diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-04-18 06:34:01 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-04-18 06:34:33 -0700 |
commit | d4fc4415aac96132fac5b1e43e73bcba33a41b79 (patch) | |
tree | c87f1b9ea1ffc5720b8bd0a1132a5764f64a17ff /t | |
parent | 87c7b53d0d7cc2f04915964e3d082adce6dac613 (diff) | |
download | perl-d4fc4415aac96132fac5b1e43e73bcba33a41b79.tar.gz |
Make push/shift $scalar accept only unblessed aryrefs
See ticket #80626.
Diffstat (limited to 't')
-rw-r--r-- | t/op/push.t | 13 | ||||
-rw-r--r-- | t/op/splice.t | 6 |
2 files changed, 12 insertions, 7 deletions
diff --git a/t/op/push.t b/t/op/push.t index 2804d5be66..813898e669 100644 --- a/t/op/push.t +++ b/t/op/push.t @@ -14,7 +14,7 @@ -4, 4 5 6 7, 0 1 2 3 EOF -print "1..", 13 + 2*@tests, "\n"; +print "1..", 14 + 2*@tests, "\n"; die "blech" unless @tests; @x = (1,2,3); @@ -44,8 +44,10 @@ if (join(':',@x) eq '1:2:3:1:2:3:4') {print "ok 6\n";} else {print "not ok 6\n"; # test autovivification push @$undef1, 1, 2, 3; if (join(':',@$undef1) eq '1:2:3') {print "ok 7\n";} else {print "not ok 7\n";} -push $undef2, 1, 2, 3; -if (join(':',@$undef2) eq '1:2:3') {print "ok 8\n";} else {print "not ok 8\n";} + +# test push on undef (error) +eval { push $undef2, 1, 2, 3 }; +if ($@ =~ /Not an ARRAY/) {print "ok 8\n";} else {print "not ok 8\n";} # test constant use constant CONST_ARRAYREF => [qw/a b c/]; @@ -60,7 +62,10 @@ $hashref = { }; eval { push $hashref, 0, 1, 2, 3 }; if ( $@ && $@ =~ /Not an ARRAY reference/ ) {print "ok 11\n"} else {print "not ok 11 # \$\@ = $@\n"} -$test = 12; +eval { push bless([]), 0, 1, 2, 3 }; +if ( $@ && $@ =~ /Not an unblessed ARRAY reference/ ) {print "ok 12\n"} else {print "not ok 12 # \$\@ = $@\n"} + +$test = 13; # test context { diff --git a/t/op/splice.t b/t/op/splice.t index 07a3e6723c..bc6fb40272 100644 --- a/t/op/splice.t +++ b/t/op/splice.t @@ -93,7 +93,7 @@ splice @Foo::ISA, 0, 0, 'Bar'; print "not " if !Foo->isa('Bar'); print "ok 20\n"; -# Test vivification -splice( $new_arrayref, 0, 0, 1, 2, 3 ); -print "not " unless j(@$new_arrayref) eq j(1,2,3); +# Test undef first arg +eval { splice( $new_arrayref, 0, 0, 1, 2, 3 ) }; +print "not " unless $@ && $@ =~ /Not an ARRAY/; print "ok 21\n"; |