Updated as part of DB_File update
[p5sagit/p5-mst-13.2.git] / t / lib / filehand.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     require Config; import Config;
7     if ($Config{'extensions'} !~ /\bFileHandle\b/ && $^O ne 'VMS') {
8         print "1..0\n";
9         exit 0;
10     }
11 }
12
13 use FileHandle;
14 use strict subs;
15
16 $mystdout = new_from_fd FileHandle 1,"w";
17 autoflush STDOUT;
18 autoflush $mystdout;
19 print "1..4\n";
20
21 print $mystdout "ok ",fileno($mystdout),"\n";
22
23 $fh = new FileHandle "TEST", O_RDONLY and print "ok 2\n";
24 $buffer = <$fh>;
25 print $buffer eq "#!./perl\n" ? "ok 3\n" : "not ok 3\n";
26
27 if ($^O eq 'VMS') {
28     ungetc $fh 65;
29     CORE::read($fh, $buf,1);
30 }
31 else {
32     ungetc STDIN 65;
33     CORE::read(STDIN, $buf,1);
34 }
35 print $buf eq 'A' ? "ok 4\n" : "not ok 4\n";