redid while with brackets and just one condition expression

This commit is contained in:
Torsten Ruger
2014-05-12 12:26:38 +03:00
parent e2fb0a5f34
commit ee4d8033af
4 changed files with 12 additions and 9 deletions

View File

@ -4,6 +4,7 @@ require_relative "test_arguments"
require_relative "test_expressions"
require_relative "test_function_call"
require_relative "test_conditional"
require_relative "test_while"
require_relative "test_operators"
require_relative "test_function_definition"
require_relative "test_root"

View File

@ -6,21 +6,21 @@ class TestWhile < MiniTest::Test
def test_while
@string_input = <<HERE
while 1 do
while(1) do
tmp = a
puts(b)
end
HERE
@parse_output = {:while=>"while",
:while_cond=>{:expressions=>[{:integer=>"1"}],
:do=>"do"},
:body=>{:expressions=>[{:l=>{:name=>"tmp"}, :o=>"= ", :r=>{:name=>"a"}},
{:function_call=>{:name=>"puts"}, :argument_list=>[{:argument=>{:name=>"b"}}]}], :end=>"end"}}
:while_cond=>{:integer=>"1"},
:do=>"do",
:body=>{:expressions=>[{:l=>{:name=>"tmp"}, :o=>"= ", :r=>{:name=>"a"}},
{:function_call=>{:name=>"puts"}, :argument_list=>[{:argument=>{:name=>"b"}}]}], :end=>"end"}}
@transform_output = Ast::WhileExpression.new(
[Ast::IntegerExpression.new(1)],
Ast::IntegerExpression.new(1),
[Ast::OperatorExpression.new("=", Ast::NameExpression.new("tmp"),Ast::NameExpression.new("a")),
Ast::FuncallExpression.new("puts", [Ast::NameExpression.new("b")] )] )
Ast::FuncallExpression.new("puts", [Ast::NameExpression.new("b")] )] )
@parser = @parser.while_do
end
end