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 | |
b89fed5f | 45 | Use of uninitialized value 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 | |
b89fed5f | 56 | Use of uninitialized value 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 | |
b89fed5f | 67 | Use of uninitialized value 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 | ######## |
75 | ||
76 | --FILE-- abc | |
551cd33c | 77 | my $a =+ 1 ; |
599cee73 | 78 | 1; |
79 | --FILE-- | |
551cd33c | 80 | use warnings 'syntax' ; |
599cee73 | 81 | require "./abc"; |
82 | EXPECT | |
83 | ||
84 | ######## | |
85 | ||
86 | --FILE-- abc | |
551cd33c | 87 | use warnings 'syntax' ; |
599cee73 | 88 | 1; |
89 | --FILE-- | |
90 | require "./abc"; | |
551cd33c | 91 | my $a =+ 1 ; |
599cee73 | 92 | EXPECT |
93 | ||
94 | ######## | |
95 | ||
96 | --FILE-- abc | |
551cd33c | 97 | use warnings 'syntax' ; |
98 | my $a =+ 1 ; | |
599cee73 | 99 | 1; |
100 | --FILE-- | |
4438c4b7 | 101 | use warnings 'uninitialized' ; |
599cee73 | 102 | require "./abc"; |
103 | my $a ; chop $a ; | |
104 | EXPECT | |
551cd33c | 105 | Reversed += operator at ./abc line 2. |
b89fed5f | 106 | Use of uninitialized value in scalar chop at - line 3. |
599cee73 | 107 | ######## |
108 | ||
109 | --FILE-- abc.pm | |
551cd33c | 110 | use warnings 'syntax' ; |
111 | my $a =+ 1 ; | |
599cee73 | 112 | 1; |
113 | --FILE-- | |
4438c4b7 | 114 | use warnings 'uninitialized' ; |
599cee73 | 115 | use abc; |
116 | my $a ; chop $a ; | |
117 | EXPECT | |
551cd33c | 118 | Reversed += operator at abc.pm line 2. |
b89fed5f | 119 | Use of uninitialized value in scalar chop at - line 3. |
599cee73 | 120 | ######## |
121 | ||
122 | # Check scope of pragma with eval | |
16ff4256 | 123 | use warnings; |
124 | { | |
125 | no warnings ; | |
126 | eval { | |
127 | my $b ; chop $b ; | |
128 | }; print STDERR $@ ; | |
599cee73 | 129 | my $b ; chop $b ; |
16ff4256 | 130 | } |
599cee73 | 131 | EXPECT |
132 | ||
133 | ######## | |
134 | ||
135 | # Check scope of pragma with eval | |
16ff4256 | 136 | use 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 | 145 | EXPECT |
16ff4256 | 146 | Use of uninitialized value in scalar chop at - line 8. |
599cee73 | 147 | ######## |
148 | ||
149 | # Check scope of pragma with eval | |
16ff4256 | 150 | no 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 | 158 | EXPECT |
b89fed5f | 159 | Use of uninitialized value in scalar chop at - line 7. |
16ff4256 | 160 | Use of uninitialized value in scalar chop at - line 9. |
599cee73 | 161 | ######## |
162 | ||
163 | # Check scope of pragma with eval | |
16ff4256 | 164 | no 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 | 173 | EXPECT |
16ff4256 | 174 | Use of uninitialized value in scalar chop at - line 10. |
599cee73 | 175 | ######## |
176 | ||
177 | # Check scope of pragma with eval | |
16ff4256 | 178 | use warnings; |
179 | { | |
180 | no warnings ; | |
181 | eval { | |
551cd33c | 182 | my $a =+ 1 ; |
16ff4256 | 183 | }; print STDERR $@ ; |
551cd33c | 184 | my $a =+ 1 ; |
16ff4256 | 185 | } |
599cee73 | 186 | EXPECT |
187 | ||
188 | ######## | |
189 | ||
190 | # Check scope of pragma with eval | |
16ff4256 | 191 | use warnings; |
192 | { | |
193 | no warnings ; | |
194 | eval { | |
551cd33c | 195 | use warnings 'syntax' ; |
196 | my $a =+ 1 ; | |
16ff4256 | 197 | }; print STDERR $@ ; |
551cd33c | 198 | my $a =+ 1 ; |
16ff4256 | 199 | } |
599cee73 | 200 | EXPECT |
551cd33c | 201 | Reversed += operator at - line 8. |
599cee73 | 202 | ######## |
203 | ||
204 | # Check scope of pragma with eval | |
16ff4256 | 205 | no 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 | 213 | EXPECT |
551cd33c | 214 | Reversed += operator at - line 7. |
215 | Reversed += operator at - line 9. | |
599cee73 | 216 | ######## |
217 | ||
218 | # Check scope of pragma with eval | |
16ff4256 | 219 | no warnings; |
220 | { | |
551cd33c | 221 | use warnings 'syntax' ; |
16ff4256 | 222 | eval { |
223 | no warnings ; | |
551cd33c | 224 | my $a =+ 1 ; |
16ff4256 | 225 | }; print STDERR $@ ; |
551cd33c | 226 | my $a =+ 1 ; |
16ff4256 | 227 | } |
599cee73 | 228 | EXPECT |
551cd33c | 229 | Reversed += operator at - line 10. |
599cee73 | 230 | ######## |
231 | ||
232 | # Check scope of pragma with eval | |
16ff4256 | 233 | use warnings; |
234 | { | |
235 | no warnings ; | |
236 | eval ' | |
237 | my $b ; chop $b ; | |
238 | '; print STDERR $@ ; | |
599cee73 | 239 | my $b ; chop $b ; |
16ff4256 | 240 | } |
599cee73 | 241 | EXPECT |
242 | ||
243 | ######## | |
244 | ||
245 | # Check scope of pragma with eval | |
16ff4256 | 246 | use 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 | 255 | EXPECT |
b89fed5f | 256 | Use of uninitialized value in scalar chop at (eval 1) line 3. |
599cee73 | 257 | ######## |
258 | ||
259 | # Check scope of pragma with eval | |
16ff4256 | 260 | no 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 | 268 | EXPECT |
b89fed5f | 269 | Use of uninitialized value in scalar chop at (eval 1) line 2. |
16ff4256 | 270 | Use of uninitialized value in scalar chop at - line 9. |
599cee73 | 271 | ######## |
272 | ||
273 | # Check scope of pragma with eval | |
16ff4256 | 274 | no 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 | 283 | EXPECT |
16ff4256 | 284 | Use of uninitialized value in scalar chop at - line 10. |
599cee73 | 285 | ######## |
286 | ||
287 | # Check scope of pragma with eval | |
16ff4256 | 288 | use warnings; |
289 | { | |
290 | no warnings ; | |
291 | eval ' | |
551cd33c | 292 | my $a =+ 1 ; |
16ff4256 | 293 | '; print STDERR $@ ; |
551cd33c | 294 | my $a =+ 1 ; |
16ff4256 | 295 | } |
599cee73 | 296 | EXPECT |
297 | ||
298 | ######## | |
299 | ||
300 | # Check scope of pragma with eval | |
16ff4256 | 301 | use warnings; |
302 | { | |
303 | no warnings ; | |
304 | eval q[ | |
551cd33c | 305 | use warnings 'syntax' ; |
306 | my $a =+ 1 ; | |
16ff4256 | 307 | ]; print STDERR $@; |
551cd33c | 308 | my $a =+ 1 ; |
16ff4256 | 309 | } |
599cee73 | 310 | EXPECT |
551cd33c | 311 | Reversed += operator at (eval 1) line 3. |
599cee73 | 312 | ######## |
313 | ||
314 | # Check scope of pragma with eval | |
16ff4256 | 315 | no 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 | 323 | EXPECT |
551cd33c | 324 | Reversed += operator at - line 9. |
325 | Reversed += operator at (eval 1) line 2. | |
599cee73 | 326 | ######## |
327 | ||
328 | # Check scope of pragma with eval | |
16ff4256 | 329 | no warnings; |
330 | { | |
551cd33c | 331 | use warnings 'syntax' ; |
16ff4256 | 332 | eval ' |
333 | no warnings ; | |
551cd33c | 334 | my $a =+ 1 ; |
16ff4256 | 335 | '; print STDERR $@; |
551cd33c | 336 | my $a =+ 1 ; |
16ff4256 | 337 | } |
599cee73 | 338 | EXPECT |
551cd33c | 339 | Reversed += operator at - line 10. |
4438c4b7 | 340 | ######## |
341 | ||
342 | # Check the additive nature of the pragma | |
551cd33c | 343 | my $a =+ 1 ; |
4438c4b7 | 344 | my $a ; chop $a ; |
551cd33c | 345 | use warnings 'syntax' ; |
346 | $a =+ 1 ; | |
4438c4b7 | 347 | my $b ; chop $b ; |
348 | use warnings 'uninitialized' ; | |
349 | my $c ; chop $c ; | |
551cd33c | 350 | no warnings 'syntax' ; |
351 | $a =+ 1 ; | |
4438c4b7 | 352 | EXPECT |
551cd33c | 353 | Reversed += operator at - line 6. |
b89fed5f | 354 | Use of uninitialized value in scalar chop at - line 9. |