soml-parser/test/unit/test_arguments.rb

37 lines
1.3 KiB
Ruby
Raw Normal View History

2014-06-26 10:55:49 +02:00
require_relative "../parser_helper"
2014-06-04 18:56:50 +02:00
class TestArguments < MiniTest::Test
# include the magic (setup and parse -> test method translation), see there
include ParserHelper
def test_one_argument
@string_input = '(42)'
@parse_output = {:argument_list => [{:argument => {:integer => '42'}}] }
@transform_output = [Ast::IntegerExpression.new(42) ]
@parser = @parser.argument_list
end
def test_argument_list
@string_input = '(42, foo)'
@parse_output = {:argument_list => [{:argument => {:integer => '42'}},
{:argument => {:name => 'foo'}}]}
@transform_output = [Ast::IntegerExpression.new(42), Ast::NameExpression.new('foo')]
@parser = @parser.argument_list
end
2014-06-19 18:33:08 +02:00
def test_parameter
2014-06-04 18:56:50 +02:00
@string_input = "(foo)"
2014-06-19 18:33:08 +02:00
@parse_output = {:parameter_list=>[{:parameter=>{:name=>"foo"}}]}
2014-06-04 18:56:50 +02:00
@transform_output = [Ast::NameExpression.new('foo')]
2014-06-19 18:33:08 +02:00
@parser = @parser.parameter_list
2014-06-04 18:56:50 +02:00
end
2014-06-19 18:33:08 +02:00
def test_parameter_list
2014-06-04 18:56:50 +02:00
@string_input = "( foo , bar)"
2014-06-19 18:33:08 +02:00
@parse_output = {:parameter_list => [{:parameter => { :name => "foo"}},
{:parameter => { :name => "bar"}} ]}
2014-06-04 18:56:50 +02:00
@transform_output = [Ast::NameExpression.new('foo') , Ast::NameExpression.new('bar')]
2014-06-19 18:33:08 +02:00
@parser = @parser.parameter_list
2014-06-04 18:56:50 +02:00
end
end