RUBY-281 make BSON::OrderedHash#inspect more precise.
This commit is contained in:
parent
28f0f7af3e
commit
eca6653bc2
|
@ -119,9 +119,9 @@ module BSON
|
|||
end
|
||||
|
||||
def inspect
|
||||
str = '{'
|
||||
str = "#<BSON::OrderedHash:0x#{self.object_id.to_s(16)} {"
|
||||
str << (@ordered_keys || []).collect { |k| "\"#{k}\"=>#{self.[](k).inspect}" }.join(", ")
|
||||
str << '}'
|
||||
str << '}>'
|
||||
end
|
||||
|
||||
def delete(key, &block)
|
||||
|
|
|
@ -38,6 +38,7 @@ class OrderedHashTest < Test::Unit::TestCase
|
|||
same_doc = BSON::OrderedHash.new
|
||||
same_doc['_id'] = 'ab12'
|
||||
same_doc['name'] = 'test'
|
||||
|
||||
list << doc
|
||||
list << same_doc
|
||||
|
||||
|
@ -191,7 +192,7 @@ class OrderedHashTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_inspect_retains_order
|
||||
assert_equal '{"c"=>1, "a"=>2, "z"=>3}', @oh.inspect
|
||||
assert_equal "#<BSON::OrderedHash:0x#{@oh.object_id.to_s(16)} {\"c\"=>1, \"a\"=>2, \"z\"=>3}>", @oh.inspect
|
||||
end
|
||||
|
||||
def test_clear
|
||||
|
|
Loading…
Reference in New Issue