24 lines
693 B
Ruby
24 lines
693 B
Ruby
require_relative "helper"
|
|
|
|
class TestConditional < MiniTest::Test
|
|
# include the magic (setup and parse -> test method translation), see there
|
|
include ParserHelper
|
|
|
|
def test_conditional
|
|
@string_input = <<HERE
|
|
if(0)
|
|
42
|
|
else
|
|
667
|
|
end
|
|
HERE
|
|
@parse_output = { :conditional => { :integer => "0"},
|
|
:if_true => { :expressions => [ { :integer => "42" } ] } ,
|
|
:if_false => { :expressions => [ { :integer => "667" } ] } }
|
|
@transform_output = Ast::ConditionalExpression.new( Ast::IntegerExpression.new(0),
|
|
[Ast::IntegerExpression.new(42)], [Ast::IntegerExpression.new(667)])
|
|
|
|
@parser = @parser.conditional
|
|
end
|
|
|
|
end |