2014-04-29 12:50:07 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
class TestBasic < MiniTest::Test
|
2014-04-29 13:09:10 +02:00
|
|
|
# include the magic (setup and parse -> test method translation), see there
|
|
|
|
include ParserHelper
|
|
|
|
|
2014-04-29 15:22:39 +02:00
|
|
|
def test_number
|
2014-04-29 13:09:10 +02:00
|
|
|
@string_input = '42 '
|
2014-04-29 12:50:07 +02:00
|
|
|
@parse_output = {:integer => '42'}
|
|
|
|
@transform_output = Parser::IntegerExpression.new(42)
|
|
|
|
@parser = @parser.integer
|
|
|
|
end
|
|
|
|
|
2014-04-29 15:22:39 +02:00
|
|
|
def test_name
|
2014-04-29 13:09:10 +02:00
|
|
|
@string_input = 'foo '
|
2014-04-29 12:50:07 +02:00
|
|
|
@parse_output = {:name => 'foo'}
|
|
|
|
@transform_output = Parser::NameExpression.new('foo')
|
|
|
|
@parser = @parser.name
|
|
|
|
end
|
|
|
|
|
2014-04-29 15:22:39 +02:00
|
|
|
def test_string
|
2014-04-29 13:09:10 +02:00
|
|
|
@string_input = <<HERE
|
2014-04-29 12:50:07 +02:00
|
|
|
"hello"
|
|
|
|
HERE
|
|
|
|
@parse_output = {:string=>"hello"}
|
|
|
|
@transform_output = Parser::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" } }
|
|
|
|
@transform_output = Parser::AssignmentExpression.new("a", Parser::IntegerExpression.new(5) )
|
|
|
|
@parser = @parser.assignment
|
|
|
|
end
|
|
|
|
|
2014-04-29 12:50:07 +02:00
|
|
|
end
|