Commit | Line | Data |
3eb568f1 |
1 | #!./perl |
2 | |
3 | # $RCSfile$ |
853846ea |
4 | $| = 1; |
5 | $^W = 1; |
821b8a23 |
6 | $Is_VMS = $^O eq 'VMS'; |
3eb568f1 |
7 | |
6170680b |
8 | print "1..32\n"; |
3eb568f1 |
9 | |
853846ea |
10 | # my $file tests |
11 | |
6170680b |
12 | { |
a6c40364 |
13 | unlink("afile") if -f "afile"; |
853846ea |
14 | print "$!\nnot " unless open(my $f,"+>afile"); |
3eb568f1 |
15 | print "ok 1\n"; |
a6c40364 |
16 | binmode $f; |
853846ea |
17 | print "not " unless -f "afile"; |
3eb568f1 |
18 | print "ok 2\n"; |
853846ea |
19 | print "not " unless print $f "SomeData\n"; |
3eb568f1 |
20 | print "ok 3\n"; |
853846ea |
21 | print "not " unless tell($f) == 9; |
3eb568f1 |
22 | print "ok 4\n"; |
853846ea |
23 | print "not " unless seek($f,0,0); |
3eb568f1 |
24 | print "ok 5\n"; |
853846ea |
25 | $b = <$f>; |
26 | print "not " unless $b eq "SomeData\n"; |
3eb568f1 |
27 | print "ok 6\n"; |
853846ea |
28 | print "not " unless -f $f; |
29 | print "ok 7\n"; |
30 | eval { die "Message" }; |
31 | # warn $@; |
32 | print "not " unless $@ =~ /<\$f> line 1/; |
33 | print "ok 8\n"; |
34 | print "not " unless close($f); |
35 | print "ok 9\n"; |
36 | unlink("afile"); |
6170680b |
37 | } |
38 | { |
39 | print "# \$!='$!'\nnot " unless open(my $f,'>', 'afile'); |
40 | print "ok 10\n"; |
41 | print $f "a row\n"; |
42 | print "not " unless close($f); |
43 | print "ok 11\n"; |
44 | print "not " unless -s 'afile' < 10; |
45 | print "ok 12\n"; |
46 | } |
47 | { |
48 | print "# \$!='$!'\nnot " unless open(my $f,'>>', 'afile'); |
49 | print "ok 13\n"; |
50 | print $f "a row\n"; |
51 | print "not " unless close($f); |
52 | print "ok 14\n"; |
53 | print "not " unless -s 'afile' > 10; |
54 | print "ok 15\n"; |
55 | } |
56 | { |
57 | print "# \$!='$!'\nnot " unless open(my $f, '<', 'afile'); |
58 | print "ok 16\n"; |
59 | @rows = <$f>; |
60 | print "not " unless @rows == 2; |
61 | print "ok 17\n"; |
62 | print "not " unless close($f); |
63 | print "ok 18\n"; |
64 | } |
65 | { |
66 | print "not " unless -s 'afile' < 20; |
67 | print "ok 19\n"; |
68 | print "# \$!='$!'\nnot " unless open(my $f, '+<', 'afile'); |
69 | print "ok 20\n"; |
70 | @rows = <$f>; |
71 | print "not " unless @rows == 2; |
72 | print "ok 21\n"; |
73 | seek $f, 0, 1; |
74 | print $f "yet another row\n"; |
75 | print "not " unless close($f); |
76 | print "ok 22\n"; |
77 | print "not " unless -s 'afile' > 20; |
78 | print "ok 23\n"; |
79 | |
80 | unlink("afile"); |
81 | } |
d132b95f |
82 | if ($Is_VMS) { for (24..26) { print "ok $_ # skipped: not Unix fork\n"; } } |
821b8a23 |
83 | else { |
6170680b |
84 | print "# \$!='$!'\nnot " unless open(my $f, '-|', <<'EOC'); |
bd4fc1f0 |
85 | ./perl -e "print qq(a row\n); print qq(another row\n)" |
6170680b |
86 | EOC |
87 | print "ok 24\n"; |
88 | @rows = <$f>; |
89 | print "not " unless @rows == 2; |
90 | print "ok 25\n"; |
91 | print "not " unless close($f); |
92 | print "ok 26\n"; |
93 | } |
d132b95f |
94 | if ($Is_VMS) { for (27..30) { print "ok $_ # skipped: not Unix fork\n"; } } |
821b8a23 |
95 | else { |
6170680b |
96 | print "# \$!='$!'\nnot " unless open(my $f, '|-', <<'EOC'); |
bd4fc1f0 |
97 | ./perl -pe "s/^not //" |
6170680b |
98 | EOC |
99 | print "ok 27\n"; |
100 | @rows = <$f>; |
101 | print $f "not ok 28\n"; |
102 | print $f "not ok 29\n"; |
103 | print "#\nnot " unless close($f); |
104 | sleep 1; |
105 | print "ok 30\n"; |
106 | } |
3eb568f1 |
107 | |
6170680b |
108 | eval <<'EOE' and print "not "; |
109 | open my $f, '<&', 'afile'; |
110 | 1; |
111 | EOE |
112 | print "ok 31\n"; |
113 | $@ =~ /Unknown open\(\) mode \'<&\'/ or print "not "; |
114 | print "ok 32\n"; |