found and fixed hashing bug
This commit is contained in:
parent
d6c503ecf4
commit
0fa7f54bcc
@ -47,7 +47,7 @@ module Parfait
|
||||
|
||||
def self.hash_code_for_hash( dict )
|
||||
index = 1
|
||||
hash_code = 5467
|
||||
hash_code = str_hash(dict[:type])
|
||||
dict.each do |name , type|
|
||||
next if name == :type
|
||||
item_hash = str_hash(name) + str_hash(type)
|
||||
|
@ -22,12 +22,12 @@ class TypeHash < MiniTest::Test
|
||||
end
|
||||
|
||||
def test_name
|
||||
assert_equal "BinaryCode_Type" , @types.values.first.name
|
||||
assert_equal "Word_Type" , @types.values.first.name
|
||||
end
|
||||
|
||||
def test_to_hash
|
||||
assert_equal "BinaryCode_Type" , @first.name
|
||||
assert_equal :BinaryCode , @first.object_class.name
|
||||
assert_equal "Word_Type" , @first.name
|
||||
assert_equal :Word , @first.object_class.name
|
||||
hash = @first.to_hash
|
||||
assert_equal :Type , @first.types.first
|
||||
assert_equal hash[:type] , :Type
|
||||
@ -51,4 +51,9 @@ class TypeHash < MiniTest::Test
|
||||
assert @first.hash != type.hash
|
||||
end
|
||||
|
||||
def test_hash_for_no_ivars
|
||||
h1 = Parfait::Type.hash_code_for_hash( type: :NewInt)
|
||||
h2 = Parfait::Type.hash_code_for_hash( type: :NewObj)
|
||||
assert h1 != h2 , "Hashes should differ"
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user