fixing the tests from all the previous changes
This commit is contained in:
@ -5,6 +5,7 @@ class BasicType < MiniTest::Test
|
||||
def setup
|
||||
@mess = Register.machine.boot.space.first_message
|
||||
assert @mess
|
||||
@type = @mess.get_type()
|
||||
end
|
||||
|
||||
def test_type_index
|
||||
@ -22,22 +23,26 @@ class BasicType < MiniTest::Test
|
||||
assert_equal 9 , @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 9 , @mess.get_type.instance_length , @mess.get_type.inspect
|
||||
assert_equal 18 , @mess.get_type.get_internal_word(4)
|
||||
end
|
||||
|
||||
def test_type_length_index
|
||||
assert_equal 4 , @mess.get_type.get_type.variable_index(:indexed_length)
|
||||
assert_equal 4 , @mess.get_type.get_type.get_offset
|
||||
assert_equal 4 , @mess.get_type.get_offset
|
||||
assert_equal 8 , @mess.get_type.get_type.indexed_length
|
||||
assert_equal 8 , @mess.get_type.get_type.get_internal_word(4)
|
||||
type = @mess.get_type.get_type
|
||||
assert_equal 5 , type.variable_index(:instance_methods)
|
||||
assert_equal type.object_class , type.get_internal_word(4)
|
||||
end
|
||||
|
||||
def test_no_index_below_1
|
||||
type = @mess.get_type
|
||||
names = type.instance_names
|
||||
names = type.names
|
||||
assert_equal 9 , names.get_length , names.inspect
|
||||
names.each do |n|
|
||||
assert type.variable_index(n) >= 1
|
||||
@ -45,7 +50,7 @@ class BasicType < MiniTest::Test
|
||||
end
|
||||
|
||||
def test_attribute_set
|
||||
@mess.receiver = 55
|
||||
@mess.set_receiver( 55)
|
||||
assert_equal 55 , @mess.receiver
|
||||
end
|
||||
|
||||
@ -53,7 +58,7 @@ class BasicType < MiniTest::Test
|
||||
def test_reg_index
|
||||
message_ind = Register.resolve_to_index( :message , :receiver )
|
||||
assert_equal 3 , message_ind
|
||||
@mess.receiver = 55
|
||||
@mess.set_receiver( 55)
|
||||
assert_equal 55 , @mess.get_internal_word(message_ind)
|
||||
end
|
||||
|
||||
|
@ -24,8 +24,11 @@ class TypeHash < MiniTest::Test
|
||||
end
|
||||
|
||||
def test_to_hash
|
||||
assert_equal "Word_Type" , @first.name
|
||||
assert_equal :Word , @first.object_class.name
|
||||
hash = @first.to_hash
|
||||
assert_equal hash[:type] , :Word
|
||||
assert_equal :Type , @first.types.first
|
||||
assert_equal hash[:type] , :Type
|
||||
assert_equal hash[:char_length] , :Integer
|
||||
assert_equal 2 , @first.instance_length
|
||||
end
|
||||
|
@ -4,47 +4,49 @@ class TestMethodApi < MiniTest::Test
|
||||
|
||||
def setup
|
||||
@space = Register.machine.boot.space
|
||||
@try = @space.create_class( :Try , :Object).instance_type
|
||||
@try_class = @space.create_class( :Try )
|
||||
@try_type = @try_class.instance_type
|
||||
end
|
||||
|
||||
def foo_method for_class = :Try
|
||||
args = Parfait::Type.for_hash( @try , { bar: :Integer})
|
||||
args = Parfait::Type.for_hash( @try_class , { bar: :Integer})
|
||||
::Parfait::TypedMethod.new @space.get_class_by_name(for_class).instance_type , :foo , args
|
||||
end
|
||||
|
||||
def test_new_methods
|
||||
assert_equal @try.method_names.class, @try.instance_methods.class
|
||||
assert_equal @try.method_names.get_length , @try.instance_methods.get_length
|
||||
assert_equal @try_type.method_names.class, @try_type.instance_methods.class
|
||||
assert_equal @try_type.method_names.get_length , @try_type.instance_methods.get_length
|
||||
end
|
||||
|
||||
def test_add_method
|
||||
before = @try_type.instance_methods.get_length
|
||||
foo = foo_method
|
||||
assert_equal foo , @try.add_instance_method(foo)
|
||||
assert_equal 1 , @try.instance_methods.get_length
|
||||
assert_equal ":foo" , @try.method_names.inspect
|
||||
assert_equal foo , @try_type.add_instance_method(foo)
|
||||
assert_equal 1 , @try_type.instance_methods.get_length - before
|
||||
assert @try_type.method_names.inspect.include?(":foo")
|
||||
end
|
||||
def test_remove_method
|
||||
test_add_method
|
||||
assert_equal true , @try.remove_instance_method(:foo)
|
||||
assert_equal true , @try_type.remove_instance_method(:foo)
|
||||
end
|
||||
def test_remove_nothere
|
||||
assert_raises RuntimeError do
|
||||
@try.remove_instance_method(:foo)
|
||||
@try_type.remove_instance_method(:foo)
|
||||
end
|
||||
end
|
||||
def test_create_method
|
||||
args = Parfait::Type.for_hash( @try , { bar: :Integer})
|
||||
@try.create_instance_method :bar, args
|
||||
assert_equal ":bar" , @try.method_names.inspect
|
||||
args = Parfait::Type.for_hash( @try_class , { bar: :Integer})
|
||||
@try_type.create_instance_method :bar, args
|
||||
assert @try_type.method_names.inspect.include?("bar")
|
||||
end
|
||||
def test_method_get
|
||||
test_add_method
|
||||
assert_equal Parfait::TypedMethod , @try.get_instance_method(:foo).class
|
||||
assert_equal Parfait::TypedMethod , @try_type.get_instance_method(:foo).class
|
||||
end
|
||||
def test_method_get_nothere
|
||||
assert_nil @try.get_instance_method(:foo)
|
||||
assert_nil @try_type.get_instance_method(:foo)
|
||||
test_remove_method
|
||||
assert_nil @try.get_instance_method(:foo)
|
||||
assert_nil @try_type.get_instance_method(:foo)
|
||||
end
|
||||
def test_get_instance
|
||||
foo = foo_method :Object
|
||||
|
Reference in New Issue
Block a user