This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Ensure that pp_qr returns a new regexp SV each time. Resolves RT #69852.
[perl5.git] / t / op / qr.t
1 #!./perl -w
2
3 use strict;
4
5 require './test.pl';
6
7 plan(tests => 12);
8
9 sub r {
10     return qr/Good/;
11 }
12
13 my $a = r();
14 isa_ok($a, 'Regexp');
15 my $b = r();
16 isa_ok($b, 'Regexp');
17
18 my $b1 = $b;
19
20 isnt($a + 0, $b + 0, 'Not the same object');
21
22 bless $b, 'Pie';
23
24 isa_ok($b, 'Pie');
25 isa_ok($a, 'Regexp');
26 isa_ok($b1, 'Pie');
27
28 my $c = r();
29 like("$c", qr/Good/);
30 my $d = r();
31 like("$d", qr/Good/);
32
33 my $d1 = $d;
34
35 isnt($c + 0, $d + 0, 'Not the same object');
36
37 $$d = 'Bad';
38
39 like("$c", qr/Good/);
40 like("$d", qr/Bad/);
41 like("$d1", qr/Bad/);