adding instance variables to class
This commit is contained in:
parent
8b364eb566
commit
85eec2f3cb
@ -43,6 +43,11 @@ module Parfait
|
|||||||
@methods[name]
|
@methods[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# adding an instance changes the instance_type to include that variable
|
||||||
|
def add_instance_variable( name , type)
|
||||||
|
@instance_type = @instance_type.add_instance_variable( name , type )
|
||||||
|
end
|
||||||
|
|
||||||
# setting the type generates all methods for this type
|
# setting the type generates all methods for this type
|
||||||
# (or will do, once we store the methods code to do that)
|
# (or will do, once we store the methods code to do that)
|
||||||
def set_instance_type( type )
|
def set_instance_type( type )
|
||||||
|
@ -34,4 +34,15 @@ class TestClass < MiniTest::Test
|
|||||||
def test_add_method
|
def test_add_method
|
||||||
assert_raises{ @try.add_instance_method(nil)}
|
assert_raises{ @try.add_instance_method(nil)}
|
||||||
end
|
end
|
||||||
|
def test_add_instance_variable_changes_type
|
||||||
|
before = @space.get_class.instance_type
|
||||||
|
@space.get_class.add_instance_variable(:counter , :Integer)
|
||||||
|
assert before != @space.get_class.instance_type
|
||||||
|
end
|
||||||
|
def test_add_instance_variable_changes_type_hash
|
||||||
|
before = @space.get_class.instance_type.hash
|
||||||
|
@space.get_class.add_instance_variable(:counter , :Integer)
|
||||||
|
assert before != @space.get_class.instance_type.hash
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user