In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/ade1ceae51b239152f8abd667cb1ad2441b86bdf?hp=45d74e11808ef284790f2e31eb9ae23f46569f07>

- Log -----------------------------------------------------------------
commit ade1ceae51b239152f8abd667cb1ad2441b86bdf
Author: David Mitchell <[email protected]>
Date:   Fri Mar 11 13:36:42 2011 +0000

    add more tests for 'my @a =' OPpASSIGN_COMMON
    
    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].
-----------------------------------------------------------------------

Summary of changes:
 t/op/array.t |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/t/op/array.t b/t/op/array.t
index c5d45d7..f995ea3 100644
--- a/t/op/array.t
+++ b/t/op/array.t
@@ -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
@@ -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');
 

--
Perl5 Master Repository

Reply via email to