summaryrefslogtreecommitdiff
path: root/t/op
diff options
context:
space:
mode:
Diffstat (limited to 't/op')
-rw-r--r--t/op/lvref.t78
1 files changed, 78 insertions, 0 deletions
diff --git a/t/op/lvref.t b/t/op/lvref.t
new file mode 100644
index 0000000000..5749ddf2a3
--- /dev/null
+++ b/t/op/lvref.t
@@ -0,0 +1,78 @@
+BEGIN {
+ chdir 't';
+ require './test.pl';
+ set_up_inc("../lib");
+}
+
+plan 13;
+
+$::TODO = ' ';
+
+eval '\$x = \$y';
+like $@, qr/^Experimental lvalue references not enabled/,
+ 'error when feature is disabled';
+
+use feature 'lvalue_refs';
+
+{
+ my($w,$c);
+ local $SIG{__WARN__} = sub { $c++; $w = shift };
+ eval '\$x = \$y';
+ is $c, 1, 'one warning from lv ref assignment';
+ like $w, qr/^Lvalue references are experimental/,
+ 'experimental warning';
+}
+
+no warnings 'experimental::lvalue_refs';
+
+# Scalars
+
+eval '\$x = \$y';
+is \$x, \$y, '\$pkg_scalar = ...';
+my $m;
+eval '\$m = \$y';
+is \$m, \$y, '\$lexical = ...';
+eval '\my $n = \$y';
+is \$n, \$y, '\my $lexical = ...';
+@_ = \$_;
+eval '\($x) = @_';
+is \$x, \$_, '\($pkgvar) = ... gives list context';
+my $o;
+eval '\($o) = @_';
+is \$o, \$_, '\($lexical) = ... gives list cx';
+eval '\(my $p) = @_';
+is \$p, \$_, '\(my $lexical) = ... gives list cx';
+eval '\($_a, my $a) = @{[\$b, \$c]}';
+is \$_a, \$b, 'package scalar in \(...)';
+is \$a, \$c, 'lex scalar in \(...)';
+eval '(\$_b, \my $b) = @{[\$b, \$c]}';
+is \$_b, \$::b, 'package scalar in (\$foo, \$bar)';
+is \$b, \$c, 'lex scalar in (\$foo, \$bar)';
+
+# Array Elements
+
+# ...
+
+# Hash Elements
+
+# ...
+
+# Arrays
+
+# ...
+
+# Hashes
+
+# ...
+
+# Subroutines
+
+# ...
+
+# Mixed List Assignments
+
+# ...
+
+# Errors
+
+# ...