Once more unto resync
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / 2use
1 Check lexical warnings functionality
2
3 TODO
4   check that the warning hierarchy works.
5
6 __END__
7
8 # ignore unknown warning categories
9 use warnings 'this-should-never-be-a-warning-category' ;
10 EXPECT
11 ########
12
13 # Check compile time scope of pragma
14 use warnings 'deprecated' ;
15 {
16     no warnings ;
17     1 if $a EQ $b ;
18 }
19 1 if $a EQ $b ;
20 EXPECT
21 Use of EQ is deprecated at - line 8.
22 ########
23
24 # Check compile time scope of pragma
25 no warnings;
26 {
27     use warnings 'deprecated' ;
28     1 if $a EQ $b ;
29 }
30 1 if $a EQ $b ;
31 EXPECT
32 Use of EQ is deprecated at - line 6.
33 ########
34
35 # Check runtime scope of pragma
36 use warnings 'uninitialized' ;
37 {
38     no warnings ;
39     my $b ; chop $b ;
40 }
41 my $b ; chop $b ;
42 EXPECT
43 Use of uninitialized value in scalar chop at - line 8.
44 ########
45
46 # Check runtime scope of pragma
47 no warnings ;
48 {
49     use warnings 'uninitialized' ;
50     my $b ; chop $b ;
51 }
52 my $b ; chop $b ;
53 EXPECT
54 Use of uninitialized value in scalar chop at - line 6.
55 ########
56
57 # Check runtime scope of pragma
58 no warnings ;
59 {
60     use warnings 'uninitialized' ;
61     $a = sub { my $b ; chop $b ; }
62 }
63 &$a ;
64 EXPECT
65 Use of uninitialized value in scalar chop at - line 6.
66 ########
67
68 use warnings 'deprecated' ;
69 1 if $a EQ $b ;
70 EXPECT
71 Use of EQ is deprecated at - line 3.
72 ########
73
74 --FILE-- abc
75 1 if $a EQ $b ;
76 1;
77 --FILE-- 
78 use warnings 'deprecated' ;
79 require "./abc";
80 EXPECT
81
82 ########
83
84 --FILE-- abc
85 use warnings 'deprecated' ;
86 1;
87 --FILE-- 
88 require "./abc";
89 1 if $a EQ $b ;
90 EXPECT
91
92 ########
93
94 --FILE-- abc
95 use warnings 'deprecated' ;
96 1 if $a EQ $b ;
97 1;
98 --FILE-- 
99 use warnings 'uninitialized' ;
100 require "./abc";
101 my $a ; chop $a ;
102 EXPECT
103 Use of EQ is deprecated at ./abc line 2.
104 Use of uninitialized value in scalar chop at - line 3.
105 ########
106
107 --FILE-- abc.pm
108 use warnings 'deprecated' ;
109 1 if $a EQ $b ;
110 1;
111 --FILE-- 
112 use warnings 'uninitialized' ;
113 use abc;
114 my $a ; chop $a ;
115 EXPECT
116 Use of EQ is deprecated at abc.pm line 2.
117 Use of uninitialized value in scalar chop at - line 3.
118 ########
119
120 # Check scope of pragma with eval
121 no warnings ;
122 eval {
123     my $b ; chop $b ;
124 }; print STDERR $@ ;
125 my $b ; chop $b ;
126 EXPECT
127
128 ########
129
130 # Check scope of pragma with eval
131 no warnings ;
132 eval {
133     use warnings 'uninitialized' ;
134     my $b ; chop $b ;
135 }; print STDERR $@ ;
136 my $b ; chop $b ;
137 EXPECT
138 Use of uninitialized value in scalar chop at - line 6.
139 ########
140
141 # Check scope of pragma with eval
142 use warnings 'uninitialized' ;
143 eval {
144     my $b ; chop $b ;
145 }; print STDERR $@ ;
146 my $b ; chop $b ;
147 EXPECT
148 Use of uninitialized value in scalar chop at - line 5.
149 Use of uninitialized value in scalar chop at - line 7.
150 ########
151
152 # Check scope of pragma with eval
153 use warnings 'uninitialized' ;
154 eval {
155     no warnings ;
156     my $b ; chop $b ;
157 }; print STDERR $@ ;
158 my $b ; chop $b ;
159 EXPECT
160 Use of uninitialized value in scalar chop at - line 8.
161 ########
162
163 # Check scope of pragma with eval
164 no warnings ;
165 eval {
166     1 if $a EQ $b ;
167 }; print STDERR $@ ;
168 1 if $a EQ $b ;
169 EXPECT
170
171 ########
172
173 # Check scope of pragma with eval
174 no warnings ;
175 eval {
176     use warnings 'deprecated' ;
177     1 if $a EQ $b ;
178 }; print STDERR $@ ;
179 1 if $a EQ $b ;
180 EXPECT
181 Use of EQ is deprecated at - line 6.
182 ########
183
184 # Check scope of pragma with eval
185 use warnings 'deprecated' ;
186 eval {
187     1 if $a EQ $b ;
188 }; print STDERR $@ ;
189 1 if $a EQ $b ;
190 EXPECT
191 Use of EQ is deprecated at - line 5.
192 Use of EQ is deprecated at - line 7.
193 ########
194
195 # Check scope of pragma with eval
196 use warnings 'deprecated' ;
197 eval {
198     no warnings ;
199     1 if $a EQ $b ;
200 }; print STDERR $@ ;
201 1 if $a EQ $b ;
202 EXPECT
203 Use of EQ is deprecated at - line 8.
204 ########
205
206 # Check scope of pragma with eval
207 no warnings ;
208 eval '
209     my $b ; chop $b ;
210 '; print STDERR $@ ;
211 my $b ; chop $b ;
212 EXPECT
213
214 ########
215
216 # Check scope of pragma with eval
217 no warnings ;
218 eval q[ 
219     use warnings 'uninitialized' ;
220     my $b ; chop $b ;
221 ]; print STDERR $@;
222 my $b ; chop $b ;
223 EXPECT
224 Use of uninitialized value in scalar chop at (eval 1) line 3.
225 ########
226
227 # Check scope of pragma with eval
228 use warnings 'uninitialized' ;
229 eval '
230     my $b ; chop $b ;
231 '; print STDERR $@ ;
232 my $b ; chop $b ;
233 EXPECT
234 Use of uninitialized value in scalar chop at (eval 1) line 2.
235 Use of uninitialized value in scalar chop at - line 7.
236 ########
237
238 # Check scope of pragma with eval
239 use warnings 'uninitialized' ;
240 eval '
241     no warnings ;
242     my $b ; chop $b ;
243 '; print STDERR $@ ;
244 my $b ; chop $b ;
245 EXPECT
246 Use of uninitialized value in scalar chop at - line 8.
247 ########
248
249 # Check scope of pragma with eval
250 no warnings ;
251 eval '
252     1 if $a EQ $b ;
253 '; print STDERR $@ ;
254 1 if $a EQ $b ;
255 EXPECT
256
257 ########
258
259 # Check scope of pragma with eval
260 no warnings ;
261 eval q[ 
262     use warnings 'deprecated' ;
263     1 if $a EQ $b ;
264 ]; print STDERR $@;
265 1 if $a EQ $b ;
266 EXPECT
267 Use of EQ is deprecated at (eval 1) line 3.
268 ########
269
270 # Check scope of pragma with eval
271 use warnings 'deprecated' ;
272 eval '
273     1 if $a EQ $b ;
274 '; print STDERR $@;
275 1 if $a EQ $b ;
276 EXPECT
277 Use of EQ is deprecated at - line 7.
278 Use of EQ is deprecated at (eval 1) line 2.
279 ########
280
281 # Check scope of pragma with eval
282 use warnings 'deprecated' ;
283 eval '
284     no warnings ;
285     1 if $a EQ $b ;
286 '; print STDERR $@;
287 1 if $a EQ $b ;
288 EXPECT
289 Use of EQ is deprecated at - line 8.
290 ########
291
292 # Check the additive nature of the pragma
293 1 if $a EQ $b ;
294 my $a ; chop $a ;
295 use warnings 'deprecated' ;
296 1 if $a EQ $b ;
297 my $b ; chop $b ;
298 use warnings 'uninitialized' ;
299 my $c ; chop $c ;
300 no warnings 'deprecated' ;
301 1 if $a EQ $b ;
302 EXPECT
303 Use of EQ is deprecated at - line 6.
304 Use of uninitialized value in scalar chop at - line 9.
305 Use of uninitialized value in string eq at - line 11.
306 Use of uninitialized value in string eq at - line 11.