This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
No List::Util under miniperl.
[perl5.git] / t / lib / croak / toke
CommitLineData
ca8ffed2 1__END__
b255a112
FC
2# NAME foo found where operator expected
3myfunc 1,2,3
4EXPECT
5Number found where operator expected at - line 1, near "myfunc 1"
6 (Do you need to predeclare myfunc?)
7syntax error at - line 1, near "myfunc 1"
8Execution of - aborted due to compilation errors.
9########
10# NAME foo found where operator expected (after strict error, w/fatal warnings)
11use warnings FATAL => 'all';
12use strict;
13$foo;
14myfunc 1,2,3
15EXPECT
16Global symbol "$foo" requires explicit package name (did you forget to declare "my $foo"?) at - line 3.
17Number found where operator expected at - line 4, near "myfunc 1"
18 (Do you need to predeclare myfunc?)
19syntax error at - line 4, near "myfunc 1"
20Execution of - aborted due to compilation errors.
21########
488bc579
FC
22# NAME (Missing operator before ${?) [perl #123737]
230${
24EXPECT
25Scalar found where operator expected at - line 1, near "0${"
26 (Missing operator before ${?)
27syntax error at - line 1, near "0$"
28Missing right curly or square bracket at - line 1, at end of line
29Execution of - aborted due to compilation errors.
30########
310a0d0a
DM
31# NAME (Missing operator before $#{?) [perl #123737]
320$#{
33EXPECT
34Array length found where operator expected at - line 1, near "0$#{"
35 (Missing operator before $#{?)
36syntax error at - line 1, near "0$#"
37Missing right curly or square bracket at - line 1, at end of line
38Execution of - aborted due to compilation errors.
39########
a7162bf7
TC
40# NAME (Missing opertaor before @foo) [perl #123737]
410@foo
42EXPECT
43Array found where operator expected at - line 1, near "0@foo"
44 (Missing operator before @foo?)
45syntax error at - line 1, near "0@foo
46"
47Execution of - aborted due to compilation errors.
48########
5af08aed
FC
49# NAME Unterminated here-doc in string eval
50eval "<<foo"; die $@
51EXPECT
52Can't find string terminator "foo" anywhere before EOF at (eval 1) line 1.
53########
54# NAME Unterminated here-doc in s/// string eval
55eval "s//<<foo/e"; die $@
56EXPECT
57Can't find string terminator "foo" anywhere before EOF at (eval 1) line 1.
58########
fd2709db
FC
59# NAME Unterminated here-doc in string
60"${<<foo"; # Used to give ‘Attempt to free blah blah blah’
61EXPECT
62Can't find string terminator "foo" anywhere before EOF at - line 1.
63########
20ed5f00
FC
64# NAME Unterminated qw//
65qw/
66EXPECT
67Can't find string terminator "/" anywhere before EOF at - line 1.
68########
69# NAME Unterminated q//
70qw/
71EXPECT
72Can't find string terminator "/" anywhere before EOF at - line 1.
73########
74# NAME Unterminated ''
75'
76EXPECT
77Can't find string terminator "'" anywhere before EOF at - line 1.
78########
4407f1b8
FC
79# NAME /\N{/
80/\N{/
81EXPECT
82Missing right brace on \N{} or unescaped left brace after \N at - line 1, within pattern
ca53e5d5 83Execution of - aborted due to compilation errors.
4407f1b8 84########
e660c409
FC
85# NAME map{for our *a...
86map{for our *a (1..10) {$_.=$x}}
87EXPECT
88Missing $ on loop variable at - line 1.
89########
ca8ffed2 90# NAME Missing name in "my sub"
e7d0b801 91use feature 'lexical_subs'; my sub;
ca8ffed2 92EXPECT
e7d0b801 93The lexical_subs feature is experimental at - line 1.
ca8ffed2 94Missing name in "my sub" at - line 1.
6f2d7fc9 95########
8767b1ab 96# NAME Missing name in "our sub"
e7d0b801 97use feature 'lexical_subs'; our sub;
8767b1ab 98EXPECT
e7d0b801 99The lexical_subs feature is experimental at - line 1.
8767b1ab
FC
100Missing name in "our sub" at - line 1.
101########
102# NAME Missing name in "state sub"
e7d0b801 103use 5.01; use feature 'lexical_subs';
8767b1ab
FC
104state sub;
105EXPECT
64fbf0dd 106The lexical_subs feature is experimental at - line 2.
8767b1ab
FC
107Missing name in "state sub" at - line 2.
108########
a21eb52b
FC
109# NAME my sub pack::foo
110use feature 'lexical_subs', 'state';
111my sub foo::bar;
112state sub foo::bear;
113EXPECT
114The lexical_subs feature is experimental at - line 2.
115The lexical_subs feature is experimental at - line 3.
116"my" subroutine &foo::bar can't be in a package at - line 2, near "my sub foo::bar"
117"state" subroutine &foo::bear can't be in a package at - line 3, near "state sub foo::bear"
118Execution of - aborted due to compilation errors.
119########
b2e3d01a
FC
120# NAME Integer constant overloading returning undef
121use overload;
247a7f40
FC
122BEGIN { overload::constant integer => sub {}; undef *^H }
1231
124EXPECT
bb4784f0 125Constant(1) unknown at - line 3, at end of line
247a7f40
FC
126Execution of - aborted due to compilation errors.
127########
128# NAME Float constant overloading returning undef
129use overload;
130BEGIN { overload::constant float => sub {}; undef *^H }
1311.1
132EXPECT
bb4784f0 133Constant(1.1) unknown at - line 3, at end of line
247a7f40
FC
134Execution of - aborted due to compilation errors.
135########
136# NAME Binary constant overloading returning undef
137use overload;
138BEGIN { overload::constant binary => sub {}; undef *^H }
1390x1
140EXPECT
bb4784f0 141Constant(0x1) unknown at - line 3, at end of line
247a7f40
FC
142Execution of - aborted due to compilation errors.
143########
144# NAME String constant overloading returning undef
145use overload;
146BEGIN { overload::constant q => sub {}; undef *^H }
147'1', "1$_", tr"a"", s""a"
148EXPECT
149Constant(q) unknown at - line 3, near "'1'"
150Constant(qq) unknown at - line 3, within string
151Constant(tr) unknown at - line 3, within string
152Constant(s) unknown at - line 3, within string
153Execution of - aborted due to compilation errors.
154########
155# NAME Regexp constant overloading when *^H is undefined
156use overload;
157BEGIN { overload::constant qr => sub {}; undef *^H }
158/a/, m'a'
159EXPECT
160Constant(qq) unknown at - line 3, within pattern
161Constant(q) unknown at - line 3, within pattern
162Execution of - aborted due to compilation errors.
163########
164# NAME \N{...} when charnames fails to load but without an error
d4ead2eb 165# SKIP ? exists $ENV{PERL_UNICODE} ? "Unreliable under some PERL_UNICODE settings" : 0
247a7f40
FC
166BEGIN { ++$_ for @INC{"charnames.pm","_charnames.pm"} }
167"\N{a}"
168EXPECT
169Constant(\N{a}) unknown at - line 2, within string
170Execution of - aborted due to compilation errors.
171########
172# NAME Integer constant overloading returning undef
173use overload;
b2e3d01a
FC
174BEGIN { overload::constant integer => sub {} }
1751
176EXPECT
bb4784f0 177Constant(1): Call to &{$^H{integer}} did not return a defined value at - line 3, at end of line
b2e3d01a
FC
178Execution of - aborted due to compilation errors.
179########
180# NAME Float constant overloading returning undef
181use overload;
182BEGIN { overload::constant float => sub {} }
1831.1
184EXPECT
bb4784f0 185Constant(1.1): Call to &{$^H{float}} did not return a defined value at - line 3, at end of line
b2e3d01a
FC
186Execution of - aborted due to compilation errors.
187########
188# NAME Binary constant overloading returning undef
189use overload;
190BEGIN { overload::constant binary => sub {} }
1910x1
192EXPECT
bb4784f0 193Constant(0x1): Call to &{$^H{binary}} did not return a defined value at - line 3, at end of line
b2e3d01a
FC
194Execution of - aborted due to compilation errors.
195########
196# NAME String constant overloading returning undef
197use overload;
198BEGIN { overload::constant q => sub {} }
199'1', "1$_", tr"a"", s""a"
200EXPECT
201Constant(q): Call to &{$^H{q}} did not return a defined value at - line 3, near "'1'"
202Constant(qq): Call to &{$^H{q}} did not return a defined value at - line 3, within string
203Constant(tr): Call to &{$^H{q}} did not return a defined value at - line 3, within string
204Constant(s): Call to &{$^H{q}} did not return a defined value at - line 3, within string
205Execution of - aborted due to compilation errors.
206########
207# NAME Regexp constant overloading returning undef
208use overload;
209BEGIN { overload::constant qr => sub {} }
210/a/, m'a'
211EXPECT
212Constant(qq): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
213Constant(q): Call to &{$^H{qr}} did not return a defined value at - line 3, within pattern
214Execution of - aborted due to compilation errors.
215########
67c71cbb
FC
216# NAME Failed constant overloading should not cause a double free
217use overload;
218BEGIN { overload::constant q => sub {}; undef *^H }
219undef(1,2);
220undef(1,2);
221undef(1,2);
222undef(1,2);
223undef(1,2);
224undef(1,2);
225undef(1,2);
226undef(1,2);
227undef(1,2);
228"a"
229EXPECT
230Too many arguments for undef operator at - line 3, near "2)"
231Too many arguments for undef operator at - line 4, near "2)"
232Too many arguments for undef operator at - line 5, near "2)"
233Too many arguments for undef operator at - line 6, near "2)"
234Too many arguments for undef operator at - line 7, near "2)"
235Too many arguments for undef operator at - line 8, near "2)"
236Too many arguments for undef operator at - line 9, near "2)"
237Too many arguments for undef operator at - line 10, near "2)"
238Too many arguments for undef operator at - line 11, near "2)"
239Constant(q) unknown at - line 12, near ""a""
240- has too many errors.
241########
6f2d7fc9
FC
242# NAME Unterminated delimiter for here document
243<<"foo
244EXPECT
245Unterminated delimiter for here document at - line 1.
f3106bc8
LM
246########
247# NAME my (our $x) errors
248my (our $x);
249EXPECT
250Can't redeclare "our" in "my" at - line 1, at end of line
251Execution of - aborted due to compilation errors.
252########
253# NAME our (my $x) errors
254our (my $x);
255EXPECT
256Can't redeclare "my" in "our" at - line 1, at end of line
257Execution of - aborted due to compilation errors.
258########
259# NAME state (my $x) errors
260use feature 'state';
261state (my $x);
262EXPECT
263Can't redeclare "my" in "state" at - line 2, at end of line
264Execution of - aborted due to compilation errors.
265########
266# NAME our (state $x) errors
267use feature 'state';
268our (state $x);
269EXPECT
270Can't redeclare "state" in "our" at - line 2, at end of line
271Execution of - aborted due to compilation errors.
272########
273# NAME my (my $x) errors
274my (my $x, $y, $z);
275EXPECT
276Can't redeclare "my" in "my" at - line 1, at end of line
277Execution of - aborted due to compilation errors.
278########
279# NAME our (our $x) errors
280our ($x, our($y), $z);
281EXPECT
282Can't redeclare "our" in "our" at - line 1, near ", "
283Execution of - aborted due to compilation errors.
284########
285# NAME state (state $x) errors
286use feature 'state';
287state ($x, $y, state $z);
288EXPECT
289Can't redeclare "state" in "state" at - line 2, near ", "
290Execution of - aborted due to compilation errors.
e6b2cf83
TC
291########
292# NAME BEGIN <> [perl #125341]
293BEGIN <>
294EXPECT
295Illegal declaration of subroutine BEGIN at - line 1.