diff options
author | Ruslan Zakirov <ruz@bestpractical.com> | 2012-10-08 02:30:54 +0400 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-12-11 08:59:39 -0800 |
commit | 231cbeb24ba077cbde643fc4d5178055c1464f5c (patch) | |
tree | 206ceaf12160a1b8ccb47af55e7aadd969b13321 | |
parent | 6d70c686156da1532212fbc817c63c0a02bf894a (diff) | |
download | perl-231cbeb24ba077cbde643fc4d5178055c1464f5c.tar.gz |
scalar(%h = (1,1,1,1)) should return 4, not 2
perldoc perlop says:
a list assignment in scalar context returns the number of elements
produced by the expression on the right hand side of the assignment
Behaviour was changed as side effect of
ca65944e8ff8fff6e36ea7476ba807be16cfe2a9 where goal was to fix
return value in list context.
-rw-r--r-- | ext/Hash-Util-FieldHash/t/11_hashassign.t | 4 | ||||
-rw-r--r-- | pp_hot.c | 2 | ||||
-rw-r--r-- | t/op/hashassign.t | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/ext/Hash-Util-FieldHash/t/11_hashassign.t b/ext/Hash-Util-FieldHash/t/11_hashassign.t index e492fa228f..d3e45d32de 100644 --- a/ext/Hash-Util-FieldHash/t/11_hashassign.t +++ b/ext/Hash-Util-FieldHash/t/11_hashassign.t @@ -282,9 +282,9 @@ foreach my $chr (60, 200, 600, 6000, 60000) { fieldhash %h; is( (join ':', %h = (1) x 8), '1:1', 'hash assignment in list context removes duplicates' ); - is( scalar( %h = (1,2,1,3,1,4,1,5) ), 2, + is( scalar( %h = (1,2,1,3,1,4,1,5) ), 8, 'hash assignment in scalar context' ); - is( scalar( ($x,%h) = (0,1,2,1,3,1,4,1,5) ), 3, + is( scalar( ($x,%h) = (0,1,2,1,3,1,4,1,5) ), 9, 'scalar + hash assignment in scalar context' ); $ar = [ %h = (1,2,1,3,1,4,1,5) ]; is( $#$ar, 1, 'hash assignment in list context' ); @@ -1234,7 +1234,7 @@ PP(pp_aassign) else if (gimme == G_SCALAR) { dTARGET; SP = firstrelem; - SETi(lastrelem - firstrelem + 1 - duplicates); + SETi(lastrelem - firstrelem + 1); } else { if (ary) diff --git a/t/op/hashassign.t b/t/op/hashassign.t index 37a7674bb1..906e7ca7df 100644 --- a/t/op/hashassign.t +++ b/t/op/hashassign.t @@ -280,9 +280,9 @@ foreach my $chr (60, 200, 600, 6000, 60000) { 'hash assignment in list context removes duplicates' ); is( (join ':', %h = qw(a 1 a 2 b 3 c 4 d 5 d 6)), 'a:2:b:3:c:4:d:6', 'hash assignment in list context removes duplicates 2' ); - is( scalar( %h = (1,2,1,3,1,4,1,5) ), 2, + is( scalar( %h = (1,2,1,3,1,4,1,5) ), 8, 'hash assignment in scalar context' ); - is( scalar( ($x,%h) = (0,1,2,1,3,1,4,1,5) ), 3, + is( scalar( ($x,%h) = (0,1,2,1,3,1,4,1,5) ), 9, 'scalar + hash assignment in scalar context' ); $ar = [ %h = (1,2,1,3,1,4,1,5) ]; is( $#$ar, 1, 'hash assignment in list context' ); |