diff --git a/test/parser/test_basic.rb b/test/parser/test_basic.rb index f673dbac..3c9110f5 100644 --- a/test/parser/test_basic.rb +++ b/test/parser/test_basic.rb @@ -21,8 +21,7 @@ class TestBasic < MiniTest::Test def test_comment out = "# i am a comment \n" @string_input = out.dup #NEEDS the return, which is what delimits the comment - out = out[1..-2] - @parse_output = {:comment => out} + @parse_output = out @transform_output = @parse_output #dont transform @parser = @parser.comment end diff --git a/test/parser/test_root.rb b/test/parser/test_root.rb index 3f5624bc..a8d6189e 100644 --- a/test/parser/test_root.rb +++ b/test/parser/test_root.rb @@ -22,7 +22,26 @@ HERE Ast::CallSiteExpression.new("foo", [Ast::IntegerExpression.new(3)] )] end - + + def test_comments + @string_input = <{:name=>"foo"}, :parmeter_list=>[{:parmeter=>{:name=>"x"}}], :expressions=>[{:l=>{:name=>"a"}, :o=>"= ", :r=>{:integer=>"5"}}], :end=>"end"}, {:call_site=>{:name=>"foo"}, :argument_list=>[{:argument=>{:integer=>"3"}}]}] + @transform_output = [Ast::FunctionExpression.new(:foo, [Ast::NameExpression.new("x")] , [Ast::OperatorExpression.new("=", Ast::NameExpression.new("a"),Ast::IntegerExpression.new(5))] ), Ast::CallSiteExpression.new(:foo, [Ast::IntegerExpression.new(3)] )] + end + def test_fibo1 @string_input = < 1 ) do - tmp = a - a = b - b = tmp + b - putstring(b) - n = n - 1 - end +def fibonaccit(n) # n == r0 + a = 0 # a == r1 + b = 1 # b = r2 + while( n > 1 ) do #BUG comment lines + comments behind function calls + tmp = a # r3 <- r1 + a = b # r1 <- r2 + b = tmp + b # r4 = r2 + r3 (r4 transient) r2 <- r4 + putstring(b) + n = n - 1 # r2 <- 0 ???? #call ok + end #r5 <- r0 - 1 # r0 <- r5 end fibonaccit( 10 )