diff options
| author | Koichi Sasada <ko1@atdot.net> | 2023-12-15 11:21:39 +0900 |
|---|---|---|
| committer | Koichi Sasada <ko1@atdot.net> | 2023-12-15 11:58:43 +0900 |
| commit | 406d4bb59905903cf7b9fa62c2d590e963edda5c (patch) | |
| tree | f8d7f95a0368b1cbd62611ccb0fbb11faee9a60b /test/ruby | |
| parent | 7ba2506232d3fa6c4e82e3708c0ff746a1a8de5c (diff) | |
add a test
proposed at https://bugs.ruby-lang.org/issues/20050#note-5
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_hash.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 8658e6ddc2..70daea0ef1 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -2311,4 +2311,26 @@ class TestHashOnly < 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 |
