summaryrefslogtreecommitdiff
path: root/test/ruby/test_marshal.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-09-23 01:36:27 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-10-02 11:43:35 +0900
commitd08721465850a6e6954b43bbfebe2ed5a7256dec (patch)
tree4d7b76889e7e9f06f886ffb66ed614cfa6088332 /test/ruby/test_marshal.rb
parent806e7947fec775ce27aa783ee00dbd8f52685db8 (diff)
Restore Hash#compare_by_identity mode [Bug #18171]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4893
Diffstat (limited to 'test/ruby/test_marshal.rb')
-rw-r--r--test/ruby/test_marshal.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index 131ebd5fa6..4f25344bf6 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -870,4 +870,23 @@ class TestMarshal < Test::Unit::TestCase
Marshal.load(s, :freeze.to_proc)
end
end
+
+ def _test_hash_compared_by_identity(h)
+ h.compare_by_identity
+ h["a" + "0"] = 1
+ h["a" + "0"] = 2
+ h = Marshal.load(Marshal.dump(h))
+ assert_predicate(h, :compare_by_identity?)
+ a = h.to_a
+ assert_equal([["a0", 1], ["a0", 2]], a.sort)
+ assert_not_same(a[1][0], a[0][0])
+ end
+
+ def test_hash_compared_by_identity
+ _test_hash_compared_by_identity(Hash.new)
+ end
+
+ def test_hash_default_compared_by_identity
+ _test_hash_compared_by_identity(Hash.new(true))
+ end
end