summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-09-24 13:22:49 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-10-10 21:56:33 -0700
commit26a50d995a0122ec4aec3392722aa70e74fe54f3 (patch)
treea5f3f4a608bf9c774cdd3efcb31c3cdc0e0f5bf3 /t
parente5e1ee61c50f938a3a8b7487d29d5128d4f9a909 (diff)
downloadperl-26a50d995a0122ec4aec3392722aa70e74fe54f3.tar.gz
List assignment to package scalar ref
\ on the lhs returns a special magical scalar with set-magic that does the aliasing. I considered having a separate abind op that would be like aassign, but different. However, I realised that for ($x, \$y) = ... to work it would have to duplicate all of aassign. So I went with the sim- pler magic implementation.
Diffstat (limited to 't')
-rw-r--r--t/op/lvref.t21
1 files changed, 16 insertions, 5 deletions
diff --git a/t/op/lvref.t b/t/op/lvref.t
index 1353c31b94..1fe91bd98e 100644
--- a/t/op/lvref.t
+++ b/t/op/lvref.t
@@ -4,7 +4,7 @@ BEGIN {
set_up_inc("../lib");
}
-plan 34;
+plan 37;
sub on { $::TODO = ' ' }
sub off{ $::TODO = '' }
@@ -12,6 +12,9 @@ sub off{ $::TODO = '' }
eval '\$x = \$y';
like $@, qr/^Experimental lvalue references not enabled/,
'error when feature is disabled';
+eval '\($x) = \$y';
+like $@, qr/^Experimental lvalue references not enabled/,
+ 'error when feature is disabled (aassign)';
use feature 'lvalue_refs';
@@ -22,6 +25,11 @@ use feature 'lvalue_refs';
is $c, 1, 'one warning from lv ref assignment';
like $w, qr/^Lvalue references are experimental/,
'experimental warning';
+ undef $c;
+ eval '\($x) = \$y';
+ is $c, 1, 'one warning from lv ref list assignment';
+ like $w, qr/^Lvalue references are experimental/,
+ 'experimental warning';
}
no warnings 'experimental::lvalue_refs';
@@ -35,16 +43,17 @@ my $m;
is \$m, \$y, '\$lexical = ...';
\my $n = \$y;
is \$n, \$y, '\my $lexical = ...';
-on;
@_ = \$_;
-eval '\($x) = @_';
+\($x) = @_;
is \$x, \$_, '\($pkgvar) = ... gives list context';
undef *x;
-eval '(\$x) = @_';
+(\$x) = @_;
is \$x, \$_, '(\$pkgvar) = ... gives list context';
+on;
my $o;
eval '\($o) = @_';
is \$o, \$_, '\($lexical) = ... gives list cx';
+my $q;
eval '(\$q) = @_';
is \$q, \$_, '(\$lexical) = ... gives list cx';
eval '\(my $p) = @_';
@@ -88,9 +97,11 @@ on;
# Mixed (List) Assignments
-eval '(\$tahi, $rua) = \(1,2)';
+off;
+(\$tahi, $rua) = \(1,2);
is join(' ', $tahi, $$rua), '1 2',
'mixed scalar ref and scalar list assignment';
+on;
$_ = 3;
eval '$_ == 3 ? \$tahi : $rua = \3';
is $tahi, 3, 'cond assignment resolving to scalar ref';