rubyx/test/parser/test_basic.rb

37 lines
986 B
Ruby
Raw Normal View History

require_relative "helper"
class TestBasic < MiniTest::Test
# include the magic (setup and parse -> test method translation), see there
include ParserHelper
def test_number
@string_input = '42 '
@parse_output = {:integer => '42'}
2014-05-05 08:51:16 +02:00
@transform_output = Ast::IntegerExpression.new(42)
@parser = @parser.integer
end
def test_name
@string_input = 'foo '
@parse_output = {:name => 'foo'}
2014-05-05 08:51:16 +02:00
@transform_output = Ast::NameExpression.new('foo')
@parser = @parser.name
end
def test_string
@string_input = <<HERE
"hello"
HERE
@parse_output = {:string=>"hello"}
2014-05-05 08:51:16 +02:00
@transform_output = Ast::StringExpression.new('hello')
@parser = @parser.string
end
2014-04-29 15:49:37 +02:00
def test_assignment
@string_input = "a = 5"
@parse_output = { :asignee => { :name=>"a" } , :asigned => { :integer => "5" } }
2014-05-05 08:51:16 +02:00
@transform_output = Ast::AssignmentExpression.new("a", Ast::IntegerExpression.new(5) )
2014-04-29 15:49:37 +02:00
@parser = @parser.assignment
end
end