Tests for iterator deletion [perl #85026]
authorFather Chrysostomos <sprout@cpan.org>
Fri, 20 May 2011 00:05:48 +0000 (17:05 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 20 May 2011 01:01:46 +0000 (18:01 -0700)
t/op/hash.t

index 278bea7..fa66f4c 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
 
 use strict;
 
-plan tests => 8;
+plan tests => 9;
 
 my %h;
 
@@ -146,3 +146,15 @@ is($destroyed, 1, 'Timely hash destruction with lvalue keys');
     is ref $key, SCALAR =>
      'hash keys are not stringified during compilation';
 }
+
+# Part of RT #85026: Deleting the current iterator in void context does not
+# free it.
+{
+    my $gone;
+    no warnings 'once';
+    local *::DESTROY = sub { ++$gone };
+    my %a=(a=>bless[]);
+    each %a;   # make the entry with the obj the current iterator
+    delete $a{a};
+    ok $gone, 'deleting the current iterator in void context frees the val'
+}