This commit is contained in:
Torsten Ruger 2017-01-01 21:50:54 +02:00
parent adf35ca038
commit 06cfbdf066
4 changed files with 11 additions and 13 deletions

View File

@ -21,7 +21,8 @@ module Melon
def on_class statement
name , sup , body = *statement
clazz = Parfait.object_space.create_class(get_name(name) , get_name(sup) )
class_name = get_name(name)
clazz = Parfait.object_space.create_class(class_name , get_name(sup) )
ivar_hash = TypeCollector.new.collect(body)
clazz.set_instance_type( Parfait::Type.for_hash( clazz , ivar_hash ) )

View File

@ -4,7 +4,7 @@ module Melon
class TestTypeCollector < MiniTest::Test
def setup
Register.machine.boot unless Register.machine.booted
Register.machine.boot
end
def parse_collect( input )
@ -30,6 +30,7 @@ module Melon
def test_compile_class
Compiler.compile "class TestIvar < Object ; def meth; @ivar;end; end"
itest = Parfait.object_space.get_class_by_name(:TestIvar)
assert itest
assert itest.instance_type.names.include?(:ivar) , itest.instance_type.names.inspect
end

View File

@ -4,19 +4,21 @@ module Melon
class TestClass < MiniTest::Test
def setup
Register.machine.boot unless Register.machine.booted
Register.machine.boot
end
def test_creates_class_without_deriviation
Compiler.compile "class Testing ; end"
assert t = Parfait.object_space.get_class_by_name(:Testing) , "No classes created"
assert_equal :Object , t.super_class_name
clazz = Parfait.object_space.get_class_by_name(:Testing)
assert clazz , "No classes created"
assert_equal :Object , clazz.super_class_name
end
def test_creates_class_with_deriviation
Compiler.compile "class Test2 < List ;end"
assert t = Parfait.object_space.get_class_by_name(:Test2) , "No classes created"
assert_equal :List , t.super_class_name
clazz = Parfait.object_space.get_class_by_name(:Test2)
assert clazz, "No classes created"
assert_equal :List , clazz.super_class_name
end
end

View File

@ -2,12 +2,6 @@ require_relative "../helper"
module Register
class TestCollector < MiniTest::Test
def test_collect_raises
Parfait.set_object_space( BootSpace.new )
assert_raises {Register::Collector.collect_space}
end
def test_simple_collect
Machine.new.boot
objects = Register::Collector.collect_space