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