fixing the tests from all the previous changes
This commit is contained in:
parent
25f44949e4
commit
e3de4efe02
@ -12,8 +12,8 @@ class TestAttributes < MiniTest::Test
|
||||
end
|
||||
|
||||
def test_message_name_nil
|
||||
last = @type.instance_names.last
|
||||
assert_equal :arguments , last , @type.instance_names.inspect
|
||||
last = @type.names.last
|
||||
assert_equal :arguments , last , @type.names.inspect
|
||||
assert_nil @mess.name
|
||||
end
|
||||
def test_message_next_set
|
||||
@ -21,21 +21,14 @@ class TestAttributes < MiniTest::Test
|
||||
assert_equal :next_message , @mess.next_message
|
||||
end
|
||||
def test_message_type_set
|
||||
@mess.set_type :type
|
||||
assert_equal :type , @mess.get_type
|
||||
@mess.set_type @type
|
||||
assert_equal @type , @mess.get_type
|
||||
end
|
||||
def test_attribute_index
|
||||
@mess.next_message = :message
|
||||
assert_equal Parfait::Type , @mess.get_type.class
|
||||
end
|
||||
def test_type_attribute
|
||||
@type.object_class = :message
|
||||
assert_equal :message , @type.object_class
|
||||
end
|
||||
def test_type_attribute_check
|
||||
@type.object_class = :message
|
||||
assert_equal Parfait::Type , @type.get_type.class
|
||||
end
|
||||
|
||||
def test_type_type
|
||||
assert_equal Parfait::Type , @type.get_type.get_type.class
|
||||
end
|
||||
|
@ -60,4 +60,11 @@ class TestDictionary < MiniTest::Test
|
||||
assert_equal v , shouldda[k]
|
||||
end
|
||||
end
|
||||
|
||||
def test_values
|
||||
assert @lookup.values
|
||||
end
|
||||
def test_keys
|
||||
assert @lookup.keys
|
||||
end
|
||||
end
|
||||
|
@ -34,7 +34,7 @@ class TestList < MiniTest::Test
|
||||
|
||||
def test_length0
|
||||
assert_equal 0 , @list.get_length
|
||||
assert_nil @list.indexed_length
|
||||
assert_equal 0, @list.indexed_length
|
||||
end
|
||||
def test_offset
|
||||
assert_equal 2 , @list.get_offset
|
||||
|
@ -6,44 +6,12 @@ class TestObject < MiniTest::Test
|
||||
@object = ::Parfait::Object.new
|
||||
end
|
||||
|
||||
def test_object_create
|
||||
# another test sometime adds a field variable. Maybe should reboot ?
|
||||
res = 1
|
||||
[:boo1 , :boo2 , :bro , :runner].each { |v| res += 1 if @object.get_type.variable_index(v) }
|
||||
assert_equal res , @object.get_type.instance_length , @object.get_type.inspect
|
||||
end
|
||||
|
||||
def test_empty_object_doesnt_return
|
||||
assert_nil @object.get_internal_word(3)
|
||||
assert_nil @object.get_internal_word(3)
|
||||
end
|
||||
|
||||
def test_one_set1
|
||||
assert_equal 1 , @object.set_internal_word(1,1)
|
||||
assert_equal @object.get_type , @object.set_internal_word(1, @object.get_type)
|
||||
end
|
||||
|
||||
def test_one_set2
|
||||
assert_equal :some , @object.set_internal_word(2,:some)
|
||||
end
|
||||
|
||||
def test_two_sets
|
||||
assert_equal 1 , @object.set_internal_word(1,1)
|
||||
assert_equal :some , @object.set_internal_word(1,:some)
|
||||
end
|
||||
def test_one_get1
|
||||
test_one_set1
|
||||
assert_equal 1 , @object.get_internal_word(1)
|
||||
end
|
||||
def test_one_get2
|
||||
test_one_set2
|
||||
assert_equal :some , @object.get_internal_word(2)
|
||||
end
|
||||
def test_many_get
|
||||
shouldda = { 1 => :one , 2 => :two , 3 => :three}
|
||||
shouldda.each do |k,v|
|
||||
@object.set_internal_word(k,v)
|
||||
end
|
||||
shouldda.each do |k,v|
|
||||
assert_equal v , @object.get_internal_word(k)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user