minor: OrderedHash hash algorithm fix
This commit is contained in:
parent
28227f8ac6
commit
329af9e685
@ -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)
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user