From ff32d809d6a93c134e1e28175c175babfc8a2b16 Mon Sep 17 00:00:00 2001 From: Laurent Sansonetti Date: Sat, 13 Jul 2013 14:41:37 +0200 Subject: [PATCH] add test for Hash.new{} leak --- test/test/spec/block_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/test/spec/block_spec.rb b/test/test/spec/block_spec.rb index c8fe1b19..4c9d24da 100644 --- a/test/test/spec/block_spec.rb +++ b/test/test/spec/block_spec.rb @@ -212,3 +212,20 @@ describe "self" do $test_dealloc.should == true end end + +describe "Hash.new {}" do + class TestObjectDealloc + def dealloc + $test_dealloc = true + super + end + end + it "does not leak memory" do + $test_dealloc = false + autorelease_pool do + h = Hash.new { |h, k| h[k] = [] } + h['1'] << TestObjectDealloc.new + end + $test_dealloc.should == true + end +end