vool method fix

This commit is contained in:
Torsten Ruger 2017-04-06 14:02:18 +03:00
parent 488af5b8f7
commit 3683aa8976
2 changed files with 13 additions and 11 deletions

View File

@ -19,7 +19,7 @@ module Vool
def on_def( statement ) def on_def( statement )
name , args , body = *statement name , args , body = *statement
arg_array = process_all( args ) arg_array = process_all( args )
MethodStatement.new( name , arg_array , body ) MethodStatement.new( name , arg_array , process(body) )
end end
def on_arg( arg ) def on_arg( arg )

View File

@ -3,26 +3,28 @@ require_relative "helper"
module Vool module Vool
class TestMethodStatement < MiniTest::Test class TestMethodStatement < MiniTest::Test
def setup def basic_setup()
input = "def tryout(arg1, arg2) ; end " input = "def tryout(arg1, arg2) ; true ; false ; end "
@lst = Compiler.compile( input ) @lst = Compiler.compile( input )
end end
def test_method
def test_compile_method basic_setup
assert_equal MethodStatement , @lst.class assert_equal MethodStatement , @lst.class
end end
def test_compile_method_name def test_method_name
basic_setup
assert_equal :tryout , @lst.name assert_equal :tryout , @lst.name
end end
def test_compile_method_super def test_method_args
basic_setup
assert_equal [:arg1, :arg2] , @lst.args assert_equal [:arg1, :arg2] , @lst.args
end end
def test_basic_body
def test_compile_method_body basic_setup
assert_equal [] , @lst.body assert_equal ScopeStatement , @lst.body.class
assert_equal 2 , @lst.body.length
end end
end end
end end