Actually submit previous change.
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / 2use
CommitLineData
4438c4b7 1Check lexical warnings functionality
599cee73 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 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 24########
25
26# Check compile time scope of pragma
4438c4b7 27no warnings;
599cee73 28{
551cd33c 29 use warnings 'syntax' ;
30 my $a =+ 1 ;
599cee73 31}
551cd33c 32my $a =+ 1 ;
599cee73 33EXPECT
551cd33c 34Reversed += operator at - line 6.
599cee73 35########
36
37# Check runtime scope of pragma
4438c4b7 38use warnings 'uninitialized' ;
599cee73 39{
4438c4b7 40 no warnings ;
599cee73 41 my $b ; chop $b ;
42}
43my $b ; chop $b ;
44EXPECT
29489e7c 45Use of uninitialized value $b in scalar chop at - line 8.
599cee73 46########
47
48# Check runtime scope of pragma
4438c4b7 49no warnings ;
599cee73 50{
4438c4b7 51 use warnings 'uninitialized' ;
599cee73 52 my $b ; chop $b ;
53}
54my $b ; chop $b ;
55EXPECT
29489e7c 56Use of uninitialized value $b in scalar chop at - line 6.
599cee73 57########
58
59# Check runtime scope of pragma
4438c4b7 60no warnings ;
599cee73 61{
4438c4b7 62 use warnings 'uninitialized' ;
599cee73 63 $a = sub { my $b ; chop $b ; }
64}
65&$a ;
66EXPECT
29489e7c 67Use of uninitialized value $b in scalar chop at - line 6.
599cee73 68########
69
551cd33c 70use warnings 'syntax' ;
71my $a =+ 1 ;
599cee73 72EXPECT
551cd33c 73Reversed += operator at - line 3.
599cee73 74########
013b78e8 75-w
76no warnings 'reserved' ;
77foo.bar;
78EXPECT
79Useless use of concatenation (.) or string in void context at - line 3.
80########
599cee73 81
82--FILE-- abc
551cd33c 83my $a =+ 1 ;
599cee73 841;
85--FILE--
551cd33c 86use warnings 'syntax' ;
599cee73 87require "./abc";
88EXPECT
89
90########
91
92--FILE-- abc
551cd33c 93use warnings 'syntax' ;
599cee73 941;
95--FILE--
96require "./abc";
551cd33c 97my $a =+ 1 ;
599cee73 98EXPECT
99
100########
101
102--FILE-- abc
551cd33c 103use warnings 'syntax' ;
104my $a =+ 1 ;
599cee73 1051;
106--FILE--
4438c4b7 107use warnings 'uninitialized' ;
599cee73 108require "./abc";
109my $a ; chop $a ;
110EXPECT
551cd33c 111Reversed += operator at ./abc line 2.
29489e7c 112Use of uninitialized value $a in scalar chop at - line 3.
599cee73 113########
114
115--FILE-- abc.pm
551cd33c 116use warnings 'syntax' ;
117my $a =+ 1 ;
599cee73 1181;
119--FILE--
4438c4b7 120use warnings 'uninitialized' ;
599cee73 121use abc;
122my $a ; chop $a ;
123EXPECT
551cd33c 124Reversed += operator at abc.pm line 2.
29489e7c 125Use of uninitialized value $a in scalar chop at - line 3.
599cee73 126########
127
128# Check scope of pragma with eval
16ff4256 129use warnings;
130{
131 no warnings ;
132 eval {
133 my $b ; chop $b ;
134 }; print STDERR $@ ;
599cee73 135 my $b ; chop $b ;
16ff4256 136}
599cee73 137EXPECT
138
139########
140
141# Check scope of pragma with eval
16ff4256 142use warnings;
143{
144 no warnings ;
145 eval {
146 use warnings 'uninitialized' ;
147 my $b ; chop $b ;
148 }; print STDERR $@ ;
599cee73 149 my $b ; chop $b ;
16ff4256 150}
599cee73 151EXPECT
29489e7c 152Use of uninitialized value $b in scalar chop at - line 8.
599cee73 153########
154
155# Check scope of pragma with eval
16ff4256 156no warnings;
157{
158 use warnings 'uninitialized' ;
159 eval {
160 my $b ; chop $b ;
161 }; print STDERR $@ ;
599cee73 162 my $b ; chop $b ;
16ff4256 163}
599cee73 164EXPECT
29489e7c 165Use of uninitialized value $b in scalar chop at - line 7.
166Use of uninitialized value $b in scalar chop at - line 9.
599cee73 167########
168
169# Check scope of pragma with eval
16ff4256 170no warnings;
171{
172 use warnings 'uninitialized' ;
173 eval {
174 no warnings ;
175 my $b ; chop $b ;
176 }; print STDERR $@ ;
599cee73 177 my $b ; chop $b ;
16ff4256 178}
599cee73 179EXPECT
29489e7c 180Use of uninitialized value $b in scalar chop at - line 10.
599cee73 181########
182
183# Check scope of pragma with eval
16ff4256 184use warnings;
185{
186 no warnings ;
187 eval {
551cd33c 188 my $a =+ 1 ;
16ff4256 189 }; print STDERR $@ ;
551cd33c 190 my $a =+ 1 ;
16ff4256 191}
599cee73 192EXPECT
193
194########
195
196# Check scope of pragma with eval
16ff4256 197use warnings;
198{
199 no warnings ;
200 eval {
551cd33c 201 use warnings 'syntax' ;
202 my $a =+ 1 ;
16ff4256 203 }; print STDERR $@ ;
551cd33c 204 my $a =+ 1 ;
16ff4256 205}
599cee73 206EXPECT
551cd33c 207Reversed += operator at - line 8.
599cee73 208########
209
210# Check scope of pragma with eval
16ff4256 211no warnings;
212{
551cd33c 213 use warnings 'syntax' ;
16ff4256 214 eval {
551cd33c 215 my $a =+ 1 ;
16ff4256 216 }; print STDERR $@ ;
551cd33c 217 my $a =+ 1 ;
16ff4256 218}
599cee73 219EXPECT
551cd33c 220Reversed += operator at - line 7.
221Reversed += operator at - line 9.
599cee73 222########
223
224# Check scope of pragma with eval
16ff4256 225no warnings;
226{
551cd33c 227 use warnings 'syntax' ;
16ff4256 228 eval {
229 no warnings ;
551cd33c 230 my $a =+ 1 ;
16ff4256 231 }; print STDERR $@ ;
551cd33c 232 my $a =+ 1 ;
16ff4256 233}
599cee73 234EXPECT
551cd33c 235Reversed += operator at - line 10.
599cee73 236########
237
238# Check scope of pragma with eval
16ff4256 239use warnings;
240{
241 no warnings ;
242 eval '
243 my $b ; chop $b ;
244 '; print STDERR $@ ;
599cee73 245 my $b ; chop $b ;
16ff4256 246}
599cee73 247EXPECT
248
249########
250
251# Check scope of pragma with eval
16ff4256 252use warnings;
253{
254 no warnings ;
255 eval q[
256 use warnings 'uninitialized' ;
257 my $b ; chop $b ;
258 ]; print STDERR $@;
599cee73 259 my $b ; chop $b ;
16ff4256 260}
599cee73 261EXPECT
29489e7c 262Use of uninitialized value $b in scalar chop at (eval 1) line 3.
599cee73 263########
264
265# Check scope of pragma with eval
16ff4256 266no warnings;
267{
268 use warnings 'uninitialized' ;
269 eval '
270 my $b ; chop $b ;
271 '; print STDERR $@ ;
599cee73 272 my $b ; chop $b ;
16ff4256 273}
599cee73 274EXPECT
29489e7c 275Use of uninitialized value $b in scalar chop at (eval 1) line 2.
276Use of uninitialized value $b in scalar chop at - line 9.
599cee73 277########
278
279# Check scope of pragma with eval
16ff4256 280no warnings;
281{
282 use warnings 'uninitialized' ;
283 eval '
284 no warnings ;
285 my $b ; chop $b ;
286 '; print STDERR $@ ;
599cee73 287 my $b ; chop $b ;
16ff4256 288}
599cee73 289EXPECT
29489e7c 290Use of uninitialized value $b in scalar chop at - line 10.
599cee73 291########
292
293# Check scope of pragma with eval
16ff4256 294use warnings;
295{
296 no warnings ;
297 eval '
551cd33c 298 my $a =+ 1 ;
16ff4256 299 '; print STDERR $@ ;
551cd33c 300 my $a =+ 1 ;
16ff4256 301}
599cee73 302EXPECT
303
304########
305
306# Check scope of pragma with eval
16ff4256 307use warnings;
308{
309 no warnings ;
310 eval q[
551cd33c 311 use warnings 'syntax' ;
312 my $a =+ 1 ;
16ff4256 313 ]; print STDERR $@;
551cd33c 314 my $a =+ 1 ;
16ff4256 315}
599cee73 316EXPECT
551cd33c 317Reversed += operator at (eval 1) line 3.
599cee73 318########
319
320# Check scope of pragma with eval
16ff4256 321no warnings;
322{
551cd33c 323 use warnings 'syntax' ;
16ff4256 324 eval '
551cd33c 325 my $a =+ 1 ;
16ff4256 326 '; print STDERR $@;
551cd33c 327 my $a =+ 1 ;
16ff4256 328}
599cee73 329EXPECT
551cd33c 330Reversed += operator at - line 9.
331Reversed += operator at (eval 1) line 2.
599cee73 332########
333
334# Check scope of pragma with eval
16ff4256 335no warnings;
336{
551cd33c 337 use warnings 'syntax' ;
16ff4256 338 eval '
339 no warnings ;
551cd33c 340 my $a =+ 1 ;
16ff4256 341 '; print STDERR $@;
551cd33c 342 my $a =+ 1 ;
16ff4256 343}
599cee73 344EXPECT
551cd33c 345Reversed += operator at - line 10.
4438c4b7 346########
347
348# Check the additive nature of the pragma
551cd33c 349my $a =+ 1 ;
4438c4b7 350my $a ; chop $a ;
551cd33c 351use warnings 'syntax' ;
352$a =+ 1 ;
4438c4b7 353my $b ; chop $b ;
354use warnings 'uninitialized' ;
355my $c ; chop $c ;
551cd33c 356no warnings 'syntax' ;
357$a =+ 1 ;
4438c4b7 358EXPECT
551cd33c 359Reversed += operator at - line 6.
29489e7c 360Use of uninitialized value $c in scalar chop at - line 9.