Commit | Line | Data |
---|---|---|
cb07477e | 1 | #!./perl -w |
a9f6cb1f A |
2 | |
3 | BEGIN { | |
4 | chdir 't' if -d 't'; | |
5 | @INC = '../lib'; | |
cb07477e | 6 | require './test.pl'; |
a9f6cb1f A |
7 | } |
8 | ||
cb07477e NC |
9 | use strict; |
10 | no warnings 'syntax'; | |
a9f6cb1f A |
11 | |
12 | { | |
13 | # Bug #77084 points out a corruption problem when scalar //g is used | |
14 | # on overloaded objects. | |
15 | ||
f427b557 | 16 | my @realloc; |
a9f6cb1f A |
17 | my $TAG = "foo:bar"; |
18 | use overload '""' => sub {$TAG}; | |
19 | ||
20 | my $o = bless []; | |
21 | my ($one) = $o =~ /(.*)/g; | |
f427b557 | 22 | push @realloc, "xxxxxx"; # encourage realloc of SV and PVX |
a9f6cb1f A |
23 | is $one, $TAG, "list context //g against overloaded object"; |
24 | ||
a9f6cb1f A |
25 | |
26 | my $r = $o =~ /(.*)/g; | |
f427b557 | 27 | push @realloc, "yyyyyy"; # encourage realloc of SV and PVX |
a9f6cb1f | 28 | is $1, $TAG, "scalar context //g against overloaded object"; |
f3a0defb | 29 | pos ($o) = 0; # Reset pos, as //g in scalar context sets it to non-0. |
f427b557 | 30 | |
a9f6cb1f | 31 | $o =~ /(.*)/g; |
f427b557 | 32 | push @realloc, "zzzzzz"; # encourage realloc of SV and PVX |
a9f6cb1f A |
33 | is $1, $TAG, "void context //g against overloaded object"; |
34 | } | |
35 | ||
cb07477e | 36 | done_testing(); |