RUBY-292 OrderedHash should hash with same value as Hash.
This commit is contained in:
parent
237dc98fbf
commit
28f0f7af3e
|
@ -159,6 +159,7 @@ module BSON
|
|||
@ordered_keys = []
|
||||
end
|
||||
|
||||
if RUBY_VERSION =~ /1.8.6/
|
||||
def hash
|
||||
code = 17
|
||||
each_pair do |key, value|
|
||||
|
@ -175,6 +176,7 @@ module BSON
|
|||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def clone
|
||||
Marshal::load(Marshal.dump(self))
|
||||
|
|
|
@ -45,6 +45,23 @@ class OrderedHashTest < Test::Unit::TestCase
|
|||
assert_equal 1, list.uniq.size
|
||||
end
|
||||
|
||||
if !(RUBY_VERSION =~ /1.8.6/)
|
||||
def test_compatibility_with_hash
|
||||
list = []
|
||||
doc = BSON::OrderedHash.new
|
||||
doc['_id'] = 'ab12'
|
||||
doc['name'] = 'test'
|
||||
|
||||
doc2 = {}
|
||||
doc2['_id'] = 'ab12'
|
||||
doc2['name'] = 'test'
|
||||
list << doc
|
||||
list << doc2
|
||||
|
||||
assert_equal 1, list.uniq.size
|
||||
end
|
||||
end
|
||||
|
||||
def test_equality
|
||||
a = BSON::OrderedHash.new
|
||||
a['x'] = 1
|
||||
|
|
Loading…
Reference in New Issue