Skip to content

Commit

Permalink
add more tests for 'my @A =' OPpASSIGN_COMMON
Browse files Browse the repository at this point in the history
bug #70171 was fixed a while ago. This just adds some more tests for the
same (already fixed) bug.

This time its a variant which makes @A already have content at the
'my @A =' declaration, but without requiring a closure.
 See also [perl #82110].
  • Loading branch information
iabyn committed Mar 11, 2011
1 parent 45d74e1 commit ade1cea
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion t/op/array.t
Expand Up @@ -7,7 +7,7 @@ BEGIN {

require 'test.pl';

plan (128);
plan (130);

#
# @foo, @bar, and @ary are also used from tie-stdarray after tie-ing them
Expand Down Expand Up @@ -442,6 +442,28 @@ sub test_arylen {
);
}

# [perl #70171], [perl #82110]
{
my ($i, $ra, $rh);
again:
my @a = @$ra; # common assignment on 2nd attempt
my %h = %$rh; # common assignment on 2nd attempt
@a = qw(1 2 3 4);
%h = qw(a 1 b 2 c 3 d 4);
$ra = \@a;
$rh = \%h;
goto again unless $i++;

is("@a", "1 2 3 4",
'bug 70171 (self-assignment via my @x = @$x) - goto variant'
);
is(
join(" ", map +($_,$h{$_}), sort keys %h), "a 1 b 2 c 3 d 4",
'bug 70171 (self-assignment via my %x = %$x) - goto variant'
);
}


*trit = *scile; $trit[0];
ok(1, 'aelem_fast on a nonexistent array does not crash');

Expand Down

0 comments on commit ade1cea

Please sign in to comment.