require_relative "helper" # Please read note in test_parser require_relative 'helper' class TestAst < MiniTest::Test def setup @parser = Parser::Composed.new @transform = Parser::Transform.new end def check syntax = @parser.parse(@string_input) tree = @transform.apply(syntax) # puts tree.inspect assert_equal @transform_output , tree end def test_expression_else @string_input = <[ Parser::IntegerExpression.new(4), Parser::IntegerExpression.new(5)]} @parser = @parser.expressions_else check end def test_expression_end @string_input = < [Parser::IntegerExpression.new(5), Parser::NameExpression.new("name"), Parser::FuncallExpression.new("call", [Parser::IntegerExpression.new(4), Parser::IntegerExpression.new(6) ]) ] } @parser = @parser.expressions_end check end def test_conditional @string_input = <