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