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