diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-09-26 10:40:19 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-10-10 21:57:13 -0700 |
commit | 0ca7b7f7720bb25ab1fc20faded8002d21b67c88 (patch) | |
tree | d0a269978fdee44de47fc148ede6c41d15f78105 /t/op | |
parent | 1199b01a19ac3b55dfe962f42e76278451b91b13 (diff) | |
download | perl-0ca7b7f7720bb25ab1fc20faded8002d21b67c88.tar.gz |
\@array[@slice] assignment
plus changes to the aelem tests to check rhs context.
I did \local @a[@s] at the same time, since I was practically copying
and pasting code from aslice (ok, not quite).
Diffstat (limited to 't/op')
-rw-r--r-- | t/op/lvref.t | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/t/op/lvref.t b/t/op/lvref.t index f9aff2a711..4c7c24cb1f 100644 --- a/t/op/lvref.t +++ b/t/op/lvref.t @@ -4,7 +4,7 @@ BEGIN { set_up_inc("../lib"); } -plan 48; +plan 52; sub on { $::TODO = ' ' } sub off{ $::TODO = '' } @@ -76,17 +76,32 @@ is *foo{SCALAR}, *bar{GLOB}, 'globref-to-scalarref assignment'; # Array Elements -\$a[0] = \$_; +sub expect_scalar_cx { wantarray ? 0 : \$_ } +sub expect_list_cx { wantarray ? (\$_,\$_) : 0 } +\$a[0] = expect_scalar_cx; is \$a[0], \$_, '\$array[0]'; -\($a[1]) = \$_; +\($a[1]) = expect_list_cx; is \$a[1], \$_, '\($array[0])'; { my @a; - \$a[0] = \$_; + \$a[0] = expect_scalar_cx; is \$a[0], \$_, '\$lexical_array[0]'; - \($a[1]) = \$_; + \($a[1]) = expect_list_cx; is \$a[1], \$_, '\($lexical_array[0])'; } +{ + my @a; + \@a[0,1] = expect_list_cx; + is \$a[0].\$a[1], \$_.\$_, '\@array[indices]'; + \(@a[2,3]) = expect_list_cx; + is \$a[0].\$a[1], \$_.\$_, '\(@array[indices])'; + my $tmp; + { + \local @a[0,1] = (\$tmp)x2; + is \$a[0].\$a[1], \$tmp.\$tmp, '\local @a[indices]'; + } + is \$a[0].\$a[1], \$_.\$_, '\local @a[indices] unwound'; +} # Hash Elements |