This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
To-do tests for scalar lvalue refs
authorFather Chrysostomos <sprout@cpan.org>
Sat, 20 Sep 2014 18:46:14 +0000 (11:46 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 11 Oct 2014 04:53:49 +0000 (21:53 -0700)
MANIFEST
t/op/lvref.t [new file with mode: 0644]

index 917f2f9..66ba5df 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -5138,6 +5138,7 @@ t/op/local.t                      See if local works
 t/op/lock.t                    Tests for lock args & retval (no threads)
 t/op/loopctl.t                 See if next/last/redo work
 t/op/lop.t                     See if logical operators work
+t/op/lvref.t                   See if lvalue references work
 t/op/magic-27839.t             Test for #27839, skipped for minitest
 t/op/magic.t                   See if magic variables work
 t/op/method.t                  See if method calls work
diff --git a/t/op/lvref.t b/t/op/lvref.t
new file mode 100644 (file)
index 0000000..5749ddf
--- /dev/null
@@ -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
+
+# ...