2014-04-29 15:47:33 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
2014-04-29 16:02:38 +02:00
|
|
|
class TestExpressions < MiniTest::Test
|
2014-04-29 15:47:33 +02:00
|
|
|
# include the magic (setup and parse -> test method translation), see there
|
|
|
|
include ParserHelper
|
|
|
|
|
|
|
|
def test_expression_else
|
|
|
|
@string_input = <<HERE
|
2014-05-12 12:47:47 +02:00
|
|
|
dud
|
|
|
|
fuu(3)
|
2014-04-29 15:47:33 +02:00
|
|
|
else
|
|
|
|
HERE
|
2014-05-12 12:47:47 +02:00
|
|
|
@string_input.chop!
|
|
|
|
@parse_output = {:expressions=>[{:name=>"dud"},
|
|
|
|
{:function_call=>{:name=>"fuu"}, :argument_list=>[{:argument=>{:integer=>"3"}}]}],
|
|
|
|
:else=>"else"}
|
|
|
|
@transform_output ={:expressions=>[Ast::NameExpression.new("dud"),
|
|
|
|
Ast::FuncallExpression.new("fuu", [Ast::IntegerExpression.new(3)] )], :else=>"else"}
|
2014-04-29 15:47:33 +02:00
|
|
|
@parser = @parser.expressions_else
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_expression_end
|
|
|
|
@string_input = <<HERE
|
|
|
|
name
|
|
|
|
call(4,6)
|
|
|
|
end
|
|
|
|
HERE
|
2014-05-12 12:47:47 +02:00
|
|
|
@string_input.chop!
|
|
|
|
@parse_output = {:expressions=>[{:name=>"name"},
|
|
|
|
{:function_call=>{:name=>"call"}, :argument_list=>[{:argument=>{:integer=>"4"}}, {:argument=>{:integer=>"6"}}]}],
|
|
|
|
:end=>"end"}
|
|
|
|
@transform_output = {:expressions=>[Ast::NameExpression.new("name"),
|
|
|
|
Ast::FuncallExpression.new("call", [Ast::IntegerExpression.new(4),Ast::IntegerExpression.new(6)] )],
|
|
|
|
:end=>"end"}
|
2014-04-29 15:47:33 +02:00
|
|
|
|
|
|
|
@parser = @parser.expressions_end
|
|
|
|
end
|
|
|
|
|
2014-05-10 20:41:46 +02:00
|
|
|
|
2014-04-29 15:47:33 +02:00
|
|
|
end
|