This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix copy & paste error in tests
[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 EXPECT
51 ########
52 -W
53 # perl.c
54 no warnings 'once' ;
55 $x = 3 ;
56 use warnings 'once' ;
57 $z = 3 ;
58 EXPECT
59 OPTION random
60 Name "main::z" used only once: possible typo at - line 6.
61 Name "main::x" used only once: possible typo at - line 4.
62 ########
63 -X
64 # perl.c
65 use warnings 'once' ;
66 $x = 3 ;
67 EXPECT
68 ########
69
70 # perl.c
71 { use warnings 'once' ; $x = 3 ; }
72 $y = 3 ;
73 EXPECT
74 Name "main::x" used only once: possible typo at - line 3.
75 ########
76
77 # perl.c
78 $z = 3 ;
79 BEGIN { $^W = 1 }
80 { no warnings 'once' ; $x = 3 ; }
81 $y = 3 ;
82 EXPECT
83 Name "main::y" used only once: possible typo at - line 6.
84 ########
85
86 # perl.c
87 use utf8;
88 use open qw( :utf8 :std );
89 no warnings 'once' ;
90 $ᛪ = 3 ;
91 use warnings 'once' ;
92 $ȥ = 3 ;
93 EXPECT
94 Name "main::ȥ" used only once: possible typo at - line 8.
95 ########
96 -w
97 # perl.c
98 use utf8;
99 use open qw( :utf8 :std );
100 $ᛪ = 3 ;
101 no warnings 'once' ;
102 $ȥ = 3;
103 EXPECT
104 Name "main::ᛪ" used only once: possible typo at - line 5.
105 ########
106 # perl.c
107 use utf8;
108 use open qw( :utf8 :std );
109 BEGIN { $^W =1 ; }
110 $ᛪ = 3 ;
111 no warnings 'once' ;
112 $ȥ = 3 
113 EXPECT
114 Name "main::ᛪ" used only once: possible typo at - line 5.
115 ########
116 -W
117 # perl.c
118 use utf8;
119 use open qw( :utf8 :std );
120 no warnings 'once' ;
121 $ᛪ = 3 ;
122 use warnings 'once' ;
123 $ȥ = 3 ;
124 EXPECT
125 OPTION random
126 Name "main::ȥ" used only once: possible typo at - line 8.
127 Name "main::ᛪ" used only once: possible typo at - line 6.
128 ########
129 -X
130 # perl.c
131 use utf8;
132 use open qw( :utf8 :std );
133 use warnings 'once' ;
134 $ᛪ = 3 ;
135 EXPECT
136 ########
137
138 # perl.c
139 use utf8;
140 use open qw( :utf8 :std );
141 { use warnings 'once' ; $ᛪ = 3 ; }
142 $ŷ = 3 ;
143 EXPECT
144 Name "main::ᛪ" used only once: possible typo at - line 5.
145 ########
146
147 # perl.c
148 use utf8;
149 use open qw( :utf8 :std );
150 $ȥ = 3 ;
151 BEGIN { $^W = 1 }
152 { no warnings 'once' ; $ᛪ = 3 ; }
153 $ŷ = 3 ;
154 EXPECT
155 Name "main::ŷ" used only once: possible typo at - line 8.
156 ########
157
158
159 # perl.c
160 use utf8;
161 use open qw( :utf8 :std );
162 package ɕლȃṢȿ;
163 no warnings 'once' ;
164 $ᛪ = 3 ;
165 use warnings 'once' ;
166 $ȥ = 3 ;
167 EXPECT
168 Name "ɕლȃṢȿ::ȥ" used only once: possible typo at - line 10.
169 ########
170 -w
171 # perl.c
172 use utf8;
173 use open qw( :utf8 :std );
174 package ɕლȃṢȿ;
175 $ᛪ = 3 ;
176 no warnings 'once' ;
177 $ȥ = 3 
178 EXPECT
179 Name "ɕლȃṢȿ::ᛪ" used only once: possible typo at - line 6.
180 ########
181 # perl.c
182 use utf8;
183 use open qw( :utf8 :std );
184 package ɕლȃṢȿ;
185 BEGIN { $^W =1 ; }
186 $ᛪ = 3 ;
187 no warnings 'once' ;
188 $ȥ = 3 
189 EXPECT
190 Name "ɕლȃṢȿ::ᛪ" used only once: possible typo at - line 6.
191 ########
192 -W
193 # perl.c
194 use utf8;
195 use open qw( :utf8 :std );
196 package ɕლȃṢȿ;
197 no warnings 'once' ;
198 $ᛪ = 3 ;
199 use warnings 'once' ;
200 $ȥ = 3 ;
201 EXPECT
202 OPTION random
203 Name "ɕლȃṢȿ::ᛪ" used only once: possible typo at - line 7.
204 Name "ɕლȃṢȿ::ȥ" used only once: possible typo at - line 9.
205 ########
206 -X
207 # perl.c
208 use utf8;
209 use open qw( :utf8 :std );
210 use warnings 'once' ;
211 package ɕლȃṢȿ;
212 $ᛪ = 3 ;
213 EXPECT
214 ########
215
216 # perl.c
217 use utf8;
218 use open qw( :utf8 :std );
219 package ɕლȃṢȿ;
220 { use warnings 'once' ; $ᛪ = 3 ; }
221 $ŷ = 3 ;
222 EXPECT
223 Name "ɕლȃṢȿ::ᛪ" used only once: possible typo at - line 6.
224 ########
225
226 # perl.c
227 use utf8;
228 use open qw( :utf8 :std );
229 package ɕლȃṢȿ;
230 $ȥ = 3 ;
231 BEGIN { $^W = 1 }
232 { no warnings 'once' ; $ᛪ = 3 ; }
233 $ŷ = 3 ;
234 EXPECT
235 Name "ɕლȃṢȿ::ŷ" used only once: possible typo at - line 9.
236 ########
237
238 use warnings 'once';
239 $foo++; BEGIN { eval q|@a =~ s///; sub foo;| }
240 EXPECT
241 Name "main::foo" used only once: possible typo at - line 3.
242 ########
243
244 use warnings 'once';
245 BEGIN { ${"_<".__FILE__} = \1 } # should not affect file name in warning
246 $foo++;
247 EXPECT
248 Name "main::foo" used only once: possible typo at - line 4.
249 ########
250
251 use warnings 'once'; # necessary to trigger the crash
252 BEGIN{*MUSHROOMS::mushrooms::MUSHROOMS:: = *MUSHROOMS::} # circularity
253 $foo++;
254 EXPECT
255 Name "main::foo" used only once: possible typo at - line 4.