This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Another op description correction: & -> &.
[perl5.git] / t / lib / croak / op
CommitLineData
7a44ba35 1__END__
a4545448
FC
2# NAME join,
3join,
4EXPECT
5Not enough arguments for join or string at - line 1, near "join,"
6Execution of - aborted due to compilation errors.
7########
b14845b4
FC
8# NAME my $<special>
9my $!;
10EXPECT
11Can't use global $! in "my" at - line 1, near "my $!"
12Execution of - aborted due to compilation errors.
13########
ec7e59fb
KW
14# NAME my $<non-ASCII> doesn't output garbage
15# \xB6 is same character in all three EBCDIC pages and Latin1
f6a1dc93 16use open ":std", ":utf8";
ec7e59fb 17eval qq|my \$\xb6;|; # ¶ in Latin-1, and EBCDIC 1047, 037, POSIX-BC
f6a1dc93
FC
18print $@;
19exit 1;
20EXPECT
ec7e59fb 21Can't use global $¶ in "my" at (eval 1) line 1, near "my $¶"
f6a1dc93 22########
7a44ba35
TC
23# NAME OP_HELEM fields
24package Foo;
25use fields qw(a b);
26sub new {
27 my $class = shift;
28 return fields::new($class);
29}
30my Foo $f = Foo->new;
31$f->{c} = 1;
32EXPECT
33No such class field "c" in variable $f of type Foo at - line 8.
34########
e6307ed0
FC
35# NAME "No such field" with block: ${$ref}{key}
36%FIELDS; # empty hash so all keys are invalid
37my main $r;
38${$r}{key};
39EXPECT
40No such class field "key" in variable $r of type main at - line 3.
41########
7a44ba35
TC
42# NAME OP_HSLICE fields
43package Foo;
44use fields qw(a b);
45sub new {
46 my $class = shift;
47 return fields::new($class);
48}
49my Foo $f = Foo->new;
50@$f{"a", "c"} = ( 1, 2 );
51EXPECT
52No such class field "c" in variable $f of type Foo at - line 8.
53########
0e706dd4
FC
54# NAME Single OP_HSLICE field
55%FIELDS; # vivify it, but leave it empty, so all fields are invalid
56my main $f;
57@$f{"a"};
58EXPECT
59No such class field "a" in variable $f of type main at - line 3.
60########
c5f75dba
FC
61# NAME OP_KVHSLICE fields
62BEGIN { %FIELDS = qw(a 1 b 1); }
63my main $f;
64%$f{"a","c"};
65EXPECT
66No such class field "c" in variable $f of type main at - line 3.
67########
4748e002
FC
68# NAME Can't declare conditional
69my($a?$b:$c)
70EXPECT
71Can't declare conditional expression in "my" at - line 1, at EOF
72Execution of - aborted due to compilation errors.
73########
74# NAME Can't declare do block
75my(do{})
76EXPECT
77Can't declare do block in "my" at - line 1, at EOF
78Execution of - aborted due to compilation errors.
79########
f0614d30
FC
80# NAME ($_, state $x) = ...
81($_, CORE::state $x) = ();
82EXPECT
83Initialization of state variables in list context currently forbidden at - line 1, near ");"
84Execution of - aborted due to compilation errors.
85########
86# NAME my $y; ($y, state $x) = ...
87my $y; ($y, CORE::state $x) = ();
88EXPECT
89Initialization of state variables in list context currently forbidden at - line 1, near ");"
90Execution of - aborted due to compilation errors.
91########
7a44ba35
TC
92# NAME delete BAD
93delete $x;
94EXPECT
95delete argument is not a HASH or ARRAY element or slice at - line 1.
96########
2186f873
FC
97# NAME delete sort
98use warnings;
99delete sort; # used to warn about scalar context, too
100EXPECT
101delete argument is not a HASH or ARRAY element or slice at - line 2.
102########
7a44ba35
TC
103# NAME exists BAD
104exists $x;
105EXPECT
106exists argument is not a HASH or ARRAY element or a subroutine at - line 1.
107########
108# NAME exists non-sub
109exists &foo()
110EXPECT
111exists argument is not a subroutine name at - line 1.
b5adc3e5
DIM
112########
113# NAME push BAREWORD
b5adc3e5
DIM
114push FRED;
115EXPECT
26230909 116Type of arg 1 to push must be array (not constant item) at - line 1, near "FRED;"
b5adc3e5
DIM
117Execution of - aborted due to compilation errors.
118########
119# NAME pop BAREWORD
b5adc3e5
DIM
120pop FRED;
121EXPECT
26230909 122Type of arg 1 to pop must be array (not constant item) at - line 1, near "FRED;"
b5adc3e5
DIM
123Execution of - aborted due to compilation errors.
124########
125# NAME shift BAREWORD
b5adc3e5
DIM
126shift FRED;
127EXPECT
26230909 128Type of arg 1 to shift must be array (not constant item) at - line 1, near "FRED;"
b5adc3e5
DIM
129Execution of - aborted due to compilation errors.
130########
131# NAME unshift BAREWORD
b5adc3e5
DIM
132unshift FRED;
133EXPECT
26230909 134Type of arg 1 to unshift must be array (not constant item) at - line 1, near "FRED;"
b5adc3e5
DIM
135Execution of - aborted due to compilation errors.
136########
137# NAME keys BAREWORD
138@a = keys FRED ;
139EXPECT
69e7f50e 140Type of arg 1 to keys must be hash or array (not constant item) at - line 1, near "FRED ;"
b5adc3e5
DIM
141Execution of - aborted due to compilation errors.
142########
143# NAME values BAREWORD
144@a = values FRED ;
145EXPECT
69e7f50e 146Type of arg 1 to values must be hash or array (not constant item) at - line 1, near "FRED ;"
b5adc3e5
DIM
147Execution of - aborted due to compilation errors.
148########
149# NAME each BAREWORD
150@a = each FRED ;
151EXPECT
69e7f50e 152Type of arg 1 to each must be hash or array (not constant item) at - line 1, near "FRED ;"
b5adc3e5 153Execution of - aborted due to compilation errors.