6 require Config; import Config;
7 if ($Config{'extensions'} !~ /\bIO\b/ && $^O ne 'VMS') {
16 use Test::More (tests => 12);
17 my $TB = Test::More->builder;
19 my $mystdout = new_from_fd FileHandle 1,"w";
23 print $mystdout "ok ".fileno($mystdout),
24 " - ", "create new handle from file descriptor", "\n";
25 $TB->current_test($TB->current_test + 1);
27 my $fh = (new FileHandle "./TEST", O_RDONLY
28 or new FileHandle "TEST", O_RDONLY);
29 ok(defined($fh), "create new handle O_RDONLY");
32 is($buffer, "#!./perl\n", "Got expected first line via handle");
36 CORE::read($fh, $buf,1);
37 is($buf, 'A', "Got expected ordinal value via ungetc in handle's input stream");
41 ok(($fh->open("< TEST") && <$fh> eq $buffer),
42 "FileHandle open() method created handle, which got expected first line");
45 ok((<$fh> eq $buffer), "Averted possible mixed CRLF/LF in t/TEST");
49 ok(! (defined($line) || !$fh->eof), "FileHandle seek() and eof() methods");
51 ok(($fh->open("TEST","r") && !$fh->tell && $fh->close),
52 "FileHandle open(), tell() and close() methods");
55 ok(! $|, "handle not auto-flushing current output channel");
58 ok($|, "handle auto-flushing current output channel");
61 skip "No fork or pipe on DOS", 1 if ($^O eq 'dos');
63 my ($rd,$wr) = FileHandle::pipe;
65 $^O eq 'VMS' || $^O eq 'os2' || $^O eq 'amigaos' ||
66 $^O eq 'MSWin32' || $^O eq 'NetWare' || $Config{d_fork} ne 'define'
68 my $content = "Writing to one end of a pipe, reading from the other\n";
72 is($rd->getline, $content,
73 "Read content from pipe on non-forking platform");
80 is($rd->getline, $content,
81 "Read content from pipe on forking platform");
83 elsif (defined $child) {
90 die "fork failed: $!";
96 ok(!FileHandle->new('', 'r'), "Can't open empty filename");