Commit | Line | Data |
---|---|---|
4438c4b7 | 1 | Check lexical warnings functionality |
599cee73 | 2 | |
3 | TODO | |
4 | check that the warning hierarchy works. | |
5 | ||
6 | __END__ | |
7 | ||
d3a7d8c7 | 8 | # check illegal category is caught |
327afb7f | 9 | use warnings 'this-should-never-be-a-warning-category' ; |
599cee73 | 10 | EXPECT |
3d1a39c8 | 11 | Unknown warnings category 'this-should-never-be-a-warning-category' at - line 3 |
d3a7d8c7 | 12 | BEGIN failed--compilation aborted at - line 3. |
599cee73 | 13 | ######## |
14 | ||
15 | # Check compile time scope of pragma | |
551cd33c | 16 | use warnings 'syntax' ; |
599cee73 | 17 | { |
4438c4b7 | 18 | no warnings ; |
551cd33c | 19 | my $a =+ 1 ; |
599cee73 | 20 | } |
551cd33c | 21 | my $a =+ 1 ; |
599cee73 | 22 | EXPECT |
551cd33c | 23 | Reversed += operator at - line 8. |
599cee73 | 24 | ######## |
25 | ||
26 | # Check compile time scope of pragma | |
4438c4b7 | 27 | no warnings; |
599cee73 | 28 | { |
551cd33c | 29 | use warnings 'syntax' ; |
30 | my $a =+ 1 ; | |
599cee73 | 31 | } |
551cd33c | 32 | my $a =+ 1 ; |
599cee73 | 33 | EXPECT |
551cd33c | 34 | Reversed += operator at - line 6. |
599cee73 | 35 | ######## |
36 | ||
37 | # Check runtime scope of pragma | |
4438c4b7 | 38 | use warnings 'uninitialized' ; |
599cee73 | 39 | { |
4438c4b7 | 40 | no warnings ; |
599cee73 | 41 | my $b ; chop $b ; |
42 | } | |
43 | my $b ; chop $b ; | |
44 | EXPECT | |
29489e7c | 45 | Use of uninitialized value $b in scalar chop at - line 8. |
599cee73 | 46 | ######## |
47 | ||
48 | # Check runtime scope of pragma | |
4438c4b7 | 49 | no warnings ; |
599cee73 | 50 | { |
4438c4b7 | 51 | use warnings 'uninitialized' ; |
599cee73 | 52 | my $b ; chop $b ; |
53 | } | |
54 | my $b ; chop $b ; | |
55 | EXPECT | |
29489e7c | 56 | Use of uninitialized value $b in scalar chop at - line 6. |
599cee73 | 57 | ######## |
58 | ||
59 | # Check runtime scope of pragma | |
4438c4b7 | 60 | no warnings ; |
599cee73 | 61 | { |
4438c4b7 | 62 | use warnings 'uninitialized' ; |
599cee73 | 63 | $a = sub { my $b ; chop $b ; } |
64 | } | |
65 | &$a ; | |
66 | EXPECT | |
29489e7c | 67 | Use of uninitialized value $b in scalar chop at - line 6. |
599cee73 | 68 | ######## |
69 | ||
551cd33c | 70 | use warnings 'syntax' ; |
71 | my $a =+ 1 ; | |
599cee73 | 72 | EXPECT |
551cd33c | 73 | Reversed += operator at - line 3. |
599cee73 | 74 | ######## |
013b78e8 | 75 | -w |
76 | no warnings 'reserved' ; | |
77 | foo.bar; | |
78 | EXPECT | |
79 | Useless use of concatenation (.) or string in void context at - line 3. | |
80 | ######## | |
599cee73 | 81 | |
82 | --FILE-- abc | |
551cd33c | 83 | my $a =+ 1 ; |
599cee73 | 84 | 1; |
85 | --FILE-- | |
551cd33c | 86 | use warnings 'syntax' ; |
599cee73 | 87 | require "./abc"; |
88 | EXPECT | |
89 | ||
90 | ######## | |
91 | ||
92 | --FILE-- abc | |
551cd33c | 93 | use warnings 'syntax' ; |
599cee73 | 94 | 1; |
95 | --FILE-- | |
96 | require "./abc"; | |
551cd33c | 97 | my $a =+ 1 ; |
599cee73 | 98 | EXPECT |
99 | ||
100 | ######## | |
101 | ||
102 | --FILE-- abc | |
551cd33c | 103 | use warnings 'syntax' ; |
104 | my $a =+ 1 ; | |
599cee73 | 105 | 1; |
106 | --FILE-- | |
4438c4b7 | 107 | use warnings 'uninitialized' ; |
599cee73 | 108 | require "./abc"; |
109 | my $a ; chop $a ; | |
110 | EXPECT | |
551cd33c | 111 | Reversed += operator at ./abc line 2. |
29489e7c | 112 | Use of uninitialized value $a in scalar chop at - line 3. |
599cee73 | 113 | ######## |
114 | ||
115 | --FILE-- abc.pm | |
551cd33c | 116 | use warnings 'syntax' ; |
117 | my $a =+ 1 ; | |
599cee73 | 118 | 1; |
119 | --FILE-- | |
4438c4b7 | 120 | use warnings 'uninitialized' ; |
599cee73 | 121 | use abc; |
122 | my $a ; chop $a ; | |
123 | EXPECT | |
551cd33c | 124 | Reversed += operator at abc.pm line 2. |
29489e7c | 125 | Use of uninitialized value $a in scalar chop at - line 3. |
599cee73 | 126 | ######## |
127 | ||
128 | # Check scope of pragma with eval | |
16ff4256 | 129 | use warnings; |
130 | { | |
131 | no warnings ; | |
132 | eval { | |
133 | my $b ; chop $b ; | |
134 | }; print STDERR $@ ; | |
599cee73 | 135 | my $b ; chop $b ; |
16ff4256 | 136 | } |
599cee73 | 137 | EXPECT |
138 | ||
139 | ######## | |
140 | ||
141 | # Check scope of pragma with eval | |
16ff4256 | 142 | use 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 | 151 | EXPECT |
29489e7c | 152 | Use of uninitialized value $b in scalar chop at - line 8. |
599cee73 | 153 | ######## |
154 | ||
155 | # Check scope of pragma with eval | |
16ff4256 | 156 | no 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 | 164 | EXPECT |
29489e7c | 165 | Use of uninitialized value $b in scalar chop at - line 7. |
166 | Use of uninitialized value $b in scalar chop at - line 9. | |
599cee73 | 167 | ######## |
168 | ||
169 | # Check scope of pragma with eval | |
16ff4256 | 170 | no 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 | 179 | EXPECT |
29489e7c | 180 | Use of uninitialized value $b in scalar chop at - line 10. |
599cee73 | 181 | ######## |
182 | ||
183 | # Check scope of pragma with eval | |
16ff4256 | 184 | use warnings; |
185 | { | |
186 | no warnings ; | |
187 | eval { | |
551cd33c | 188 | my $a =+ 1 ; |
16ff4256 | 189 | }; print STDERR $@ ; |
551cd33c | 190 | my $a =+ 1 ; |
16ff4256 | 191 | } |
599cee73 | 192 | EXPECT |
193 | ||
194 | ######## | |
195 | ||
196 | # Check scope of pragma with eval | |
16ff4256 | 197 | use 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 | 206 | EXPECT |
551cd33c | 207 | Reversed += operator at - line 8. |
599cee73 | 208 | ######## |
209 | ||
210 | # Check scope of pragma with eval | |
16ff4256 | 211 | no 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 | 219 | EXPECT |
551cd33c | 220 | Reversed += operator at - line 7. |
221 | Reversed += operator at - line 9. | |
599cee73 | 222 | ######## |
223 | ||
224 | # Check scope of pragma with eval | |
16ff4256 | 225 | no 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 | 234 | EXPECT |
551cd33c | 235 | Reversed += operator at - line 10. |
599cee73 | 236 | ######## |
237 | ||
238 | # Check scope of pragma with eval | |
16ff4256 | 239 | use warnings; |
240 | { | |
241 | no warnings ; | |
242 | eval ' | |
243 | my $b ; chop $b ; | |
244 | '; print STDERR $@ ; | |
599cee73 | 245 | my $b ; chop $b ; |
16ff4256 | 246 | } |
599cee73 | 247 | EXPECT |
248 | ||
249 | ######## | |
250 | ||
251 | # Check scope of pragma with eval | |
16ff4256 | 252 | use 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 | 261 | EXPECT |
29489e7c | 262 | Use of uninitialized value $b in scalar chop at (eval 1) line 3. |
599cee73 | 263 | ######## |
264 | ||
265 | # Check scope of pragma with eval | |
16ff4256 | 266 | no 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 | 274 | EXPECT |
29489e7c | 275 | Use of uninitialized value $b in scalar chop at (eval 1) line 2. |
276 | Use of uninitialized value $b in scalar chop at - line 9. | |
599cee73 | 277 | ######## |
278 | ||
279 | # Check scope of pragma with eval | |
16ff4256 | 280 | no 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 | 289 | EXPECT |
29489e7c | 290 | Use of uninitialized value $b in scalar chop at - line 10. |
599cee73 | 291 | ######## |
292 | ||
293 | # Check scope of pragma with eval | |
16ff4256 | 294 | use warnings; |
295 | { | |
296 | no warnings ; | |
297 | eval ' | |
551cd33c | 298 | my $a =+ 1 ; |
16ff4256 | 299 | '; print STDERR $@ ; |
551cd33c | 300 | my $a =+ 1 ; |
16ff4256 | 301 | } |
599cee73 | 302 | EXPECT |
303 | ||
304 | ######## | |
305 | ||
306 | # Check scope of pragma with eval | |
16ff4256 | 307 | use 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 | 316 | EXPECT |
551cd33c | 317 | Reversed += operator at (eval 1) line 3. |
599cee73 | 318 | ######## |
319 | ||
320 | # Check scope of pragma with eval | |
16ff4256 | 321 | no 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 | 329 | EXPECT |
551cd33c | 330 | Reversed += operator at - line 9. |
331 | Reversed += operator at (eval 1) line 2. | |
599cee73 | 332 | ######## |
333 | ||
334 | # Check scope of pragma with eval | |
16ff4256 | 335 | no 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 | 344 | EXPECT |
551cd33c | 345 | Reversed += operator at - line 10. |
4438c4b7 | 346 | ######## |
347 | ||
348 | # Check the additive nature of the pragma | |
551cd33c | 349 | my $a =+ 1 ; |
4438c4b7 | 350 | my $a ; chop $a ; |
551cd33c | 351 | use warnings 'syntax' ; |
352 | $a =+ 1 ; | |
4438c4b7 | 353 | my $b ; chop $b ; |
354 | use warnings 'uninitialized' ; | |
355 | my $c ; chop $c ; | |
551cd33c | 356 | no warnings 'syntax' ; |
357 | $a =+ 1 ; | |
4438c4b7 | 358 | EXPECT |
551cd33c | 359 | Reversed += operator at - line 6. |
29489e7c | 360 | Use of uninitialized value $c in scalar chop at - line 9. |