This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix bug with (??{$overload}) regexp caching
[perl5.git] / t / re / qr_gc.t
1 #!./perl -w
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     require './test.pl';
7     undef &Regexp::DESTROY;
8 }
9
10 plan tests => 2;
11
12 my $destroyed;
13 {
14     sub Regexp::DESTROY { $destroyed++ }
15 }
16
17 {
18     my $rx = qr//;
19 }
20
21 is( $destroyed, 1, "destroyed regexp" );
22
23 undef $destroyed;
24
25 {
26     my $var = bless {}, "Foo";
27     my $rx = qr/(?{ $var })/;
28 }
29
30 is( $destroyed, 1, "destroyed regexp with closure capture" );
31