This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix test (see <20100901161607.GB2892@iabyn.com>)
[perl5.git] / t / re / overload.t
... / ...
CommitLineData
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
22 my @realloc;
23 my $TAG = "foo:bar";
24 use overload '""' => sub {$TAG};
25
26 my $o = bless [];
27 my ($one) = $o =~ /(.*)/g;
28 push @realloc, "xxxxxx"; # encourage realloc of SV and PVX
29 is $one, $TAG, "list context //g against overloaded object";
30
31
32 my $r = $o =~ /(.*)/g;
33 push @realloc, "yyyyyy"; # encourage realloc of SV and PVX
34 is $1, $TAG, "scalar context //g against overloaded object";
35 pos ($o) = 0; # Reset pos, as //g in scalar context sets it to non-0.
36
37 $o =~ /(.*)/g;
38 push @realloc, "zzzzzz"; # encourage realloc of SV and PVX
39 is $1, $TAG, "void context //g against overloaded object";
40}
41
42
43__END__