summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKJ Tsanaktsidis <ktsanaktsidis@zendesk.com>2024-03-28 15:57:10 +1100
committernagachika <nagachika@ruby-lang.org>2024-04-08 18:40:47 +0900
commit06049fe98ef6eced6ccf6028621f3e10edeedccb (patch)
tree47f632759c5c0fbf2b280606e017684ebcc4032a /test
parente6bf38a6e7fbae0097fdf51e3c752820a2c58ae4 (diff)
Backport https://github.com/ruby/ruby/pull/9240 to Ruby 3.2
Merged into master in 7ba2506232d3fa6c4e82e3708c0ff746a1a8de5c [Bug #20050]
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_hash.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 8d36cf657f..639c0105c0 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -2246,4 +2246,24 @@ class TestHash < Test::Unit::TestCase
end;
end
end
+
+ def test_ar_hash_to_st_hash
+ assert_normal_exit("#{<<~"begin;"}\n#{<<~'end;'}", 'https://bugs.ruby-lang.org/issues/20050#note-5')
+ begin;
+ srand(0)
+ class Foo
+ def to_a
+ []
+ end
+ def hash
+ $h.delete($h.keys.sample) if rand < 0.1
+ to_a.hash
+ end
+ end
+ 1000.times do
+ $h = {}
+ (0..10).each {|i| $h[Foo.new] ||= {} }
+ end
+ end;
+ end
end