From 0ef2923c2b9afb76b3a1cebc56ebabc71c9a2ba8 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Mon, 15 Mar 2021 22:15:03 -0400 Subject: Avoid rehashing in Hash#replace/dup/initialize_copy [Bug #16996] --- test/ruby/test_hash.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 25dfaf4f64..3458053fea 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -113,13 +113,8 @@ class TestHash < Test::Unit::TestCase assert_equal(2, h[1]) end - def test_dup_will_rehash - set1 = @cls[] - set2 = @cls[set1 => true] - - set1[set1] = true - - assert_equal set2, set2.dup + def test_dup_will_not_rehash + assert_hash_does_not_rehash(&:dup) end def assert_hash_does_not_rehash @@ -480,6 +475,7 @@ class TestHash < Test::Unit::TestCase h1 = @cls[h => 1] assert_equal(h1, h1.dup) h[1] = 2 + h1.rehash assert_equal(h1, h1.dup) end -- cgit v1.2.3