minor: OrderedHash hash algorithm fix

This commit is contained in:
Kyle Banker 2010-01-21 17:35:53 -05:00
parent 28227f8ac6
commit 329af9e685
2 changed files with 7 additions and 1 deletions

View File

@ -120,7 +120,7 @@ class OrderedHash < Hash
code = 37 * code + key.hash code = 37 * code + key.hash
code = 37 * code + value.hash code = 37 * code + value.hash
end end
code code & 0x7fffffff
end end
def eql?(o) def eql?(o)

View File

@ -19,6 +19,12 @@ class OrderedHashTest < Test::Unit::TestCase
assert_equal a, b assert_equal a, b
end end
def test_hash_code
o = OrderedHash.new
o['number'] = 50
assert o.hash
end
def test_empty def test_empty
assert_equal [], OrderedHash.new.keys assert_equal [], OrderedHash.new.keys
end end