This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #93320] localising @DB::args leads to coredump
[perl5.git] / t / op / qr.t
CommitLineData
c2123ae3
NC
1#!./perl -w
2
3use strict;
4
5require './test.pl';
6
b9ad13ac 7plan(tests => 18);
c2123ae3
NC
8
9sub r {
10 return qr/Good/;
11}
12
13my $a = r();
14isa_ok($a, 'Regexp');
15my $b = r();
16isa_ok($b, 'Regexp');
17
18my $b1 = $b;
19
20isnt($a + 0, $b + 0, 'Not the same object');
21
22bless $b, 'Pie';
23
24isa_ok($b, 'Pie');
25isa_ok($a, 'Regexp');
26isa_ok($b1, 'Pie');
27
28my $c = r();
29like("$c", qr/Good/);
30my $d = r();
31like("$d", qr/Good/);
32
33my $d1 = $d;
34
35isnt($c + 0, $d + 0, 'Not the same object');
36
37$$d = 'Bad';
38
39like("$c", qr/Good/);
b9ad13ac
NC
40is($$d, 'Bad');
41is($$d1, 'Bad');
42
43# Assignment to an implicitly blessed Regexp object retains the class
44# (No different from direct value assignment to any other blessed SV
45
46isa_ok($d, 'Regexp');
47like("$d", qr/\ARegexp=SCALAR\(0x[0-9a-f]+\)\z/);
48
49# As does an explicitly blessed Regexp object.
50
51my $e = bless qr/Faux Pie/, 'Stew';
52
53isa_ok($e, 'Stew');
54$$e = 'Fake!';
55
56is($$e, 'Fake!');
57isa_ok($e, 'Stew');
58like("$e", qr/\Stew=SCALAR\(0x[0-9a-f]+\)\z/);