summaryrefslogtreecommitdiff
path: root/t/op/lvref.t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-10-01 18:15:16 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-10-11 00:10:14 -0700
commitbd9bf01b39e0fd9ebc41a7c457ab6b8a8ebc6731 (patch)
tree439e425a33812d52e834b082af4f540b55e71c76 /t/op/lvref.t
parent69b0bd0766d3c36397346c4d4697c98191c11736 (diff)
downloadperl-bd9bf01b39e0fd9ebc41a7c457ab6b8a8ebc6731.tar.gz
lvref.t: Repeat bad ref tests with list assignment
List assignment goes through a different code path. The errors come from magic_setlvref in that case, not pp_refassign.
Diffstat (limited to 't/op/lvref.t')
-rw-r--r--t/op/lvref.t24
1 files changed, 23 insertions, 1 deletions
diff --git a/t/op/lvref.t b/t/op/lvref.t
index 2cd863b221..50268a594a 100644
--- a/t/op/lvref.t
+++ b/t/op/lvref.t
@@ -4,7 +4,7 @@ BEGIN {
set_up_inc("../lib");
}
-plan 104;
+plan 111;
sub on { $::TODO = ' ' }
sub off{ $::TODO = '' }
@@ -311,6 +311,28 @@ eval { \%::x = [] };
like $@, qr/^Assigned value is not a HASH reference at/,
'assigning non-hash ref to package hash ref';
+eval { my $x; (\$x) = 3 };
+like $@, qr/^Assigned value is not a reference at/,
+ 'list-assigning non-ref';
+eval { my $x; (\$x) = [] };
+like $@, qr/^Assigned value is not a SCALAR reference at/,
+ 'list-assigning non-scalar ref to scalar ref';
+eval { (\$::x = []) };
+like $@, qr/^Assigned value is not a SCALAR reference at/,
+ 'list-assigning non-scalar ref to package scalar ref';
+eval { my @x; (\@x) = {} };
+like $@, qr/^Assigned value is not an ARRAY reference at/,
+ 'list-assigning non-array ref to array ref';
+eval { (\@::x) = {} };
+like $@, qr/^Assigned value is not an ARRAY reference at/,
+ 'list-assigning non-array ref to package array ref';
+eval { my %x; (\%x) = [] };
+like $@, qr/^Assigned value is not a HASH reference at/,
+ 'list-assigning non-hash ref to hash ref';
+eval { (\%::x) = [] };
+like $@, qr/^Assigned value is not a HASH reference at/,
+ 'list-assigning non-hash ref to package hash ref';
+
eval '(\do{}) = 42';
like $@, qr/^Can't modify reference to do block in list assignment at /,
"Can't modify reference to do block in list assignment";