This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
update perldiag for change#4707
[perl5.git] / t / pragma / warn / doio
CommitLineData
767a6a26 1 doio.c
599cee73 2
767a6a26 3 Can't do bidirectional pipe [Perl_do_open9]
599cee73
PM
4 open(F, "| true |");
5
767a6a26 6 Missing command in piped open [Perl_do_open9]
06eaf0bc
GS
7 open(F, "| ");
8
767a6a26 9 Missing command in piped open [Perl_do_open9]
06eaf0bc
GS
10 open(F, " |");
11
767a6a26 12 warn(warn_nl, "open"); [Perl_do_open9]
599cee73
PM
13 open(F, "true\ncd")
14
767a6a26
PM
15 Close on unopened file <%s> [Perl_do_close] <<TODO
16 $a = "fred";close("$a")
599cee73 17
767a6a26 18 tell() on unopened file [Perl_do_tell]
599cee73
PM
19 $a = "fred";$a = tell($a)
20
767a6a26 21 seek() on unopened file [Perl_do_seek]
599cee73
PM
22 $a = "fred";$a = seek($a,1,1)
23
767a6a26 24 sysseek() on unopened file [Perl_do_sysseek]
599cee73
PM
25 $a = "fred";$a = seek($a,1,1)
26
767a6a26 27 warn(warn_uninit); [Perl_do_print]
599cee73
PM
28 print $a ;
29
767a6a26 30 Stat on unopened file <%s> [Perl_my_stat]
599cee73
PM
31 close STDIN ; -x STDIN ;
32
767a6a26 33 warn(warn_nl, "stat"); [Perl_my_stat]
599cee73
PM
34 stat "ab\ncd"
35
767a6a26 36 warn(warn_nl, "lstat"); [Perl_my_lstat]
599cee73
PM
37 lstat "ab\ncd"
38
767a6a26 39 Can't exec \"%s\": %s [Perl_do_aexec5]
599cee73 40
767a6a26 41 Can't exec \"%s\": %s [Perl_do_exec3]
599cee73 42
767a6a26
PM
43 Filehandle %s opened only for output [Perl_do_eof]
44 my $a = eof STDOUT
599cee73 45
0453d815
PM
46 Mandatory Warnings ALL TODO
47 ------------------
767a6a26 48 Can't do inplace edit: %s is not a regular file [Perl_nextargv]
0453d815
PM
49 edit a directory
50
767a6a26
PM
51 Can't do inplace edit: %s would not be unique [Perl_nextargv]
52 Can't rename %s to %s: %s, skipping file [Perl_nextargv]
53 Can't rename %s to %s: %s, skipping file [Perl_nextargv]
54 Can't remove %s: %s, skipping file [Perl_nextargv]
55 Can't do inplace edit on %s: %s [Perl_nextargv]
0453d815
PM
56
57
599cee73 58__END__
767a6a26 59# doio.c [Perl_do_open9]
4438c4b7 60use warnings 'io' ;
3eeba6fb
CB
61open(F, '|'.($^O eq 'VMS' ? 'mcr ':'')."$^X -e 1|");
62close(F);
4438c4b7 63no warnings 'io' ;
0453d815
PM
64open(G, '|'.($^O eq 'VMS' ? 'mcr ':'')."$^X -e 1|");
65close(G);
599cee73
PM
66EXPECT
67Can't do bidirectional pipe at - line 3.
68########
767a6a26 69# doio.c [Perl_do_open9]
4438c4b7 70use warnings 'io' ;
0453d815 71open(F, "| ");
4438c4b7 72no warnings 'io' ;
0453d815 73open(G, "| ");
06eaf0bc
GS
74EXPECT
75Missing command in piped open at - line 3.
76########
767a6a26 77# doio.c [Perl_do_open9]
4438c4b7 78use warnings 'io' ;
0453d815 79open(F, " |");
4438c4b7 80no warnings 'io' ;
0453d815 81open(G, " |");
06eaf0bc
GS
82EXPECT
83Missing command in piped open at - line 3.
84########
767a6a26 85# doio.c [Perl_do_open9]
4438c4b7 86use warnings 'io' ;
0453d815 87open(F, "<true\ncd");
4438c4b7 88no warnings 'io' ;
0453d815 89open(G, "<true\ncd");
599cee73
PM
90EXPECT
91Unsuccessful open on filename containing newline at - line 3.
92########
767a6a26
PM
93# doio.c [Perl_do_close] <<TODO
94use warnings 'unopened' ;
95close "fred" ;
96no warnings 'unopened' ;
97close "joe" ;
98EXPECT
99Close on unopened file <fred> at - line 3.
100########
101# doio.c [Perl_do_tell Perl_do_seek Perl_do_sysseek Perl_my_stat]
4438c4b7 102use warnings 'io' ;
599cee73
PM
103close STDIN ;
104tell(STDIN);
105$a = seek(STDIN,1,1);
106$a = sysseek(STDIN,1,1);
107-x STDIN ;
4438c4b7 108no warnings 'io' ;
0453d815
PM
109close STDIN ;
110tell(STDIN);
111$a = seek(STDIN,1,1);
112$a = sysseek(STDIN,1,1);
113-x STDIN ;
599cee73
PM
114EXPECT
115tell() on unopened file at - line 4.
116seek() on unopened file at - line 5.
117sysseek() on unopened file at - line 6.
118Stat on unopened file <STDIN> at - line 7.
119########
767a6a26 120# doio.c [Perl_do_print]
4438c4b7 121use warnings 'uninitialized' ;
599cee73 122print $a ;
4438c4b7 123no warnings 'uninitialized' ;
0453d815 124print $b ;
599cee73 125EXPECT
b89fed5f 126Use of uninitialized value in print at - line 3.
599cee73 127########
767a6a26 128# doio.c [Perl_my_stat Perl_my_lstat]
4438c4b7 129use warnings 'io' ;
599cee73
PM
130stat "ab\ncd";
131lstat "ab\ncd";
4438c4b7 132no warnings 'io' ;
0453d815
PM
133stat "ab\ncd";
134lstat "ab\ncd";
599cee73
PM
135EXPECT
136Unsuccessful stat on filename containing newline at - line 3.
137Unsuccessful stat on filename containing newline at - line 4.
138########
767a6a26 139# doio.c [Perl_do_aexec5]
4438c4b7 140use warnings 'io' ;
dfe13c55 141exec "lskdjfalksdjfdjfkls","" ;
4438c4b7 142no warnings 'io' ;
0453d815 143exec "lskdjfalksdjfdjfkls","" ;
599cee73 144EXPECT
e5e1b98b 145OPTION regex
c4f6c246 146Can't exec "lskdjfalksdjfdjfkls": .+
599cee73 147########
767a6a26 148# doio.c [Perl_do_exec3]
4438c4b7 149use warnings 'io' ;
599cee73 150exec "lskdjfalksdjfdjfkls", "abc" ;
4438c4b7 151no warnings 'io' ;
0453d815 152exec "lskdjfalksdjfdjfkls", "abc" ;
599cee73 153EXPECT
e5e1b98b 154OPTION regex
3eeba6fb 155Can't exec "lskdjfalksdjfdjfkls(:? abc)?": .+
0453d815 156########
767a6a26 157# doio.c [Perl_nextargv]
0453d815
PM
158$^W = 0 ;
159my $filename = "./temp" ;
160mkdir $filename, 0777
161 or die "Cannot create directory $filename: $!\n" ;
162{
163 local (@ARGV) = ($filename) ;
164 local ($^I) = "" ;
165 my $x = <> ;
166}
167{
4438c4b7 168 no warnings 'inplace' ;
0453d815
PM
169 local (@ARGV) = ($filename) ;
170 local ($^I) = "" ;
171 my $x = <> ;
172}
173{
4438c4b7 174 use warnings 'inplace' ;
0453d815
PM
175 local (@ARGV) = ($filename) ;
176 local ($^I) = "" ;
177 my $x = <> ;
178}
179rmdir $filename ;
180EXPECT
181Can't do inplace edit: ./temp is not a regular file at - line 9.
182Can't do inplace edit: ./temp is not a regular file at - line 21.
183
767a6a26
PM
184########
185# doio.c [Perl_do_eof]
186use warnings 'io' ;
187my $a = eof STDOUT ;
188no warnings 'io' ;
189$a = eof STDOUT ;
190EXPECT
191Filehandle main::STDOUT opened only for output at - line 3.