This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlapi: Fix grammar
[perl5.git] / t / lib / warnings / pp_ctl
CommitLineData
599cee73
PM
1 pp_ctl.c AOK
2
3 Not enough format arguments
4 format STDOUT =
5 @<<< @<<<
6 $a
7 .
8 write;
9
10
11 Exiting substitution via %s
12 $_ = "abc" ;
13 while ($i ++ == 0)
14 {
15 s/ab/last/e ;
16 }
17
18 Exiting subroutine via %s
19 sub fred { last }
20 { fred() }
21
22 Exiting eval via %s
23 { eval "last" }
24
25 Exiting pseudo-block via %s
26 @a = (1,2) ; @b = sort { last } @a ;
27
28 Exiting substitution via %s
29 $_ = "abc" ;
30 last fred:
31 while ($i ++ == 0)
32 {
33 s/ab/last fred/e ;
34 }
35
36
37 Exiting subroutine via %s
38 sub fred { last joe }
39 joe: { fred() }
40
41 Exiting eval via %s
42 fred: { eval "last fred" }
43
44 Exiting pseudo-block via %s
45 @a = (1,2) ; fred: @b = sort { last fred } @a ;
46
47
48 Deep recursion on subroutine \"%s\"
49 sub fred
50 {
cd06dffe 51 fred() if $a++ < 200
599cee73
PM
52 }
53
cd06dffe 54 fred()
599cee73 55
a99e4ac2
GS
56 (in cleanup) foo bar
57 package Foo;
58 DESTROY { die "foo bar" }
59 { bless [], 'Foo' for 1..10 }
599cee73
PM
60
61__END__
62# pp_ctl.c
4438c4b7 63use warnings 'syntax' ;
599cee73
PM
64format STDOUT =
65@<<< @<<<
661
67.
68write;
69EXPECT
70Not enough format arguments at - line 5.
711
72########
73# pp_ctl.c
4438c4b7 74no warnings 'syntax' ;
0453d815
PM
75format =
76@<<< @<<<
771
78.
79write ;
80EXPECT
811
82########
83# pp_ctl.c
e476b1b5 84use warnings 'exiting' ;
599cee73
PM
85$_ = "abc" ;
86
87while ($i ++ == 0)
88{
89 s/ab/last/e ;
90}
e476b1b5 91no warnings 'exiting' ;
0453d815
PM
92while ($i ++ == 0)
93{
94 s/ab/last/e ;
95}
599cee73
PM
96EXPECT
97Exiting substitution via last at - line 7.
98########
99# pp_ctl.c
e476b1b5 100use warnings 'exiting' ;
599cee73
PM
101sub fred { last }
102{ fred() }
e476b1b5 103no warnings 'exiting' ;
0453d815
PM
104sub joe { last }
105{ joe() }
599cee73
PM
106EXPECT
107Exiting subroutine via last at - line 3.
108########
109# pp_ctl.c
0453d815 110{
e476b1b5 111 eval "use warnings 'exiting' ; last;"
0453d815
PM
112}
113print STDERR $@ ;
114{
e476b1b5 115 eval "no warnings 'exiting' ;last;"
0453d815 116}
599cee73
PM
117print STDERR $@ ;
118EXPECT
119Exiting eval via last at (eval 1) line 1.
120########
121# pp_ctl.c
e476b1b5 122use warnings 'exiting' ;
599cee73
PM
123@a = (1,2) ;
124@b = sort { last } @a ;
e476b1b5 125no warnings 'exiting' ;
0453d815 126@b = sort { last } @a ;
599cee73
PM
127EXPECT
128Exiting pseudo-block via last at - line 4.
a651a37d 129Can't "last" outside a loop block at - line 4.
599cee73
PM
130########
131# pp_ctl.c
e476b1b5 132use warnings 'exiting' ;
599cee73
PM
133$_ = "abc" ;
134fred:
135while ($i ++ == 0)
136{
137 s/ab/last fred/e ;
138}
e476b1b5 139no warnings 'exiting' ;
0453d815
PM
140while ($i ++ == 0)
141{
142 s/ab/last fred/e ;
143}
599cee73
PM
144EXPECT
145Exiting substitution via last at - line 7.
146########
147# pp_ctl.c
e476b1b5 148use warnings 'exiting' ;
599cee73
PM
149sub fred { last joe }
150joe: { fred() }
e476b1b5 151no warnings 'exiting' ;
0453d815
PM
152sub Fred { last Joe }
153Joe: { Fred() }
599cee73
PM
154EXPECT
155Exiting subroutine via last at - line 3.
156########
157# pp_ctl.c
0453d815 158joe:
e476b1b5 159{ eval "use warnings 'exiting' ; last joe;" }
0453d815
PM
160print STDERR $@ ;
161Joe:
e476b1b5 162{ eval "no warnings 'exiting' ; last Joe;" }
599cee73
PM
163print STDERR $@ ;
164EXPECT
60e6418e 165Exiting eval via last at (eval 1) line 1.
599cee73
PM
166########
167# pp_ctl.c
e476b1b5 168use warnings 'exiting' ;
599cee73
PM
169@a = (1,2) ;
170fred: @b = sort { last fred } @a ;
e476b1b5 171no warnings 'exiting' ;
0453d815 172Fred: @b = sort { last Fred } @a ;
599cee73
PM
173EXPECT
174Exiting pseudo-block via last at - line 4.
175Label not found for "last fred" at - line 4.
176########
177# pp_ctl.c
4438c4b7 178use warnings 'recursion' ;
599cee73
PM
179BEGIN { warn "PREFIX\n" ;}
180sub fred
181{
cd06dffe 182 fred() if $a++ < 200
599cee73
PM
183}
184
cd06dffe 185fred()
599cee73
PM
186EXPECT
187Deep recursion on subroutine "main::fred" at - line 6.
a99e4ac2
GS
188########
189# pp_ctl.c
4438c4b7 190no warnings 'recursion' ;
0453d815
PM
191BEGIN { warn "PREFIX\n" ;}
192sub fred
193{
cd06dffe 194 fred() if $a++ < 200
0453d815
PM
195}
196
cd06dffe 197fred()
0453d815 198EXPECT
0453d815
PM
199########
200# pp_ctl.c
e476b1b5 201use warnings 'misc' ;
a99e4ac2
GS
202package Foo;
203DESTROY { die "@{$_[0]} foo bar" }
204{ bless ['A'], 'Foo' for 1..10 }
b5d92ff4 205{ bless ['B'], 'Foo' for 1..10 }
a99e4ac2
GS
206EXPECT
207 (in cleanup) A foo bar at - line 4.
7ce09284
Z
208 (in cleanup) A foo bar at - line 4.
209 (in cleanup) A foo bar at - line 4.
210 (in cleanup) A foo bar at - line 4.
211 (in cleanup) A foo bar at - line 4.
212 (in cleanup) A foo bar at - line 4.
213 (in cleanup) A foo bar at - line 4.
214 (in cleanup) A foo bar at - line 4.
215 (in cleanup) A foo bar at - line 4.
216 (in cleanup) A foo bar at - line 4.
217 (in cleanup) B foo bar at - line 4.
218 (in cleanup) B foo bar at - line 4.
219 (in cleanup) B foo bar at - line 4.
220 (in cleanup) B foo bar at - line 4.
221 (in cleanup) B foo bar at - line 4.
222 (in cleanup) B foo bar at - line 4.
223 (in cleanup) B foo bar at - line 4.
224 (in cleanup) B foo bar at - line 4.
225 (in cleanup) B foo bar at - line 4.
b5d92ff4 226 (in cleanup) B foo bar at - line 4.
0453d815
PM
227########
228# pp_ctl.c
e476b1b5 229no warnings 'misc' ;
0453d815
PM
230package Foo;
231DESTROY { die "@{$_[0]} foo bar" }
232{ bless ['A'], 'Foo' for 1..10 }
233{ bless ['B'], 'Foo' for 1..10 }
234EXPECT
f0a6fc86
GS
235########
236# pp_ctl.c
237use warnings;
238eval 'print $foo';
239EXPECT
29489e7c 240Use of uninitialized value $foo in print at (eval 1) line 1.
f0a6fc86
GS
241########
242# pp_ctl.c
243use warnings;
244{
245 no warnings;
246 eval 'print $foo';
247}
248EXPECT
fbc891ce
RB
249########
250# pp_ctl.c
251use warnings;
252eval 'use 5.006; use 5.10.0';
253EXPECT