source: trunk/essentials/dev-lang/perl/t/lib/warnings/doio@ 3951

Last change on this file since 3951 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 6.4 KB
Line 
1 doio.c
2
3 Can't open bidirectional pipe [Perl_do_open9]
4 open(F, "| true |");
5
6 Missing command in piped open [Perl_do_open9]
7 open(F, "| ");
8
9 Missing command in piped open [Perl_do_open9]
10 open(F, " |");
11
12 warn(warn_nl, "open"); [Perl_do_open9]
13 open(F, "true\ncd")
14
15 close() on unopened filehandle %s [Perl_do_close]
16 $a = "fred";close("$a")
17
18 tell() on closed filehandle [Perl_do_tell]
19 $a = "fred";$a = tell($a)
20
21 seek() on closed filehandle [Perl_do_seek]
22 $a = "fred";$a = seek($a,1,1)
23
24 sysseek() on closed filehandle [Perl_do_sysseek]
25 $a = "fred";$a = seek($a,1,1)
26
27 warn(warn_uninit); [Perl_do_print]
28 print $a ;
29
30 -x on closed filehandle %s [Perl_my_stat]
31 close STDIN ; -x STDIN ;
32
33 warn(warn_nl, "stat"); [Perl_my_stat]
34 stat "ab\ncd"
35
36 warn(warn_nl, "lstat"); [Perl_my_lstat]
37 lstat "ab\ncd"
38
39 Use of -l on filehandle %s [Perl_my_lstat]
40
41 Can't exec \"%s\": %s [Perl_do_aexec5]
42
43 Can't exec \"%s\": %s [Perl_do_exec3]
44
45 Filehandle %s opened only for output [Perl_do_eof]
46 my $a = eof STDOUT
47
48 Mandatory Warnings ALL TODO
49 ------------------
50 Can't do inplace edit: %s is not a regular file [Perl_nextargv]
51 edit a directory
52
53 Can't do inplace edit: %s would not be unique [Perl_nextargv]
54 Can't rename %s to %s: %s, skipping file [Perl_nextargv]
55 Can't rename %s to %s: %s, skipping file [Perl_nextargv]
56 Can't remove %s: %s, skipping file [Perl_nextargv]
57 Can't do inplace edit on %s: %s [Perl_nextargv]
58
59
60__END__
61# doio.c [Perl_do_open9]
62use warnings 'io' ;
63open(F, '|'.($^O eq 'VMS' ? 'mcr ':'')."$^X -e 1|");
64close(F);
65no warnings 'io' ;
66open(G, '|'.($^O eq 'VMS' ? 'mcr ':'')."$^X -e 1|");
67close(G);
68EXPECT
69Can't open bidirectional pipe at - line 3.
70########
71# doio.c [Perl_do_open9]
72use warnings 'io' ;
73open(F, "| ");
74no warnings 'io' ;
75open(G, "| ");
76EXPECT
77Missing command in piped open at - line 3.
78########
79# doio.c [Perl_do_open9]
80use warnings 'io' ;
81open(F, " |");
82no warnings 'io' ;
83open(G, " |");
84EXPECT
85Missing command in piped open at - line 3.
86########
87# doio.c [Perl_do_open9]
88use warnings 'io' ;
89open(F, "<true\ncd");
90no warnings 'io' ;
91open(G, "<true\ncd");
92EXPECT
93Unsuccessful open on filename containing newline at - line 3.
94########
95# doio.c [Perl_do_close] <<TODO
96use warnings 'unopened' ;
97close "fred" ;
98no warnings 'unopened' ;
99close "joe" ;
100EXPECT
101close() on unopened filehandle fred at - line 3.
102########
103# doio.c [Perl_do_tell Perl_do_seek Perl_do_sysseek Perl_my_stat]
104use warnings 'io' ;
105close STDIN ;
106tell(STDIN);
107$a = seek(STDIN,1,1);
108$a = sysseek(STDIN,1,1);
109-x STDIN ;
110stat(STDIN) ;
111$a = "fred";
112tell($a);
113seek($a,1,1);
114sysseek($a,1,1);
115-x $a; # ok
116stat($a); # ok
117no warnings 'io' ;
118close STDIN ;
119tell(STDIN);
120$a = seek(STDIN,1,1);
121$a = sysseek(STDIN,1,1);
122-x STDIN ;
123stat(STDIN) ;
124$a = "fred";
125tell($a);
126seek($a,1,1);
127sysseek($a,1,1);
128-x $a;
129stat($a);
130EXPECT
131tell() on closed filehandle STDIN at - line 4.
132seek() on closed filehandle STDIN at - line 5.
133sysseek() on closed filehandle STDIN at - line 6.
134-x on closed filehandle STDIN at - line 7.
135stat() on closed filehandle STDIN at - line 8.
136tell() on unopened filehandle at - line 10.
137seek() on unopened filehandle at - line 11.
138sysseek() on unopened filehandle at - line 12.
139########
140# doio.c [Perl_do_print]
141use warnings 'uninitialized' ;
142print $a ;
143no warnings 'uninitialized' ;
144print $b ;
145EXPECT
146Use of uninitialized value in print at - line 3.
147########
148# doio.c [Perl_my_stat Perl_my_lstat]
149use warnings 'io' ;
150stat "ab\ncd";
151lstat "ab\ncd";
152no warnings 'io' ;
153stat "ab\ncd";
154lstat "ab\ncd";
155EXPECT
156Unsuccessful stat on filename containing newline at - line 3.
157Unsuccessful stat on filename containing newline at - line 4.
158########
159# doio.c [Perl_my_stat]
160use warnings 'io';
161-l STDIN;
162-l $fh;
163open $fh, $0 or die "# $!";
164-l $fh;
165no warnings 'io';
166-l STDIN;
167-l $fh;
168close $fh;
169EXPECT
170Use of -l on filehandle STDIN at - line 3.
171Use of -l on filehandle $fh at - line 6.
172########
173# doio.c [Perl_do_aexec5]
174BEGIN {
175 if ($^O eq 'MacOS') {
176 print <<EOM;
177SKIPPED
178# no exec on Mac OS
179EOM
180 exit;
181 }
182}
183use warnings 'io' ;
184exec "lskdjfalksdjfdjfkls","" ;
185no warnings 'io' ;
186exec "lskdjfalksdjfdjfkls","" ;
187EXPECT
188OPTION regex
189Can't exec "lskdjfalksdjfdjfkls": .+
190########
191# doio.c [Perl_do_exec3]
192BEGIN {
193 if ($^O eq 'MacOS') {
194 print <<EOM;
195SKIPPED
196# no exec on Mac OS
197EOM
198 exit;
199 }
200}
201use warnings 'io' ;
202exec "lskdjfalksdjfdjfkls", "abc" ;
203no warnings 'io' ;
204exec "lskdjfalksdjfdjfkls", "abc" ;
205EXPECT
206OPTION regex
207Can't exec "lskdjfalksdjfdjfkls(:? abc)?": .+
208########
209# doio.c [win32_execvp]
210BEGIN {
211 if ($^O eq 'MacOS') {
212 print <<EOM;
213SKIPPED
214# no exec on Mac OS
215EOM
216 exit;
217 }
218}
219use warnings 'exec' ;
220exec $^X, "-e0" ;
221EXPECT
222########
223# doio.c [Perl_nextargv]
224$^W = 0 ;
225my $filename = "./temp.dir" ;
226mkdir $filename, 0777
227 or die "Cannot create directory $filename: $!\n" ;
228{
229 local (@ARGV) = ($filename) ;
230 local ($^I) = "" ;
231 my $x = <> ;
232}
233{
234 no warnings 'inplace' ;
235 local (@ARGV) = ($filename) ;
236 local ($^I) = "" ;
237 my $x = <> ;
238}
239{
240 use warnings 'inplace' ;
241 local (@ARGV) = ($filename) ;
242 local ($^I) = "" ;
243 my $x = <> ;
244}
245rmdir $filename ;
246EXPECT
247Can't do inplace edit: ./temp.dir is not a regular file at - line 9.
248Can't do inplace edit: ./temp.dir is not a regular file at - line 21.
249
250########
251# doio.c [Perl_do_eof]
252use warnings 'io' ;
253my $a = eof STDOUT ;
254no warnings 'io' ;
255$a = eof STDOUT ;
256EXPECT
257Filehandle STDOUT opened only for output at - line 3.
258########
259# doio.c [Perl_do_openn]
260use Config;
261BEGIN {
262 if ($Config{useperlio}) {
263 print <<EOM;
264SKIPPED
265# warns only without perlio
266EOM
267 exit;
268 }
269}
270use warnings 'io';
271my $x = "foo";
272open FOO, '>', \$x;
273open BAR, '>&', \*STDOUT; # should not warn
274no warnings 'io';
275open FOO, '>', \$x;
276EXPECT
277Can't open a reference at - line 14.
278########
279# doio.c [Perl_do_openn]
280use Config;
281BEGIN {
282 if (!$Config{useperlio}) {
283 print <<EOM;
284SKIPPED
285# warns only with perlio
286EOM
287 exit;
288 }
289}
290use warnings 'io' ;
291close STDOUT;
292open FH1, "harness"; close FH1;
293no warnings 'io' ;
294open FH2, "harness"; close FH2;
295EXPECT
296Filehandle STDOUT reopened as FH1 only for input at - line 14.
297########
298# doio.c [Perl_do_openn]
299use Config;
300BEGIN {
301 if (!$Config{useperlio}) {
302 print <<EOM;
303SKIPPED
304# warns only with perlio
305EOM
306 exit;
307 }
308}
309use warnings 'io' ;
310close STDIN;
311open my $fh1, ">doiowarn.tmp"; close $fh1;
312no warnings 'io' ;
313open my $fh2, ">doiowarn.tmp"; close $fh2;
314unlink "doiowarn.tmp";
315EXPECT
316Filehandle STDIN reopened as $fh1 only for output at - line 14.
Note: See TracBrowser for help on using the repository browser.