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 |
d3a7d8c7 | 11 | unknown warnings category 'this-should-never-be-a-warning-category' at - line 3 |
12 | BEGIN failed--compilation aborted at - line 3. | |
599cee73 | 13 | ######## |
14 | ||
15 | # Check compile time scope of pragma | |
4438c4b7 | 16 | use warnings 'deprecated' ; |
599cee73 | 17 | { |
4438c4b7 | 18 | no warnings ; |
599cee73 | 19 | 1 if $a EQ $b ; |
20 | } | |
21 | 1 if $a EQ $b ; | |
22 | EXPECT | |
23 | Use of EQ is deprecated at - line 8. | |
24 | ######## | |
25 | ||
26 | # Check compile time scope of pragma | |
4438c4b7 | 27 | no warnings; |
599cee73 | 28 | { |
4438c4b7 | 29 | use warnings 'deprecated' ; |
599cee73 | 30 | 1 if $a EQ $b ; |
31 | } | |
32 | 1 if $a EQ $b ; | |
33 | EXPECT | |
34 | Use of EQ is deprecated at - line 6. | |
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 | ||
4438c4b7 | 70 | use warnings 'deprecated' ; |
599cee73 | 71 | 1 if $a EQ $b ; |
72 | EXPECT | |
73 | Use of EQ is deprecated at - line 3. | |
74 | ######## | |
75 | ||
76 | --FILE-- abc | |
77 | 1 if $a EQ $b ; | |
78 | 1; | |
79 | --FILE-- | |
4438c4b7 | 80 | use warnings 'deprecated' ; |
599cee73 | 81 | require "./abc"; |
82 | EXPECT | |
83 | ||
84 | ######## | |
85 | ||
86 | --FILE-- abc | |
4438c4b7 | 87 | use warnings 'deprecated' ; |
599cee73 | 88 | 1; |
89 | --FILE-- | |
90 | require "./abc"; | |
91 | 1 if $a EQ $b ; | |
92 | EXPECT | |
93 | ||
94 | ######## | |
95 | ||
96 | --FILE-- abc | |
4438c4b7 | 97 | use warnings 'deprecated' ; |
599cee73 | 98 | 1 if $a EQ $b ; |
99 | 1; | |
100 | --FILE-- | |
4438c4b7 | 101 | use warnings 'uninitialized' ; |
599cee73 | 102 | require "./abc"; |
103 | my $a ; chop $a ; | |
104 | EXPECT | |
105 | Use of EQ is deprecated at ./abc line 2. | |
b89fed5f | 106 | Use of uninitialized value in scalar chop at - line 3. |
599cee73 | 107 | ######## |
108 | ||
109 | --FILE-- abc.pm | |
4438c4b7 | 110 | use warnings 'deprecated' ; |
599cee73 | 111 | 1 if $a EQ $b ; |
112 | 1; | |
113 | --FILE-- | |
4438c4b7 | 114 | use warnings 'uninitialized' ; |
599cee73 | 115 | use abc; |
116 | my $a ; chop $a ; | |
117 | EXPECT | |
118 | Use of EQ is deprecated 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 { | |
182 | 1 if $a EQ $b ; | |
183 | }; print STDERR $@ ; | |
599cee73 | 184 | 1 if $a EQ $b ; |
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 { | |
195 | use warnings 'deprecated' ; | |
196 | 1 if $a EQ $b ; | |
197 | }; print STDERR $@ ; | |
599cee73 | 198 | 1 if $a EQ $b ; |
16ff4256 | 199 | } |
599cee73 | 200 | EXPECT |
16ff4256 | 201 | Use of EQ is deprecated at - line 8. |
599cee73 | 202 | ######## |
203 | ||
204 | # Check scope of pragma with eval | |
16ff4256 | 205 | no warnings; |
206 | { | |
207 | use warnings 'deprecated' ; | |
208 | eval { | |
209 | 1 if $a EQ $b ; | |
210 | }; print STDERR $@ ; | |
599cee73 | 211 | 1 if $a EQ $b ; |
16ff4256 | 212 | } |
599cee73 | 213 | EXPECT |
599cee73 | 214 | Use of EQ is deprecated at - line 7. |
16ff4256 | 215 | Use of EQ is deprecated at - line 9. |
599cee73 | 216 | ######## |
217 | ||
218 | # Check scope of pragma with eval | |
16ff4256 | 219 | no warnings; |
220 | { | |
221 | use warnings 'deprecated' ; | |
222 | eval { | |
223 | no warnings ; | |
224 | 1 if $a EQ $b ; | |
225 | }; print STDERR $@ ; | |
599cee73 | 226 | 1 if $a EQ $b ; |
16ff4256 | 227 | } |
599cee73 | 228 | EXPECT |
16ff4256 | 229 | Use of EQ is deprecated 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 ' | |
292 | 1 if $a EQ $b ; | |
293 | '; print STDERR $@ ; | |
599cee73 | 294 | 1 if $a EQ $b ; |
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[ | |
305 | use warnings 'deprecated' ; | |
306 | 1 if $a EQ $b ; | |
307 | ]; print STDERR $@; | |
599cee73 | 308 | 1 if $a EQ $b ; |
16ff4256 | 309 | } |
599cee73 | 310 | EXPECT |
311 | Use of EQ is deprecated at (eval 1) line 3. | |
312 | ######## | |
313 | ||
314 | # Check scope of pragma with eval | |
16ff4256 | 315 | no warnings; |
316 | { | |
317 | use warnings 'deprecated' ; | |
318 | eval ' | |
319 | 1 if $a EQ $b ; | |
320 | '; print STDERR $@; | |
599cee73 | 321 | 1 if $a EQ $b ; |
16ff4256 | 322 | } |
599cee73 | 323 | EXPECT |
16ff4256 | 324 | Use of EQ is deprecated at - line 9. |
599cee73 | 325 | Use of EQ is deprecated at (eval 1) line 2. |
326 | ######## | |
327 | ||
328 | # Check scope of pragma with eval | |
16ff4256 | 329 | no warnings; |
330 | { | |
331 | use warnings 'deprecated' ; | |
332 | eval ' | |
333 | no warnings ; | |
334 | 1 if $a EQ $b ; | |
335 | '; print STDERR $@; | |
599cee73 | 336 | 1 if $a EQ $b ; |
16ff4256 | 337 | } |
599cee73 | 338 | EXPECT |
16ff4256 | 339 | Use of EQ is deprecated at - line 10. |
4438c4b7 | 340 | ######## |
341 | ||
342 | # Check the additive nature of the pragma | |
343 | 1 if $a EQ $b ; | |
344 | my $a ; chop $a ; | |
345 | use warnings 'deprecated' ; | |
346 | 1 if $a EQ $b ; | |
347 | my $b ; chop $b ; | |
348 | use warnings 'uninitialized' ; | |
349 | my $c ; chop $c ; | |
350 | no warnings 'deprecated' ; | |
351 | 1 if $a EQ $b ; | |
352 | EXPECT | |
353 | Use of EQ is deprecated at - line 6. | |
b89fed5f | 354 | Use of uninitialized value in scalar chop at - line 9. |
355 | Use of uninitialized value in string eq at - line 11. | |
356 | Use of uninitialized value in string eq at - line 11. |