summaryrefslogtreecommitdiff
path: root/t/op
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-09-28 00:52:45 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-10-10 21:57:28 -0700
commit3f114923fafe08a32936a624ab87ca92d92a109f (patch)
tree4e4865c8d92747db7e77eceb664ca8e3fe9388ad /t/op
parent87da42eb7eb28ff70ab5b591192bb7cd5253c0bb (diff)
downloadperl-3f114923fafe08a32936a624ab87ca92d92a109f.tar.gz
Simple \@array and \%hash assignment
Parentheses do not work yet. Neither does local.
Diffstat (limited to 't/op')
-rw-r--r--t/op/lvref.t20
1 files changed, 14 insertions, 6 deletions
diff --git a/t/op/lvref.t b/t/op/lvref.t
index 1ac7e23271..0a4b988a99 100644
--- a/t/op/lvref.t
+++ b/t/op/lvref.t
@@ -154,7 +154,6 @@ is \$h{b}, \$_, '\($hash{a})';
# Arrays
-on;
package ArrayTest {
BEGIN { *is = *main::is }
sub expect_scalar_cx { wantarray ? 0 : \@ThatArray }
@@ -163,15 +162,18 @@ package ArrayTest {
eval '\@a = expect_scalar_cx';
is \@a, \@ThatArray, '\@pkg';
my @a;
- eval '\@a = expect_scalar_cx';
+ \@a = expect_scalar_cx;
is \@a, \@ThatArray, '\@lexical';
+::on;
eval '(\@b) = expect_list_cx_a';
is \@b, \@ThatArray, '(\@pkg)';
my @b;
eval '(\@b) = expect_list_cx_a';
is \@b, \@ThatArray, '(\@lexical)';
- eval '\my @c = expect_scalar_cx';
+::off;
+ \my @c = expect_scalar_cx;
is \@c, \@ThatArray, '\my @lexical';
+::on;
eval '(\my @d) = expect_list_cx_a';
is \@d, \@ThatArray, '(\my @lexical)';
eval '\(@e) = expect_list_cx';
@@ -187,22 +189,26 @@ package ArrayTest {
# Hashes
+off;
package HashTest {
BEGIN { *is = *main::is }
sub expect_scalar_cx { wantarray ? 0 : \%ThatHash }
sub expect_list_cx { wantarray ? (\%ThatHash)x2 : 0 }
- eval '\%a = expect_scalar_cx';
+ \%a = expect_scalar_cx;
is \%a, \%ThatHash, '\%pkg';
my %a;
- eval '\%a = expect_scalar_cx';
+ \%a = expect_scalar_cx;
is \%a, \%ThatHash, '\%lexical';
+::on;
eval '(\%b) = expect_list_cx';
is \%b, \%ThatArray, '(\%pkg)';
my %b;
eval '(\%b) = expect_list_cx';
is \%b, \%ThatHash, '(\%lexical)';
- eval '\my %c = expect_scalar_cx';
+::off;
+ \my %c = expect_scalar_cx;
is \%c, \%ThatHash, '\my %lexical';
+::on;
eval '(\my %d) = expect_list_cx';
is \%d, \%ThatHash, '(\my %lexical)';
}
@@ -305,10 +311,12 @@ eval '\my(%b) = 42';
like $@,
qr/^Can't modify reference to parenthesized hash in list assignment a/,
"Can't modify ref to parenthesized hash (\my(%b)) in list assignment";
+off;
eval '\%{"42"} = 42';
like $@,
qr/^Can't modify reference to hash dereference in scalar assignment a/,
"Can't modify reference to hash dereference in scalar assignment";
+on;
# Miscellaneous