Commit | Line | Data |
c07a80fd |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = '../lib'; |
6 | require Config; import Config; |
36477c24 |
7 | if ($Config{'extensions'} !~ /\bIO\b/ && $^O ne 'VMS') { |
c07a80fd |
8 | print "1..0\n"; |
9 | exit 0; |
10 | } |
11 | } |
12 | |
13 | use FileHandle; |
14 | use strict subs; |
15 | |
36477c24 |
16 | autoflush STDOUT 1; |
17 | |
c07a80fd |
18 | $mystdout = new_from_fd FileHandle 1,"w"; |
5ef887f5 |
19 | $| = 1; |
c07a80fd |
20 | autoflush $mystdout; |
36477c24 |
21 | print "1..11\n"; |
c07a80fd |
22 | |
23 | print $mystdout "ok ",fileno($mystdout),"\n"; |
24 | |
f86702cc |
25 | $fh = (new FileHandle "./TEST", O_RDONLY |
26 | or new FileHandle "TEST", O_RDONLY) |
27 | and print "ok 2\n"; |
36477c24 |
28 | |
29 | |
c07a80fd |
30 | $buffer = <$fh>; |
31 | print $buffer eq "#!./perl\n" ? "ok 3\n" : "not ok 3\n"; |
32 | |
36477c24 |
33 | |
5ef887f5 |
34 | ungetc $fh 65; |
35 | CORE::read($fh, $buf,1); |
c07a80fd |
36 | print $buf eq 'A' ? "ok 4\n" : "not ok 4\n"; |
36477c24 |
37 | |
38 | close $fh; |
39 | |
40 | $fh = new FileHandle; |
41 | |
42 | print "not " unless ($fh->open("< TEST") && <$fh> eq $buffer); |
43 | print "ok 5\n"; |
44 | |
45 | $fh->seek(0,0); |
46 | print "not " unless (<$fh> eq $buffer); |
47 | print "ok 6\n"; |
48 | |
49 | $fh->seek(0,2); |
50 | $line = <$fh>; |
51 | print "not " if (defined($line) || !$fh->eof); |
52 | print "ok 7\n"; |
53 | |
54 | print "not " unless ($fh->open("TEST","r") && !$fh->tell && $fh->close); |
55 | print "ok 8\n"; |
56 | |
57 | autoflush STDOUT 0; |
58 | |
59 | print "not " if ($|); |
60 | print "ok 9\n"; |
61 | |
62 | autoflush STDOUT 1; |
63 | |
64 | print "not " unless ($|); |
65 | print "ok 10\n"; |
66 | |
67 | ($rd,$wr) = FileHandle::pipe; |
68 | |
774d564b |
69 | if ($^O eq 'VMS' || $^O eq 'os2' || $^O eq 'amigaos') { |
5f05dabc |
70 | $wr->autoflush; |
71 | $wr->printf("ok %d\n",11); |
72 | print $rd->getline; |
36477c24 |
73 | } |
74 | else { |
5f05dabc |
75 | if (fork) { |
76 | $wr->close; |
77 | print $rd->getline; |
78 | } |
79 | else { |
80 | $rd->close; |
81 | $wr->printf("ok %d\n",11); |
82 | exit(0); |
83 | } |
36477c24 |
84 | } |