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:
@ -48,6 +48,20 @@ module Parfait
|
||||
@space.get_class.add_instance_variable(:counter , :Integer)
|
||||
assert before != @space.get_class.instance_type.hash
|
||||
end
|
||||
|
||||
def test_has_single
|
||||
assert_equal SingletonClass , @try.single_class.class
|
||||
end
|
||||
def test_before_not_single_type
|
||||
assert_equal false , @try.type.is_single?
|
||||
end
|
||||
def test_single_type_not_class
|
||||
hash_after = @try.single_class.instance_type.hash
|
||||
assert_equal @try.type.hash , hash_after
|
||||
end
|
||||
def test_single_type_not_class_before
|
||||
hash_before = @try.type.hash
|
||||
hash_after = @try.single_class.instance_type.hash
|
||||
refute_equal hash_before , hash_after
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user