Patch to JPL example program
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / toke
CommitLineData
599cee73 1toke.c AOK
2
3 we seem to have lost a few ambiguous warnings!!
4
5
6 1 if $a EQ $b ;
7 1 if $a NE $b ;
8 1 if $a LT $b ;
9 1 if $a GT $b ;
10 1 if $a GE $b ;
11 1 if $a LE $b ;
12 $a = <<;
13 Use of comma-less variable list is deprecated
14 (called 3 times via depcom)
15
16 \1 better written as $1
17 use warning 'syntax' ;
18 s/(abc)/\1/;
19
20 warn(warn_nosemi)
21 Semicolon seems to be missing
22 $a = 1
23 &time ;
24
25
26 Reversed %c= operator
27 my $a =+ 2 ;
28 $a =- 2 ;
29 $a =* 2 ;
30 $a =% 2 ;
31 $a =& 2 ;
32 $a =. 2 ;
33 $a =^ 2 ;
34 $a =| 2 ;
35 $a =< 2 ;
36 $a =/ 2 ;
37
38 Multidimensional syntax %.*s not supported
39 my $a = $a[1,2] ;
40
41 You need to quote \"%s\""
42 sub fred {} ; $SIG{TERM} = fred;
43
44 Scalar value %.*s better written as $%.*s"
45 @a[3] = 2;
46 @a{3} = 2;
47
48 Can't use \\%c to mean $%c in expression
49 $_ = "ab" ; s/(ab)/\1/e;
50
51 Unquoted string "abc" may clash with future reserved word at - line 3.
52 warn(warn_reserved
53 $a = abc;
54
55 chmod: mode argument is missing initial 0
56 chmod 3;
57
58 Possible attempt to separate words with commas
59 @a = qw(a, b, c) ;
60
61 Possible attempt to put comments in qw() list
62 @a = qw(a b # c) ;
63
64 umask: argument is missing initial 0
65 umask 3;
66
67 %s (...) interpreted as function
68 print ("")
69 printf ("")
70 sort ("")
71
72 Ambiguous use of %c{%s%s} resolved to %c%s%s
73 $a = ${time[2]}
74 $a = ${time{2}}
75
76
77 Ambiguous use of %c{%s} resolved to %c%s
78 $a = ${time}
79 sub fred {} $a = ${fred}
80
81 Misplaced _ in number
82 $a = 1_2;
83 $a = 1_2345_6;
84
85 Bareword \"%s\" refers to nonexistent package
86 $a = FRED:: ;
87
88 Ambiguous call resolved as CORE::%s(), qualify as such or use &
89 sub time {}
90 my $a = time()
91
92 Use of \\x{} without utf8 declaration
93 $_ = " \x{123} " ;
94
95
96 \x%.*s will produce malformed UTF-8 character; use \x{%.*s} for that
97 use utf8 ;
98 $_ = "\xffe"
99
100__END__
101# toke.c
102use warning 'deprecated' ;
1031 if $a EQ $b ;
1041 if $a NE $b ;
1051 if $a GT $b ;
1061 if $a LT $b ;
1071 if $a GE $b ;
1081 if $a LE $b ;
109EXPECT
110Use of EQ is deprecated at - line 3.
111Use of NE is deprecated at - line 4.
112Use of GT is deprecated at - line 5.
113Use of LT is deprecated at - line 6.
114Use of GE is deprecated at - line 7.
115Use of LE is deprecated at - line 8.
116########
117# toke.c
118use warning 'deprecated' ;
119format STDOUT =
120@<<< @||| @>>> @>>>
121$a $b "abc" 'def'
122.
123($a, $b) = (1,2,3);
124write;
125EXPECT
126Use of comma-less variable list is deprecated at - line 5.
127Use of comma-less variable list is deprecated at - line 5.
128Use of comma-less variable list is deprecated at - line 5.
1291 2 abc def
130########
131# toke.c
132use warning 'deprecated' ;
133$a = <<;
134
135EXPECT
136Use of bare << to mean <<"" is deprecated at - line 3.
137########
138# toke.c
139use warning 'syntax' ;
140s/(abc)/\1/;
141EXPECT
142\1 better written as $1 at - line 3.
143########
144# toke.c
145use warning 'semicolon' ;
146$a = 1
147&time ;
148EXPECT
149Semicolon seems to be missing at - line 3.
150########
151# toke.c
e4050d25 152BEGIN {
153 # Scalars leaked: due to syntax errors
154 $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
155}
599cee73 156use warning 'syntax' ;
157my $a =+ 2 ;
158$a =- 2 ;
159$a =* 2 ;
160$a =% 2 ;
161$a =& 2 ;
162$a =. 2 ;
163$a =^ 2 ;
164$a =| 2 ;
165$a =< 2 ;
166$a =/ 2 ;
167EXPECT
e4050d25 168Reversed += operator at - line 7.
169Reversed -= operator at - line 8.
170Reversed *= operator at - line 9.
171Reversed %= operator at - line 10.
172Reversed &= operator at - line 11.
173Reversed .= operator at - line 12.
174syntax error at - line 12, near "=."
175Reversed ^= operator at - line 13.
176syntax error at - line 13, near "=^"
177Reversed |= operator at - line 14.
178syntax error at - line 14, near "=|"
179Reversed <= operator at - line 15.
180Unterminated <> operator at - line 15.
599cee73 181########
182# toke.c
183use warning 'syntax' ;
184my $a = $a[1,2] ;
185EXPECT
186Multidimensional syntax $a[1,2] not supported at - line 3.
187########
188# toke.c
189use warning 'syntax' ;
190sub fred {} ; $SIG{TERM} = fred;
191EXPECT
192You need to quote "fred" at - line 3.
193########
194# toke.c
195use warning 'syntax' ;
196@a[3] = 2;
197@a{3} = 2;
198EXPECT
199Scalar value @a[3] better written as $a[3] at - line 3.
200Scalar value @a{3} better written as $a{3} at - line 4.
201########
202# toke.c
203use warning 'syntax' ;
204$_ = "ab" ;
205s/(ab)/\1/e;
206EXPECT
207Can't use \1 to mean $1 in expression at - line 4.
208########
209# toke.c
210use warning 'reserved' ;
211$a = abc;
212EXPECT
213Unquoted string "abc" may clash with future reserved word at - line 3.
214########
215# toke.c
216use warning 'octal' ;
217chmod 3;
218EXPECT
219chmod: mode argument is missing initial 0 at - line 3, at end of line
220########
221# toke.c
222use warning 'syntax' ;
223@a = qw(a, b, c) ;
224EXPECT
225Possible attempt to separate words with commas at - line 3.
226########
227# toke.c
228use warning 'syntax' ;
229@a = qw(a b #) ;
230EXPECT
231Possible attempt to put comments in qw() list at - line 3.
232########
233# toke.c
234use warning 'octal' ;
235umask 3;
236EXPECT
237umask: argument is missing initial 0 at - line 3, at end of line
238########
239# toke.c
240use warning 'syntax' ;
241print ("")
242EXPECT
243print (...) interpreted as function at - line 3.
244########
245# toke.c
246use warning 'syntax' ;
247printf ("")
248EXPECT
249printf (...) interpreted as function at - line 3.
250########
251# toke.c
252use warning 'syntax' ;
253sort ("")
254EXPECT
255sort (...) interpreted as function at - line 3.
256########
257# toke.c
258use warning 'ambiguous' ;
259$a = ${time[2]};
260EXPECT
261Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
262########
263# toke.c
264use warning 'ambiguous' ;
265$a = ${time{2}};
266EXPECT
267Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
268########
269# toke.c
270use warning 'ambiguous' ;
271$a = ${time} ;
272EXPECT
273Ambiguous use of ${time} resolved to $time at - line 3.
274########
275# toke.c
276use warning 'ambiguous' ;
277sub fred {}
278$a = ${fred} ;
279EXPECT
280Ambiguous use of ${fred} resolved to $fred at - line 4.
281########
282# toke.c
283use warning 'syntax' ;
284$a = 1_2;
285$a = 1_2345_6;
286EXPECT
287Misplaced _ in number at - line 3.
288Misplaced _ in number at - line 4.
289Misplaced _ in number at - line 4.
290########
291# toke.c
292use warning 'unsafe' ;
60e6418e 293#line 25 "bar"
599cee73 294$a = FRED:: ;
295EXPECT
60e6418e 296Bareword "FRED::" refers to nonexistent package at bar line 25.
599cee73 297########
298# toke.c
299use warning 'ambiguous' ;
300sub time {}
301my $a = time()
302EXPECT
303Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
304########
305# toke.c
306use warning 'utf8' ;
60e6418e 307eval <<'EOE';
308{
309#line 30 "foo"
310 $_ = " \x{123} " ;
311}
312EOE
599cee73 313EXPECT
60e6418e 314Use of \x{} without utf8 declaration at foo line 30.
599cee73 315########
316# toke.c
317use warning 'utf8' ;
318use utf8 ;
319$_ = " \xffe " ;
320EXPECT
321\xff will produce malformed UTF-8 character; use \x{ff} for that at - line 4.