minor
This commit is contained in:
parent
adf35ca038
commit
06cfbdf066
@ -21,7 +21,8 @@ module Melon
|
|||||||
|
|
||||||
def on_class statement
|
def on_class statement
|
||||||
name , sup , body = *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)
|
ivar_hash = TypeCollector.new.collect(body)
|
||||||
clazz.set_instance_type( Parfait::Type.for_hash( clazz , ivar_hash ) )
|
clazz.set_instance_type( Parfait::Type.for_hash( clazz , ivar_hash ) )
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ module Melon
|
|||||||
class TestTypeCollector < MiniTest::Test
|
class TestTypeCollector < MiniTest::Test
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Register.machine.boot unless Register.machine.booted
|
Register.machine.boot
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_collect( input )
|
def parse_collect( input )
|
||||||
@ -30,6 +30,7 @@ module Melon
|
|||||||
def test_compile_class
|
def test_compile_class
|
||||||
Compiler.compile "class TestIvar < Object ; def meth; @ivar;end; end"
|
Compiler.compile "class TestIvar < Object ; def meth; @ivar;end; end"
|
||||||
itest = Parfait.object_space.get_class_by_name(:TestIvar)
|
itest = Parfait.object_space.get_class_by_name(:TestIvar)
|
||||||
|
assert itest
|
||||||
assert itest.instance_type.names.include?(:ivar) , itest.instance_type.names.inspect
|
assert itest.instance_type.names.include?(:ivar) , itest.instance_type.names.inspect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4,19 +4,21 @@ module Melon
|
|||||||
class TestClass < MiniTest::Test
|
class TestClass < MiniTest::Test
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Register.machine.boot unless Register.machine.booted
|
Register.machine.boot
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_creates_class_without_deriviation
|
def test_creates_class_without_deriviation
|
||||||
Compiler.compile "class Testing ; end"
|
Compiler.compile "class Testing ; end"
|
||||||
assert t = Parfait.object_space.get_class_by_name(:Testing) , "No classes created"
|
clazz = Parfait.object_space.get_class_by_name(:Testing)
|
||||||
assert_equal :Object , t.super_class_name
|
assert clazz , "No classes created"
|
||||||
|
assert_equal :Object , clazz.super_class_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_creates_class_with_deriviation
|
def test_creates_class_with_deriviation
|
||||||
Compiler.compile "class Test2 < List ;end"
|
Compiler.compile "class Test2 < List ;end"
|
||||||
assert t = Parfait.object_space.get_class_by_name(:Test2) , "No classes created"
|
clazz = Parfait.object_space.get_class_by_name(:Test2)
|
||||||
assert_equal :List , t.super_class_name
|
assert clazz, "No classes created"
|
||||||
|
assert_equal :List , clazz.super_class_name
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -2,12 +2,6 @@ require_relative "../helper"
|
|||||||
|
|
||||||
module Register
|
module Register
|
||||||
class TestCollector < MiniTest::Test
|
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
|
def test_simple_collect
|
||||||
Machine.new.boot
|
Machine.new.boot
|
||||||
objects = Register::Collector.collect_space
|
objects = Register::Collector.collect_space
|
||||||
|
Loading…
Reference in New Issue
Block a user