first root test

This commit is contained in:
Torsten Ruger 2014-05-10 12:57:10 +03:00
parent 94e8a947d9
commit 7d69132d90
2 changed files with 35 additions and 6 deletions

View File

@ -1,7 +1,8 @@
require_relative "test_basic.rb"
require_relative "test_arguments.rb"
require_relative "test_expressions.rb"
require_relative "test_function_call.rb"
require_relative "test_conditional.rb"
require_relative "test_function_definition.rb"
require_relative "test_basic"
require_relative "test_arguments"
require_relative "test_expressions"
require_relative "test_function_call"
require_relative "test_conditional"
require_relative "test_function_definition"
require_relative "test_root"

28
test/parser/test_root.rb Normal file
View File

@ -0,0 +1,28 @@
require_relative "helper"
class TestRoot < MiniTest::Test
# include the magic (setup and parse -> test method translation), see there
include ParserHelper
def test_double_root
@string_input = <<HERE
def foo(x)
a = 5
end
foo( 3 )
HERE
@parse_output = [
{:function_definition=> { :name=>"foo"}, :parmeter_list => [ {:parmeter=>{:name=>"x"}} ] ,
:expressions=>[{:asignee=>{:name=>"a"}, :asigned=>{:integer=>"5"} } ] } ,
{:function_call => { :name => "foo" }, :argument_list => [ { :argument => { :integer => "3" } } ] }]
@transform_output = [ Ast::FunctionExpression.new("foo" ,
[Ast::NameExpression.new("x")] ,
[Ast::AssignmentExpression.new( "a", Ast::IntegerExpression.new(5)) ] ) ,
Ast::FuncallExpression.new( "foo", [ Ast::IntegerExpression.new(3) ] ) ]
end
end