This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Copy RE capture buf on overload as well as TEMP
[perl5.git] / t / re / overload.t
CommitLineData
a9f6cb1f
A
1#!./perl
2
3use strict;
4use warnings;
5no warnings 'syntax';
6
7BEGIN {
8 chdir 't' if -d 't';
9 @INC = '../lib';
10}
11
12sub is;
13sub plan;
14
15require './test.pl';
16plan tests => 3;
17
18{
19 # Bug #77084 points out a corruption problem when scalar //g is used
20 # on overloaded objects.
21
f427b557 22 my @realloc;
a9f6cb1f
A
23 my $TAG = "foo:bar";
24 use overload '""' => sub {$TAG};
25
26 my $o = bless [];
27 my ($one) = $o =~ /(.*)/g;
f427b557 28 push @realloc, "xxxxxx"; # encourage realloc of SV and PVX
a9f6cb1f
A
29 is $one, $TAG, "list context //g against overloaded object";
30
a9f6cb1f
A
31
32 my $r = $o =~ /(.*)/g;
f427b557 33 push @realloc, "yyyyyy"; # encourage realloc of SV and PVX
a9f6cb1f
A
34 is $1, $TAG, "scalar context //g against overloaded object";
35
f427b557
DM
36 local our $TODO = "Bug #77084";
37
a9f6cb1f 38 $o =~ /(.*)/g;
f427b557 39 push @realloc, "zzzzzz"; # encourage realloc of SV and PVX
a9f6cb1f
A
40 is $1, $TAG, "void context //g against overloaded object";
41}
42
43
44__END__