summaryrefslogtreecommitdiff
path: root/test/ruby/test_hash.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r--test/ruby/test_hash.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 82272cb301..af3fa78e0a 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -1,5 +1,6 @@
require 'test/unit'
require 'continuation'
+require_relative "envutil"
class TestHash < Test::Unit::TestCase
@@ -920,4 +921,32 @@ class TestHash < Test::Unit::TestCase
assert_not_equal(h.hash, h.invert.hash, feature4262)
end
end
+
+ def test_exception_in_rehash
+ bug9187 = '[ruby-core:58728] [Bug #9187]'
+
+ prepare = <<-EOS
+ class Foo
+ def initialize
+ @raise = false
+ end
+
+ def hash
+ raise if @raise
+ @raise = true
+ return 0
+ end
+ end
+ EOS
+
+ code = <<-EOS
+ h = {Foo.new => true}
+ 10_0000.times do
+ h.rehash rescue nil
+ end
+ GC.start
+ EOS
+
+ assert_no_memory_leak([], prepare, code, bug9187)
+ end
end