As our $_; is forced into main::, it should warn as a redeclaration.
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / doio
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]
62 use warnings 'io' ;
63 open(F, '|'."$^X -e 1|");
64 close(F);
65 no warnings 'io' ;
66 open(G, '|'."$^X -e 1|");
67 close(G);
68 EXPECT
69 Can't open bidirectional pipe at - line 3.
70 ########
71 # doio.c [Perl_do_open9]
72 use warnings 'io' ;
73 open(F, "|      ");
74 no warnings 'io' ;
75 open(G, "|      ");
76 EXPECT
77 Missing command in piped open at - line 3.
78 ########
79 # doio.c [Perl_do_open9]
80 use warnings 'io' ;
81 open(F, "      |");
82 no warnings 'io' ;
83 open(G, "      |");
84 EXPECT
85 Missing command in piped open at - line 3.
86 ########
87 # doio.c [Perl_do_open9]
88 use warnings 'io' ;
89 open(F, "<true\ncd");
90 no warnings 'io' ;
91 open(G, "<true\ncd");
92 EXPECT
93 Unsuccessful open on filename containing newline at - line 3.
94 ########
95 # doio.c [Perl_do_close] <<TODO
96 use warnings 'unopened' ;
97 close "fred" ;
98 no warnings 'unopened' ;
99 close "joe" ;
100 EXPECT
101 close() on unopened filehandle fred at - line 3.
102 ########
103 # doio.c [Perl_do_tell Perl_do_seek Perl_do_sysseek Perl_my_stat]
104 use warnings 'io' ;
105 close STDIN ;
106 tell(STDIN);
107 $a = seek(STDIN,1,1);
108 $a = sysseek(STDIN,1,1);
109 -x STDIN ;
110 stat(STDIN) ;
111 $a = "fred";
112 tell($a);
113 seek($a,1,1);
114 sysseek($a,1,1);
115 -x $a; # ok
116 stat($a); # ok
117 no warnings 'io' ;
118 close STDIN ;
119 tell(STDIN);
120 $a = seek(STDIN,1,1);
121 $a = sysseek(STDIN,1,1);
122 -x STDIN ;
123 stat(STDIN) ;
124 $a = "fred";
125 tell($a);
126 seek($a,1,1);
127 sysseek($a,1,1);
128 -x $a;
129 stat($a);
130 EXPECT
131 tell() on closed filehandle STDIN at - line 4.
132 seek() on closed filehandle STDIN at - line 5.
133 sysseek() on closed filehandle STDIN at - line 6.
134 -x on closed filehandle STDIN at - line 7.
135 stat() on closed filehandle STDIN at - line 8.
136 tell() on unopened filehandle at - line 10.
137 seek() on unopened filehandle at - line 11.
138 sysseek() on unopened filehandle at - line 12.
139 ########
140 # doio.c [Perl_do_print]
141 use warnings 'uninitialized' ;
142 print $a ;
143 no warnings 'uninitialized' ;
144 print $b ;
145 EXPECT
146 Use of uninitialized value $a in print at - line 3.
147 ########
148 # doio.c [Perl_my_stat Perl_my_lstat]
149 use warnings 'io' ;
150 stat "ab\ncd";
151 lstat "ab\ncd";
152 no warnings 'io' ;
153 stat "ab\ncd";
154 lstat "ab\ncd";
155 EXPECT
156 Unsuccessful stat on filename containing newline at - line 3.
157 Unsuccessful stat on filename containing newline at - line 4.
158 ########
159 # doio.c [Perl_my_stat]
160 use warnings 'io';
161 -l STDIN;
162 -l $fh;
163 open $fh, $0 or die "# $!";
164 -l $fh;
165 no warnings 'io';
166 -l STDIN;
167 -l $fh;
168 close $fh;
169 EXPECT
170 Use of -l on filehandle STDIN at - line 3.
171 Use of -l on filehandle $fh at - line 6.
172 ########
173 # doio.c [Perl_do_aexec5]
174 use warnings 'io' ;
175 exec "lskdjfalksdjfdjfkls","" ;
176 no warnings 'io' ;
177 exec "lskdjfalksdjfdjfkls","" ;
178 EXPECT
179 OPTION regex
180 Can't exec "lskdjfalksdjfdjfkls": .+
181 ########
182 # doio.c [Perl_do_exec3]
183 use warnings 'io' ;
184 exec "lskdjfalksdjfdjfkls", "abc" ;
185 no warnings 'io' ;
186 exec "lskdjfalksdjfdjfkls", "abc" ;
187 EXPECT
188 OPTION regex
189 Can't exec "lskdjfalksdjfdjfkls(:? abc)?": .+
190 ########
191 # doio.c [win32_execvp]
192 use warnings 'exec' ;
193 exec $^X, "-e0" ;
194 EXPECT
195 ########
196 # doio.c [Perl_nextargv]
197 $^W = 0 ;
198 my $filename = "./temp.dir" ;
199 mkdir $filename, 0777 
200   or die "Cannot create directory $filename: $!\n" ;
201 {
202     local (@ARGV) = ($filename) ;
203     local ($^I) = "" ;
204     my $x = <> ;
205 }
206 {
207     no warnings 'inplace' ;
208     local (@ARGV) = ($filename) ;
209     local ($^I) = "" ;
210     my $x = <> ;
211 }
212 {
213     use warnings 'inplace' ;
214     local (@ARGV) = ($filename) ;
215     local ($^I) = "" ;
216     my $x = <> ;
217 }
218 rmdir $filename ;
219 EXPECT
220 Can't do inplace edit: ./temp.dir is not a regular file at - line 9.
221 Can't do inplace edit: ./temp.dir is not a regular file at - line 21.
222
223 ########
224 # doio.c [Perl_do_eof]
225 use warnings 'io' ;
226 my $a = eof STDOUT ;
227 no warnings 'io' ;
228 $a = eof STDOUT ;
229 EXPECT
230 Filehandle STDOUT opened only for output at - line 3.
231 ########
232 # doio.c [Perl_do_openn]
233 use Config;
234 BEGIN {
235     if ($Config{useperlio}) {
236         print <<EOM;
237 SKIPPED
238 # warns only without perlio
239 EOM
240         exit;
241     }
242 }
243 use warnings 'io';
244 my $x = "foo";
245 open FOO, '>', \$x;
246 open BAR, '>&', \*STDOUT; # should not warn
247 no warnings 'io';
248 open FOO, '>', \$x;
249 EXPECT
250 Can't open a reference at - line 14.
251 ########
252 # doio.c [Perl_do_openn]
253 use Config;
254 BEGIN {
255     if (!$Config{useperlio}) {
256         print <<EOM;
257 SKIPPED
258 # warns only with perlio
259 EOM
260         exit;
261     }
262 }
263 use warnings 'io' ;
264 close STDOUT;
265 open FH1, "harness"; close FH1;
266 no warnings 'io' ;
267 open FH2, "harness"; close FH2;
268 EXPECT
269 Filehandle STDOUT reopened as FH1 only for input at - line 14.
270 ########
271 # doio.c [Perl_do_openn]
272 use Config;
273 BEGIN {
274     if (!$Config{useperlio}) {
275         print <<EOM;
276 SKIPPED
277 # warns only with perlio
278 EOM
279         exit;
280     }
281 }
282 use warnings 'io' ;
283 close STDIN;
284 open my $fh1, ">doiowarn.tmp"; close $fh1;
285 no warnings 'io' ;
286 open my $fh2, ">doiowarn.tmp"; close $fh2;
287 unlink "doiowarn.tmp";
288 EXPECT
289 Filehandle STDIN reopened as $fh1 only for output at - line 14.