This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlapi: Fix grammar
[perl5.git] / t / lib / warnings / perl
1   perl.c        AOK
2
3   gv_check(defstash)
4         Name \"%s::%s\" used only once: possible typo 
5
6   Mandatory Warnings All TODO
7   ------------------
8   Recompile perl with -DDEBUGGING to use -D switch      [moreswitches]
9   Unbalanced scopes: %ld more ENTERs than LEAVEs        [perl_destruct]
10   Unbalanced saves: %ld more saves than restores        [perl_destruct]
11   Unbalanced tmps: %ld more allocs than frees           [perl_destruct]
12   Unbalanced context: %ld more PUSHes than POPs         [perl_destruct]
13   Unbalanced string table refcount: (%d) for \"%s\"     [perl_destruct]
14   Scalars leaked: %ld                                   [perl_destruct]
15
16
17 __END__
18 # perl.c
19 no warnings 'once' ;
20 $x = 3 ;
21 use warnings 'once' ;
22 $z = 3 ;
23 EXPECT
24 Name "main::z" used only once: possible typo at - line 5.
25 ########
26 -w
27 # perl.c
28 $x = 3 ;
29 no warnings 'once' ;
30 $z = 3 
31 EXPECT
32 Name "main::x" used only once: possible typo at - line 3.
33 ########
34 # perl.c
35 BEGIN { $^W =1 ; }
36 $x = 3 ;
37 no warnings 'once' ;
38 $z = 3 
39 EXPECT
40 Name "main::x" used only once: possible typo at - line 3.
41 ########
42 # perl.c
43 use warnings 'once';
44 $\; # test a few
45 $:; # punct vars
46 $0; # and
47 $123; # numbers
48 $_;    # and
49 $_foo;  # underscores (none of which should warn)
50 @DB::args
51 EXPECT
52 ########
53 -w
54 # perl.c
55 print # avoid void warning
56 $\, # test a few
57 $:, # punct vars
58 $0, # and
59 $123, # numbers
60 $_,    # and
61 $_foo,  # underscores (none of which should warn)
62 @DB::args
63 if 0;
64 EXPECT
65 ########
66 -W
67 # perl.c
68 no warnings 'once' ;
69 $x = 3 ;
70 use warnings 'once' ;
71 $z = 3 ;
72 EXPECT
73 OPTION random
74 Name "main::z" used only once: possible typo at - line 6.
75 Name "main::x" used only once: possible typo at - line 4.
76 ########
77 -X
78 # perl.c
79 use warnings 'once' ;
80 $x = 3 ;
81 EXPECT
82 ########
83
84 # perl.c
85 { use warnings 'once' ; $x = 3 ; }
86 $y = 3 ;
87 EXPECT
88 Name "main::x" used only once: possible typo at - line 3.
89 ########
90
91 # perl.c
92 $z = 3 ;
93 BEGIN { $^W = 1 }
94 { no warnings 'once' ; $x = 3 ; }
95 $y = 3 ;
96 EXPECT
97 Name "main::y" used only once: possible typo at - line 6.
98 ########
99
100 # perl.c
101 use utf8;
102 use open qw( :utf8 :std );
103 no warnings 'once' ;
104 $ᛪ = 3 ;
105 use warnings 'once' ;
106 $ȥ = 3 ;
107 EXPECT
108 Name "main::ȥ" used only once: possible typo at - line 8.
109 ########
110 -w
111 # perl.c
112 use utf8;
113 use open qw( :utf8 :std );
114 $ᛪ = 3 ;
115 no warnings 'once' ;
116 $ȥ = 3;
117 EXPECT
118 Name "main::ᛪ" used only once: possible typo at - line 5.
119 ########
120 # perl.c
121 use utf8;
122 use open qw( :utf8 :std );
123 BEGIN { $^W =1 ; }
124 $ᛪ = 3 ;
125 no warnings 'once' ;
126 $ȥ = 3 
127 EXPECT
128 Name "main::ᛪ" used only once: possible typo at - line 5.
129 ########
130 -W
131 # perl.c
132 use utf8;
133 use open qw( :utf8 :std );
134 no warnings 'once' ;
135 $ᛪ = 3 ;
136 use warnings 'once' ;
137 $ȥ = 3 ;
138 EXPECT
139 OPTION random
140 Name "main::ȥ" used only once: possible typo at - line 8.
141 Name "main::ᛪ" used only once: possible typo at - line 6.
142 ########
143 -X
144 # perl.c
145 use utf8;
146 use open qw( :utf8 :std );
147 use warnings 'once' ;
148 $ᛪ = 3 ;
149 EXPECT
150 ########
151
152 # perl.c
153 use utf8;
154 use open qw( :utf8 :std );
155 { use warnings 'once' ; $ᛪ = 3 ; }
156 $ŷ = 3 ;
157 EXPECT
158 Name "main::ᛪ" used only once: possible typo at - line 5.
159 ########
160
161 # perl.c
162 use utf8;
163 use open qw( :utf8 :std );
164 $ȥ = 3 ;
165 BEGIN { $^W = 1 }
166 { no warnings 'once' ; $ᛪ = 3 ; }
167 $ŷ = 3 ;
168 EXPECT
169 Name "main::ŷ" used only once: possible typo at - line 8.
170 ########
171
172
173 # perl.c
174 use utf8;
175 use open qw( :utf8 :std );
176 package ɕლȃṢȿ;
177 no warnings 'once' ;
178 $ᛪ = 3 ;
179 use warnings 'once' ;
180 $ȥ = 3 ;
181 EXPECT
182 Name "ɕლȃṢȿ::ȥ" used only once: possible typo at - line 10.
183 ########
184 -w
185 # perl.c
186 use utf8;
187 use open qw( :utf8 :std );
188 package ɕლȃṢȿ;
189 $ᛪ = 3 ;
190 no warnings 'once' ;
191 $ȥ = 3 
192 EXPECT
193 Name "ɕლȃṢȿ::ᛪ" used only once: possible typo at - line 6.
194 ########
195 # perl.c
196 use utf8;
197 use open qw( :utf8 :std );
198 package ɕლȃṢȿ;
199 BEGIN { $^W =1 ; }
200 $ᛪ = 3 ;
201 no warnings 'once' ;
202 $ȥ = 3 
203 EXPECT
204 Name "ɕლȃṢȿ::ᛪ" used only once: possible typo at - line 6.
205 ########
206 -W
207 # perl.c
208 use utf8;
209 use open qw( :utf8 :std );
210 package ɕლȃṢȿ;
211 no warnings 'once' ;
212 $ᛪ = 3 ;
213 use warnings 'once' ;
214 $ȥ = 3 ;
215 EXPECT
216 OPTION random
217 Name "ɕლȃṢȿ::ᛪ" used only once: possible typo at - line 7.
218 Name "ɕლȃṢȿ::ȥ" used only once: possible typo at - line 9.
219 ########
220 -X
221 # perl.c
222 use utf8;
223 use open qw( :utf8 :std );
224 use warnings 'once' ;
225 package ɕლȃṢȿ;
226 $ᛪ = 3 ;
227 EXPECT
228 ########
229
230 # perl.c
231 use utf8;
232 use open qw( :utf8 :std );
233 package ɕლȃṢȿ;
234 { use warnings 'once' ; $ᛪ = 3 ; }
235 $ŷ = 3 ;
236 EXPECT
237 Name "ɕლȃṢȿ::ᛪ" used only once: possible typo at - line 6.
238 ########
239
240 # perl.c
241 use utf8;
242 use open qw( :utf8 :std );
243 package ɕლȃṢȿ;
244 $ȥ = 3 ;
245 BEGIN { $^W = 1 }
246 { no warnings 'once' ; $ᛪ = 3 ; }
247 $ŷ = 3 ;
248 EXPECT
249 Name "ɕლȃṢȿ::ŷ" used only once: possible typo at - line 9.
250 ########
251
252 use warnings 'once';
253 $foo++; BEGIN { eval q|@a =~ s///; sub foo;| }
254 EXPECT
255 Name "main::foo" used only once: possible typo at - line 3.
256 ########
257
258 use warnings 'once';
259 BEGIN { ${"_<".__FILE__} = \1 } # should not affect file name in warning
260 $foo++;
261 EXPECT
262 Name "main::foo" used only once: possible typo at - line 4.
263 ########
264
265 use warnings 'once'; # necessary to trigger the crash
266 BEGIN{*MUSHROOMS::mushrooms::MUSHROOMS:: = *MUSHROOMS::} # circularity
267 $foo++;
268 EXPECT
269 Name "main::foo" used only once: possible typo at - line 4.