This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
numeric.c:S_mulexp10 -- quit when you can
[perl5.git] / t / lib / warnings / 2use
CommitLineData
4438c4b7 1Check lexical warnings functionality
599cee73
PM
2
3TODO
4 check that the warning hierarchy works.
5
6__END__
7
d3a7d8c7 8# check illegal category is caught
327afb7f 9use warnings 'this-should-never-be-a-warning-category' ;
599cee73 10EXPECT
3d1a39c8 11Unknown warnings category 'this-should-never-be-a-warning-category' at - line 3
d3a7d8c7 12BEGIN failed--compilation aborted at - line 3.
599cee73
PM
13########
14
15# Check compile time scope of pragma
551cd33c 16use warnings 'syntax' ;
599cee73 17{
4438c4b7 18 no warnings ;
551cd33c 19 my $a =+ 1 ;
599cee73 20}
551cd33c 21my $a =+ 1 ;
599cee73 22EXPECT
551cd33c 23Reversed += operator at - line 8.
599cee73
PM
24########
25
26# Check compile time scope of pragma
4438c4b7 27no warnings;
599cee73 28{
551cd33c
JH
29 use warnings 'syntax' ;
30 my $a =+ 1 ;
599cee73 31}
551cd33c 32my $a =+ 1 ;
599cee73 33EXPECT
551cd33c 34Reversed += operator at - line 6.
599cee73
PM
35########
36
37# Check runtime scope of pragma
4438c4b7 38use warnings 'uninitialized' ;
599cee73 39{
4438c4b7 40 no warnings ;
599cee73
PM
41 my $b ; chop $b ;
42}
43my $b ; chop $b ;
44EXPECT
b89fed5f 45Use of uninitialized value in scalar chop at - line 8.
599cee73
PM
46########
47
48# Check runtime scope of pragma
4438c4b7 49no warnings ;
599cee73 50{
4438c4b7 51 use warnings 'uninitialized' ;
599cee73
PM
52 my $b ; chop $b ;
53}
54my $b ; chop $b ;
55EXPECT
b89fed5f 56Use of uninitialized value in scalar chop at - line 6.
599cee73
PM
57########
58
59# Check runtime scope of pragma
4438c4b7 60no warnings ;
599cee73 61{
4438c4b7 62 use warnings 'uninitialized' ;
599cee73
PM
63 $a = sub { my $b ; chop $b ; }
64}
65&$a ;
66EXPECT
b89fed5f 67Use of uninitialized value in scalar chop at - line 6.
599cee73
PM
68########
69
551cd33c
JH
70use warnings 'syntax' ;
71my $a =+ 1 ;
599cee73 72EXPECT
551cd33c 73Reversed += operator at - line 3.
599cee73
PM
74########
75
76--FILE-- abc
551cd33c 77my $a =+ 1 ;
599cee73
PM
781;
79--FILE--
551cd33c 80use warnings 'syntax' ;
599cee73
PM
81require "./abc";
82EXPECT
83
84########
85
86--FILE-- abc
551cd33c 87use warnings 'syntax' ;
599cee73
PM
881;
89--FILE--
90require "./abc";
551cd33c 91my $a =+ 1 ;
599cee73
PM
92EXPECT
93
94########
95
96--FILE-- abc
551cd33c
JH
97use warnings 'syntax' ;
98my $a =+ 1 ;
599cee73
PM
991;
100--FILE--
4438c4b7 101use warnings 'uninitialized' ;
599cee73
PM
102require "./abc";
103my $a ; chop $a ;
104EXPECT
551cd33c 105Reversed += operator at ./abc line 2.
b89fed5f 106Use of uninitialized value in scalar chop at - line 3.
599cee73
PM
107########
108
109--FILE-- abc.pm
551cd33c
JH
110use warnings 'syntax' ;
111my $a =+ 1 ;
599cee73
PM
1121;
113--FILE--
4438c4b7 114use warnings 'uninitialized' ;
599cee73
PM
115use abc;
116my $a ; chop $a ;
117EXPECT
551cd33c 118Reversed += operator at abc.pm line 2.
b89fed5f 119Use of uninitialized value in scalar chop at - line 3.
599cee73
PM
120########
121
122# Check scope of pragma with eval
16ff4256
GS
123use warnings;
124{
125 no warnings ;
126 eval {
127 my $b ; chop $b ;
128 }; print STDERR $@ ;
599cee73 129 my $b ; chop $b ;
16ff4256 130}
599cee73
PM
131EXPECT
132
133########
134
135# Check scope of pragma with eval
16ff4256
GS
136use warnings;
137{
138 no warnings ;
139 eval {
140 use warnings 'uninitialized' ;
141 my $b ; chop $b ;
142 }; print STDERR $@ ;
599cee73 143 my $b ; chop $b ;
16ff4256 144}
599cee73 145EXPECT
16ff4256 146Use of uninitialized value in scalar chop at - line 8.
599cee73
PM
147########
148
149# Check scope of pragma with eval
16ff4256
GS
150no warnings;
151{
152 use warnings 'uninitialized' ;
153 eval {
154 my $b ; chop $b ;
155 }; print STDERR $@ ;
599cee73 156 my $b ; chop $b ;
16ff4256 157}
599cee73 158EXPECT
b89fed5f 159Use of uninitialized value in scalar chop at - line 7.
16ff4256 160Use of uninitialized value in scalar chop at - line 9.
599cee73
PM
161########
162
163# Check scope of pragma with eval
16ff4256
GS
164no warnings;
165{
166 use warnings 'uninitialized' ;
167 eval {
168 no warnings ;
169 my $b ; chop $b ;
170 }; print STDERR $@ ;
599cee73 171 my $b ; chop $b ;
16ff4256 172}
599cee73 173EXPECT
16ff4256 174Use of uninitialized value in scalar chop at - line 10.
599cee73
PM
175########
176
177# Check scope of pragma with eval
16ff4256
GS
178use warnings;
179{
180 no warnings ;
181 eval {
551cd33c 182 my $a =+ 1 ;
16ff4256 183 }; print STDERR $@ ;
551cd33c 184 my $a =+ 1 ;
16ff4256 185}
599cee73
PM
186EXPECT
187
188########
189
190# Check scope of pragma with eval
16ff4256
GS
191use warnings;
192{
193 no warnings ;
194 eval {
551cd33c
JH
195 use warnings 'syntax' ;
196 my $a =+ 1 ;
16ff4256 197 }; print STDERR $@ ;
551cd33c 198 my $a =+ 1 ;
16ff4256 199}
599cee73 200EXPECT
551cd33c 201Reversed += operator at - line 8.
599cee73
PM
202########
203
204# Check scope of pragma with eval
16ff4256
GS
205no warnings;
206{
551cd33c 207 use warnings 'syntax' ;
16ff4256 208 eval {
551cd33c 209 my $a =+ 1 ;
16ff4256 210 }; print STDERR $@ ;
551cd33c 211 my $a =+ 1 ;
16ff4256 212}
599cee73 213EXPECT
551cd33c
JH
214Reversed += operator at - line 7.
215Reversed += operator at - line 9.
599cee73
PM
216########
217
218# Check scope of pragma with eval
16ff4256
GS
219no warnings;
220{
551cd33c 221 use warnings 'syntax' ;
16ff4256
GS
222 eval {
223 no warnings ;
551cd33c 224 my $a =+ 1 ;
16ff4256 225 }; print STDERR $@ ;
551cd33c 226 my $a =+ 1 ;
16ff4256 227}
599cee73 228EXPECT
551cd33c 229Reversed += operator at - line 10.
599cee73
PM
230########
231
232# Check scope of pragma with eval
16ff4256
GS
233use warnings;
234{
235 no warnings ;
236 eval '
237 my $b ; chop $b ;
238 '; print STDERR $@ ;
599cee73 239 my $b ; chop $b ;
16ff4256 240}
599cee73
PM
241EXPECT
242
243########
244
245# Check scope of pragma with eval
16ff4256
GS
246use warnings;
247{
248 no warnings ;
249 eval q[
250 use warnings 'uninitialized' ;
251 my $b ; chop $b ;
252 ]; print STDERR $@;
599cee73 253 my $b ; chop $b ;
16ff4256 254}
599cee73 255EXPECT
b89fed5f 256Use of uninitialized value in scalar chop at (eval 1) line 3.
599cee73
PM
257########
258
259# Check scope of pragma with eval
16ff4256
GS
260no warnings;
261{
262 use warnings 'uninitialized' ;
263 eval '
264 my $b ; chop $b ;
265 '; print STDERR $@ ;
599cee73 266 my $b ; chop $b ;
16ff4256 267}
599cee73 268EXPECT
b89fed5f 269Use of uninitialized value in scalar chop at (eval 1) line 2.
16ff4256 270Use of uninitialized value in scalar chop at - line 9.
599cee73
PM
271########
272
273# Check scope of pragma with eval
16ff4256
GS
274no warnings;
275{
276 use warnings 'uninitialized' ;
277 eval '
278 no warnings ;
279 my $b ; chop $b ;
280 '; print STDERR $@ ;
599cee73 281 my $b ; chop $b ;
16ff4256 282}
599cee73 283EXPECT
16ff4256 284Use of uninitialized value in scalar chop at - line 10.
599cee73
PM
285########
286
287# Check scope of pragma with eval
16ff4256
GS
288use warnings;
289{
290 no warnings ;
291 eval '
551cd33c 292 my $a =+ 1 ;
16ff4256 293 '; print STDERR $@ ;
551cd33c 294 my $a =+ 1 ;
16ff4256 295}
599cee73
PM
296EXPECT
297
298########
299
300# Check scope of pragma with eval
16ff4256
GS
301use warnings;
302{
303 no warnings ;
304 eval q[
551cd33c
JH
305 use warnings 'syntax' ;
306 my $a =+ 1 ;
16ff4256 307 ]; print STDERR $@;
551cd33c 308 my $a =+ 1 ;
16ff4256 309}
599cee73 310EXPECT
551cd33c 311Reversed += operator at (eval 1) line 3.
599cee73
PM
312########
313
314# Check scope of pragma with eval
16ff4256
GS
315no warnings;
316{
551cd33c 317 use warnings 'syntax' ;
16ff4256 318 eval '
551cd33c 319 my $a =+ 1 ;
16ff4256 320 '; print STDERR $@;
551cd33c 321 my $a =+ 1 ;
16ff4256 322}
599cee73 323EXPECT
551cd33c
JH
324Reversed += operator at - line 9.
325Reversed += operator at (eval 1) line 2.
599cee73
PM
326########
327
328# Check scope of pragma with eval
16ff4256
GS
329no warnings;
330{
551cd33c 331 use warnings 'syntax' ;
16ff4256
GS
332 eval '
333 no warnings ;
551cd33c 334 my $a =+ 1 ;
16ff4256 335 '; print STDERR $@;
551cd33c 336 my $a =+ 1 ;
16ff4256 337}
599cee73 338EXPECT
551cd33c 339Reversed += operator at - line 10.
4438c4b7
JH
340########
341
342# Check the additive nature of the pragma
551cd33c 343my $a =+ 1 ;
4438c4b7 344my $a ; chop $a ;
551cd33c
JH
345use warnings 'syntax' ;
346$a =+ 1 ;
4438c4b7
JH
347my $b ; chop $b ;
348use warnings 'uninitialized' ;
349my $c ; chop $c ;
551cd33c
JH
350no warnings 'syntax' ;
351$a =+ 1 ;
4438c4b7 352EXPECT
551cd33c 353Reversed += operator at - line 6.
b89fed5f 354Use of uninitialized value in scalar chop at - line 9.