bit more method collector/creation testing

This commit is contained in:
Torsten Ruger
2017-01-13 22:16:06 +02:00
parent 3f6c1bc3a3
commit 75c7ca950e
5 changed files with 31 additions and 16 deletions

View File

@ -20,7 +20,7 @@ module Melon
def test_one_arg
method = parse_collect("def meth2(arg1); 1;end").first
assert method.name == :meth2
assert method.args_type.variable_index(:arg1) , method.args_type.inspect
assert_equal 2 , method.args_type.variable_index(:arg1) , method.args_type.inspect
end
def test_three_args

View File

@ -8,12 +8,31 @@ module Melon
Register.machine.boot
end
def test_creates_method_in_class
def create_method
Compiler.compile in_Space("def meth; @ivar;end")
space = Parfait.object_space.get_class
method = space.get_method(:meth)
space.get_method(:meth)
end
def test_creates_method_in_class
method = create_method
assert method , "No method created"
end
def test_method_has_source
method = create_method
assert_equal "(ivar :@ivar)", method.source.to_s
end
def test_method_has_no_args
method = create_method
assert_equal 1 , method.args_type.instance_length
end
def test_method_has_no_locals
method = create_method
assert_equal 1 , method.locals_type.instance_length
end
end
end