diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2024-05-28 15:15:23 -0700 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2024-05-28 15:17:51 -0700 |
| commit | 917f3e5d22b3364002eb1fdc2f94b35ff76f6a73 (patch) | |
| tree | 06d7e9f2662d09f4c251c9e48f96faef46cc7226 /test/ruby | |
| parent | 7d3e71330fd38c402ae4a6ec14f43eb95cf50435 (diff) | |
merge revision(s) f36a71e26995b69ff72bc132bbcf40ad89571414: [Backport #20307]
[Bug #20307] Fix `Hash#update` to make frozen copy of string keys
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_hash.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index c72b256bab..a063518190 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1268,6 +1268,15 @@ class TestHash < Test::Unit::TestCase assert_equal(@cls[a: 10, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10], h) end + def test_update_on_identhash + key = +'a' + i = @cls[].compare_by_identity + i[key] = 0 + h = @cls[].update(i) + key.upcase! + assert_equal(0, h.fetch('a')) + end + def test_merge h1 = @cls[1=>2, 3=>4] h2 = {1=>3, 5=>7} @@ -1290,10 +1299,10 @@ class TestHash < Test::Unit::TestCase expected[7] = 8 h2 = h.merge(7=>8) assert_equal(expected, h2) - assert_equal(true, h2.compare_by_identity?) + assert_predicate(h2, :compare_by_identity?) h2 = h.merge({}) assert_equal(h, h2) - assert_equal(true, h2.compare_by_identity?) + assert_predicate(h2, :compare_by_identity?) h = @cls[] h.compare_by_identity @@ -1301,10 +1310,10 @@ class TestHash < Test::Unit::TestCase h1.compare_by_identity h2 = h.merge(7=>8) assert_equal(h1, h2) - assert_equal(true, h2.compare_by_identity?) + assert_predicate(h2, :compare_by_identity?) h2 = h.merge({}) assert_equal(h, h2) - assert_equal(true, h2.compare_by_identity?) + assert_predicate(h2, :compare_by_identity?) end def test_merge! |
