a test for Paul Evan's qr leak
Yuval Kogman [Fri, 15 Aug 2008 13:59:15 +0000 (16:59 +0300)]
MANIFEST
t/op/qr_gc.t [new file with mode: 0644]

index e97e615..9df546d 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -4083,6 +4083,7 @@ t/op/pwent.t                      See if getpw*() functions work
 t/op/qq.t                      See if qq works
 t/op/qrstack.t                 See if qr expands the stack properly
 t/op/qr.t                      See if qr works
+t/op/qr_gc.t                   See if qr doesn't leak
 t/op/quotemeta.t               See if quotemeta works
 t/op/rand.t                    See if rand works
 t/op/range.t                   See if .. works
diff --git a/t/op/qr_gc.t b/t/op/qr_gc.t
new file mode 100644 (file)
index 0000000..7de3f84
--- /dev/null
@@ -0,0 +1,33 @@
+#!./perl -w
+
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+    require './test.pl';
+}
+
+plan tests => 2;
+
+$TODO = "leaking since 32751";
+
+my $destroyed;
+{
+    no warnings 'redefine';
+    sub Regexp::DESTROY { $destroyed++ }
+}
+
+{
+    my $rx = qr//;
+}
+
+is( $destroyed, 1, "destroyed regexp" );
+
+undef $destroyed;
+
+{
+    my $var = bless {}, "Foo";
+    my $rx = qr/(?{ $var })/;
+}
+
+is( $destroyed, 1, "destroyed regexp with closure capture" );
+