This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Restore null checks to stashpv_hvname_match [perl #101430]
[perl5.git] / t / lib / warnings / perly
1   perly.y       AOK
2
3   dep() => deprecate("\"do\" to call subroutines") 
4   Use of "do" to call subroutines is deprecated
5
6         sub fred {} do fred()
7         sub fred {} do fred(1)
8         sub fred {} $a = "fred" ; do $a()
9         sub fred {} $a = "fred" ; do $a(1)
10
11   Use of qw(...) as parentheses is deprecated
12
13         if qw(a) {}
14         unless qw(a) {}
15         if (0) {} elsif qw(a) {}
16         given qw(a) {}
17         when qw(a) {}
18         while qw(a) {}
19         until qw(a) {}
20         foreach $x qw(a b c) {}
21         foreach my $x qw(a b c) {}
22         $obj->meth qw(a b c)
23         do foo qw(a b c)
24         do $subref qw(a b c)
25         &foo qw(a b c)
26         $a[0] qw(a b c)
27
28 __END__
29 # perly.y
30 use warnings 'deprecated' ;
31 sub fred {} 
32 do fred() ;
33 do fred(1) ;
34 $a = "fred" ; 
35 do $a() ;
36 do $a(1) ;
37 no warnings 'deprecated' ;
38 do fred() ;
39 do fred(1) ;
40 $a = "fred" ; 
41 do $a() ;
42 do $a(1) ;
43 EXPECT
44 Use of "do" to call subroutines is deprecated at - line 4.
45 Use of "do" to call subroutines is deprecated at - line 5.
46 Use of "do" to call subroutines is deprecated at - line 7.
47 Use of "do" to call subroutines is deprecated at - line 8.
48 ########
49 use warnings qw(deprecated void);
50 if qw(a) { print "x0\n"; } else { }
51 if qw(0) { print "x1\n"; } else { }
52 if qw(z a) { print "x2\n"; } else { }
53 if qw(z 0) { print "x3\n"; } else { }
54 EXPECT
55 Use of qw(...) as parentheses is deprecated at - line 2.
56 Use of qw(...) as parentheses is deprecated at - line 3.
57 Use of qw(...) as parentheses is deprecated at - line 4.
58 Useless use of a constant (z) in void context at - line 4.
59 Use of qw(...) as parentheses is deprecated at - line 5.
60 Useless use of a constant (z) in void context at - line 5.
61 x0
62 x2
63 ########
64 if qw() { print "x0\n"; } else { }
65 EXPECT
66 Use of qw(...) as parentheses is deprecated at - line 1.
67 syntax error at - line 1, near "if qw()"
68 Execution of - aborted due to compilation errors.
69 ########
70 use warnings qw(deprecated void);
71 unless qw(a) { print "x0\n"; } else { }
72 unless qw(0) { print "x1\n"; } else { }
73 unless qw(z a) { print "x2\n"; } else { }
74 unless qw(z 0) { print "x3\n"; } else { }
75 EXPECT
76 Use of qw(...) as parentheses is deprecated at - line 2.
77 Use of qw(...) as parentheses is deprecated at - line 3.
78 Use of qw(...) as parentheses is deprecated at - line 4.
79 Useless use of a constant (z) in void context at - line 4.
80 Use of qw(...) as parentheses is deprecated at - line 5.
81 Useless use of a constant (z) in void context at - line 5.
82 x1
83 x3
84 ########
85 unless qw() { print "x0\n"; } else { }
86 EXPECT
87 Use of qw(...) as parentheses is deprecated at - line 1.
88 syntax error at - line 1, near "unless qw()"
89 Execution of - aborted due to compilation errors.
90 ########
91 use warnings qw(deprecated void);
92 if(0) { print "eek\n"; } elsif qw(a) { print "x0\n"; } else { }
93 if(0) { print "eek\n"; } elsif qw(0) { print "x1\n"; } else { }
94 if(0) { print "eek\n"; } elsif qw(z a) { print "x2\n"; } else { }
95 if(0) { print "eek\n"; } elsif qw(z 0) { print "x3\n"; } else { }
96 EXPECT
97 Use of qw(...) as parentheses is deprecated at - line 2.
98 Use of qw(...) as parentheses is deprecated at - line 3.
99 Use of qw(...) as parentheses is deprecated at - line 4.
100 Useless use of a constant (z) in void context at - line 4.
101 Use of qw(...) as parentheses is deprecated at - line 5.
102 Useless use of a constant (z) in void context at - line 5.
103 x0
104 x2
105 ########
106 if(0) { print "eek\n"; } elsif qw() { print "x0\n"; } else { }
107 EXPECT
108 Use of qw(...) as parentheses is deprecated at - line 1.
109 syntax error at - line 1, near "elsif qw()"
110 Execution of - aborted due to compilation errors.
111 ########
112 use warnings qw(deprecated void); use feature "switch";
113 given qw(a) { print "x0 $_\n"; }
114 given qw(z a) { print "x1 $_\n"; }
115 EXPECT
116 Use of qw(...) as parentheses is deprecated at - line 2.
117 Use of qw(...) as parentheses is deprecated at - line 3.
118 Useless use of a constant (z) in void context at - line 3.
119 x0 a
120 x1 a
121 ########
122 use feature "switch";
123 given qw() { print "x0\n"; }
124 EXPECT
125 Use of qw(...) as parentheses is deprecated at - line 2.
126 syntax error at - line 2, near "given qw()"
127 Execution of - aborted due to compilation errors.
128 ########
129 use warnings qw(deprecated void); use feature "switch";
130 given("a") { when qw(a) { print "x0\n"; } }
131 given("a") { when qw(b) { print "x1\n"; } }
132 given("a") { when qw(z a) { print "x2\n"; } }
133 given("a") { when qw(z b) { print "x3\n"; } }
134 EXPECT
135 Use of qw(...) as parentheses is deprecated at - line 2.
136 Use of qw(...) as parentheses is deprecated at - line 3.
137 Use of qw(...) as parentheses is deprecated at - line 4.
138 Useless use of a constant (z) in void context at - line 4.
139 Use of qw(...) as parentheses is deprecated at - line 5.
140 Useless use of a constant (z) in void context at - line 5.
141 x0
142 x2
143 ########
144 use feature "switch";
145 given("a") { when qw() { print "x0\n"; } }
146 EXPECT
147 Use of qw(...) as parentheses is deprecated at - line 2.
148 syntax error at - line 2, near "when qw()"
149 syntax error at - line 2, near "} }"
150 Execution of - aborted due to compilation errors.
151 ########
152 use warnings qw(deprecated void);
153 while qw(a) { print "x0\n"; last; } {;}
154 while qw(0) { print "x1\n"; last; } {;}
155 while qw(z a) { print "x2\n"; last; } {;}
156 while qw(z 0) { print "x3\n"; last; } {;}
157 EXPECT
158 Use of qw(...) as parentheses is deprecated at - line 2.
159 Use of qw(...) as parentheses is deprecated at - line 3.
160 Use of qw(...) as parentheses is deprecated at - line 4.
161 Useless use of a constant (z) in void context at - line 4.
162 Use of qw(...) as parentheses is deprecated at - line 5.
163 Useless use of a constant (z) in void context at - line 5.
164 x0
165 x2
166 ########
167 while qw() { print "x0\n"; last; }
168 EXPECT
169 Use of qw(...) as parentheses is deprecated at - line 1.
170 x0
171 ########
172 use warnings qw(deprecated void);
173 until qw(a) { print "x0\n"; last; } {;}
174 until qw(0) { print "x1\n"; last; } {;}
175 until qw(z a) { print "x2\n"; last; } {;}
176 until qw(z 0) { print "x3\n"; last; } {;}
177 EXPECT
178 Use of qw(...) as parentheses is deprecated at - line 2.
179 Use of qw(...) as parentheses is deprecated at - line 3.
180 Use of qw(...) as parentheses is deprecated at - line 4.
181 Useless use of a constant (z) in void context at - line 4.
182 Use of qw(...) as parentheses is deprecated at - line 5.
183 Useless use of a constant (z) in void context at - line 5.
184 x1
185 x3
186 ########
187 until qw() { print "x0\n"; } else { }
188 EXPECT
189 Use of qw(...) as parentheses is deprecated at - line 1.
190 syntax error at - line 1, near "until qw()"
191 Execution of - aborted due to compilation errors.
192 ########
193 foreach $x qw(a b c) { print $x, "\n"; }
194 EXPECT
195 Use of qw(...) as parentheses is deprecated at - line 1.
196 a
197 b
198 c
199 ########
200 foreach $x qw() { print $x, "\n"; }
201 EXPECT
202 Use of qw(...) as parentheses is deprecated at - line 1.
203 syntax error at - line 1, near "$x qw()"
204 Execution of - aborted due to compilation errors.
205 ########
206 foreach my $x qw(a b c) { print $x, "\n"; }
207 EXPECT
208 Use of qw(...) as parentheses is deprecated at - line 1.
209 a
210 b
211 c
212 ########
213 foreach my $x qw() { print $x, "\n"; }
214 EXPECT
215 Use of qw(...) as parentheses is deprecated at - line 1.
216 syntax error at - line 1, near "$x qw()"
217 Execution of - aborted due to compilation errors.
218 ########
219 sub a5c85eef3bf30129e20989e96b099d13::foo { print "+", join(":", @_), "\n"; }
220 "a5c85eef3bf30129e20989e96b099d13"->foo qw(); {;}
221 "a5c85eef3bf30129e20989e96b099d13"->foo qw(a b c); {;}
222 EXPECT
223 Use of qw(...) as parentheses is deprecated at - line 2.
224 Use of qw(...) as parentheses is deprecated at - line 3.
225 +a5c85eef3bf30129e20989e96b099d13
226 +a5c85eef3bf30129e20989e96b099d13:a:b:c
227 ########
228 sub fd4de2af1449cec72693c36842d41862 { print "+", join(":", @_), "\n"; }
229 do fd4de2af1449cec72693c36842d41862 qw(); {;}
230 do fd4de2af1449cec72693c36842d41862 qw(a b c); {;}
231 EXPECT
232 Use of qw(...) as parentheses is deprecated at - line 2.
233 Use of "do" to call subroutines is deprecated at - line 2.
234 Use of qw(...) as parentheses is deprecated at - line 3.
235 Use of "do" to call subroutines is deprecated at - line 3.
236 +
237 +a:b:c
238 ########
239 $subref = sub { print "+", join(":", @_), "\n"; };
240 do $subref qw();
241 do $subref qw(a b c);
242 EXPECT
243 Use of qw(...) as parentheses is deprecated at - line 2.
244 Use of "do" to call subroutines is deprecated at - line 2.
245 Use of qw(...) as parentheses is deprecated at - line 3.
246 Use of "do" to call subroutines is deprecated at - line 3.
247 +
248 +a:b:c
249 ########
250 sub e293a8f7cb38880a48867fcb336448e5 { print "+", join(":", @_), "\n"; }
251 &e293a8f7cb38880a48867fcb336448e5 qw();
252 &e293a8f7cb38880a48867fcb336448e5 qw(a b c);
253 EXPECT
254 Use of qw(...) as parentheses is deprecated at - line 2.
255 Use of qw(...) as parentheses is deprecated at - line 3.
256 +
257 +a:b:c
258 ########
259 my @a = (sub { print "+", join(":", @_), "\n"; });
260 $a[0] qw();
261 $a[0] qw(a b c);
262 EXPECT
263 Use of qw(...) as parentheses is deprecated at - line 2.
264 Use of qw(...) as parentheses is deprecated at - line 3.
265 +
266 +a:b:c