summaryrefslogtreecommitdiff
path: root/t/pragma/warn/doio
blob: 5bcca8d78c9d77dad2913ba5d1d335cb8b3065c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
  doio.c	AOK

  Can't do bidirectional pipe
    open(F, "| true |");

  Missing command in piped open
    open(F, "| ");

  Missing command in piped open
    open(F, " |");

  warn(warn_nl, "open");
    open(F, "true\ncd")

  Close on unopened file <%s>
    $a = "fred";close($a)

  tell() on unopened file
    $a = "fred";$a = tell($a)

  seek() on unopened file
    $a = "fred";$a = seek($a,1,1)

  sysseek() on unopened file
    $a = "fred";$a = seek($a,1,1)

  warn(warn_uninit);
    print $a ;

  Stat on unopened file <%s> 
    close STDIN ; -x STDIN ;

  warn(warn_nl, "stat");
    stat "ab\ncd"

  warn(warn_nl, "lstat");
    lstat "ab\ncd"

  Can't exec \"%s\": %s 

  Can't exec \"%s\": %s 


  Mandatory Warnings ALL TODO
  ------------------
  Can't do inplace edit: %s is not a regular file
     edit a directory

  Can't do inplace edit: %s would not be unique
  Can't rename %s to %s: %s, skipping file
  Can't rename %s to %s: %s, skipping file
  Can't remove %s: %s, skipping file
  Can't do inplace edit on %s: %s
  

__END__
# doio.c
use warning 'io' ;
open(F, '|'.($^O eq 'VMS' ? 'mcr ':'')."$^X -e 1|");
close(F);
no warning 'io' ;
open(G, '|'.($^O eq 'VMS' ? 'mcr ':'')."$^X -e 1|");
close(G);
EXPECT
Can't do bidirectional pipe at - line 3.
########
# doio.c
use warning 'io' ;
open(F, "|      ");
no warning 'io' ;
open(G, "|      ");
EXPECT
Missing command in piped open at - line 3.
########
# doio.c
use warning 'io' ;
open(F, "      |");
no warning 'io' ;
open(G, "      |");
EXPECT
Missing command in piped open at - line 3.
########
# doio.c
use warning 'io' ;
open(F, "<true\ncd");
no warning 'io' ;
open(G, "<true\ncd");
EXPECT
Unsuccessful open on filename containing newline at - line 3.
########
# doio.c
use warning 'io' ;
close STDIN ;
tell(STDIN);
$a = seek(STDIN,1,1);
$a = sysseek(STDIN,1,1);
-x STDIN ;
no warning 'io' ;
close STDIN ;
tell(STDIN);
$a = seek(STDIN,1,1);
$a = sysseek(STDIN,1,1);
-x STDIN ;
EXPECT
tell() on unopened file at - line 4.
seek() on unopened file at - line 5.
sysseek() on unopened file at - line 6.
Stat on unopened file <STDIN> at - line 7.
########
# doio.c
use warning 'uninitialized' ;
print $a ;
no warning 'uninitialized' ;
print $b ;
EXPECT
Use of uninitialized value at - line 3.
########
# doio.c
use warning 'io' ;

EXPECT

########
# doio.c
use warning 'io' ;
stat "ab\ncd";
lstat "ab\ncd";
no warning 'io' ;
stat "ab\ncd";
lstat "ab\ncd";
EXPECT
Unsuccessful stat on filename containing newline at - line 3.
Unsuccessful stat on filename containing newline at - line 4.
########
# doio.c
use warning 'io' ;
exec "lskdjfalksdjfdjfkls","" ;
no warning 'io' ;
exec "lskdjfalksdjfdjfkls","" ;
EXPECT
OPTION regex
Can't exec "lskdjfalksdjfdjfkls": .+
########
# doio.c
use warning 'io' ;
exec "lskdjfalksdjfdjfkls", "abc" ;
no warning 'io' ;
exec "lskdjfalksdjfdjfkls", "abc" ;
EXPECT
OPTION regex
Can't exec "lskdjfalksdjfdjfkls(:? abc)?": .+
########
# doio.c
$^W = 0 ;
my $filename = "./temp" ;
mkdir $filename, 0777 
  or die "Cannot create directory $filename: $!\n" ;
{
    local (@ARGV) = ($filename) ;
    local ($^I) = "" ;
    my $x = <> ;
}
{
    no warning 'inplace' ;
    local (@ARGV) = ($filename) ;
    local ($^I) = "" ;
    my $x = <> ;
}
{
    use warning 'inplace' ;
    local (@ARGV) = ($filename) ;
    local ($^I) = "" ;
    my $x = <> ;
}
rmdir $filename ;
EXPECT
Can't do inplace edit: ./temp is not a regular file at - line 9.
Can't do inplace edit: ./temp is not a regular file at - line 21.