From 329af9e685478327cb40561b24ad71cd1dd38b2e Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Thu, 21 Jan 2010 17:35:53 -0500 Subject: [PATCH] minor: OrderedHash hash algorithm fix --- lib/mongo/util/ordered_hash.rb | 2 +- test/test_ordered_hash.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/mongo/util/ordered_hash.rb b/lib/mongo/util/ordered_hash.rb index 3e40091..ca849ac 100644 --- a/lib/mongo/util/ordered_hash.rb +++ b/lib/mongo/util/ordered_hash.rb @@ -120,7 +120,7 @@ class OrderedHash < Hash code = 37 * code + key.hash code = 37 * code + value.hash end - code + code & 0x7fffffff end def eql?(o) diff --git a/test/test_ordered_hash.rb b/test/test_ordered_hash.rb index 276cabb..08c957b 100644 --- a/test/test_ordered_hash.rb +++ b/test/test_ordered_hash.rb @@ -19,6 +19,12 @@ class OrderedHashTest < Test::Unit::TestCase assert_equal a, b end + def test_hash_code + o = OrderedHash.new + o['number'] = 50 + assert o.hash + end + def test_empty assert_equal [], OrderedHash.new.keys end