This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Document lvalue ref diagnostics
[perl5.git] / t / op / lvref.t
CommitLineData
72ed4618
FC
1BEGIN {
2 chdir 't';
3 require './test.pl';
4 set_up_inc("../lib");
5}
6
7plan 13;
8
9$::TODO = ' ';
10
11eval '\$x = \$y';
12like $@, qr/^Experimental lvalue references not enabled/,
13 'error when feature is disabled';
14
15use feature 'lvalue_refs';
16
17{
18 my($w,$c);
19 local $SIG{__WARN__} = sub { $c++; $w = shift };
20 eval '\$x = \$y';
21 is $c, 1, 'one warning from lv ref assignment';
22 like $w, qr/^Lvalue references are experimental/,
23 'experimental warning';
24}
25
26no warnings 'experimental::lvalue_refs';
27
28# Scalars
29
30eval '\$x = \$y';
31is \$x, \$y, '\$pkg_scalar = ...';
32my $m;
33eval '\$m = \$y';
34is \$m, \$y, '\$lexical = ...';
35eval '\my $n = \$y';
36is \$n, \$y, '\my $lexical = ...';
37@_ = \$_;
38eval '\($x) = @_';
39is \$x, \$_, '\($pkgvar) = ... gives list context';
40my $o;
41eval '\($o) = @_';
42is \$o, \$_, '\($lexical) = ... gives list cx';
43eval '\(my $p) = @_';
44is \$p, \$_, '\(my $lexical) = ... gives list cx';
45eval '\($_a, my $a) = @{[\$b, \$c]}';
46is \$_a, \$b, 'package scalar in \(...)';
47is \$a, \$c, 'lex scalar in \(...)';
48eval '(\$_b, \my $b) = @{[\$b, \$c]}';
49is \$_b, \$::b, 'package scalar in (\$foo, \$bar)';
50is \$b, \$c, 'lex scalar in (\$foo, \$bar)';
51
52# Array Elements
53
54# ...
55
56# Hash Elements
57
58# ...
59
60# Arrays
61
62# ...
63
64# Hashes
65
66# ...
67
68# Subroutines
69
70# ...
71
72# Mixed List Assignments
73
74# ...
75
76# Errors
77
78# ...