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