summaryrefslogtreecommitdiff
path: root/t/re/qr_gc.t
diff options
context:
space:
mode:
Diffstat (limited to 't/re/qr_gc.t')
-rw-r--r--t/re/qr_gc.t35
1 files changed, 35 insertions, 0 deletions
diff --git a/t/re/qr_gc.t b/t/re/qr_gc.t
new file mode 100644
index 0000000000..db2e96ed2c
--- /dev/null
+++ b/t/re/qr_gc.t
@@ -0,0 +1,35 @@
+#!./perl -w
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require './test.pl';
+ undef &Regexp::DESTROY;
+}
+
+plan tests => 2;
+
+if ($] >= 5.011) { # doesn't leak on 5.10.x
+ $TODO = "leaking since 32751";
+}
+
+my $destroyed;
+{
+ 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" );
+