Introduce singleton types
Just for future, as this gives us a way to know immediately in the type, which represent normal, and which singleton classes Also instantiate singleton class lazily (with singleton type) This makes the type of class single, ie unique, immediately when it is used, ie methods or variables defined. Fixes a design mistake, where all singletonn classes shared the same type, and thus unique methods per class were impossible (Also some misc in commit)
This commit is contained in:
@ -13,35 +13,29 @@ module Parfait
|
||||
def test_type_index
|
||||
assert_equal @mess.get_type , @mess.get_internal_word(Parfait::TYPE_INDEX) , "mess"
|
||||
end
|
||||
|
||||
def test_type_is_first
|
||||
type = @mess.get_type
|
||||
assert_equal 0 , type.variable_index(:type)
|
||||
end
|
||||
|
||||
def test_length
|
||||
assert @mess
|
||||
assert @mess.get_type
|
||||
assert_equal 31 , @mess.get_type.instance_length , @mess.get_type.inspect
|
||||
end
|
||||
|
||||
def test_names
|
||||
assert @type.names
|
||||
end
|
||||
def test_types
|
||||
assert @type.types
|
||||
end
|
||||
|
||||
def test_type_length
|
||||
assert_equal 31 , @mess.get_type.instance_length , @mess.get_type.inspect
|
||||
end
|
||||
|
||||
def test_type_length_index
|
||||
type = @mess.get_type.get_type
|
||||
assert_equal 4 , type.variable_index(:methods)
|
||||
assert_equal type.object_class , type.get_internal_word(3)
|
||||
end
|
||||
|
||||
def test_no_index_below_0
|
||||
type = @mess.get_type
|
||||
names = type.names
|
||||
@ -50,12 +44,10 @@ module Parfait
|
||||
assert type.variable_index(n) >= 0
|
||||
end
|
||||
end
|
||||
|
||||
def test_attribute_set
|
||||
@mess.set_receiver( 55)
|
||||
assert_equal 55 , @mess.receiver
|
||||
end
|
||||
|
||||
def test_variable_index
|
||||
assert_equal 1 , @type.variable_index(:next_message)
|
||||
end
|
||||
@ -68,7 +60,6 @@ module Parfait
|
||||
def test_type_for
|
||||
assert_equal :Message , @type.type_for(:next_message)
|
||||
end
|
||||
|
||||
def test_remove_me
|
||||
type = @mess.get_type
|
||||
assert_equal type , @mess.get_internal_word(0)
|
||||
@ -83,5 +74,9 @@ module Parfait
|
||||
int_class = @space.get_type_by_class_name(:Integer)
|
||||
assert_equal :Integer, int_class.object_class.name
|
||||
end
|
||||
def test_create_single
|
||||
single = Type.for_hash( {} , :Object ,1)
|
||||
assert_equal true , single.is_single?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user