12 $Is_Dosish = ($^O eq 'MSWin32' or $^O eq 'NetWare' or $^O eq 'dos' or
13 $^O eq 'os2' or $^O eq 'mint' or $^O eq 'cygwin' or
16 open($TST, 'harness') || (die "Can't open harness");
17 binmode $TST if $Is_Dosish;
18 if (eof(TST)) { print "not ok 1\n"; } else { print "ok 1\n"; }
27 if ($x == 1) { print "ok 2\n"; } else { print "not ok 2\n"; }
31 unless (eof) { print "not ok 3\n"; } else { print "ok 3\n"; }
33 if (seek($TST,0,0)) { print "ok 4\n"; } else { print "not ok 4\n"; }
35 if (eof) { print "not ok 5\n"; } else { print "ok 5\n"; }
37 if ($firstline eq <TST>) { print "ok 6\n"; } else { print "not ok 6\n"; }
39 if ($secondpos == tell) { print "ok 7\n"; } else { print "not ok 7\n"; }
41 if (seek(TST,0,1)) { print "ok 8\n"; } else { print "not ok 8\n"; }
43 if (eof($TST)) { print "not ok 9\n"; } else { print "ok 9\n"; }
45 if ($secondpos == tell) { print "ok 10\n"; } else { print "not ok 10\n"; }
47 if (seek(TST,0,2)) { print "ok 11\n"; } else { print "not ok 11\n"; }
49 if ($lastpos == tell) { print "ok 12\n"; } else { print "not ok 12\n"; }
51 unless (eof) { print "not ok 13\n"; } else { print "ok 13\n"; }
53 if ($. == 0) { print "not ok 14\n"; } else { print "ok 14\n"; }
56 open(OTHER, 'harness') || (die "Can't open harness: $!");
57 binmode OTHER if (($^O eq 'MSWin32') || ($^O eq 'NetWare'));
62 if ($. == 0) { print "not ok 15\n"; } else { print "ok 15\n"; }
65 if ($. == 0) { print "ok 16\n"; } else { print "not ok 16\n"; }
69 if ($. == 6) { print "ok 17\n"; } else { print "not ok 17\n"; }
72 if ($. == $curline) { print "ok 18\n"; } else { print "not ok 18\n"; }
78 if ($. == 7) { print "ok 19\n"; } else { print "not ok 19\n"; }
81 if ($. == $curline) { print "ok 20\n"; } else { print "not ok 20\n"; }
87 if ($. == 7) { print "ok 21\n"; } else { print "not ok 21\n"; }
93 if (tell(OTHER) == -1) { print "ok 22\n"; } else { print "not ok 22\n"; }
96 no warnings 'unopened';
97 if (tell(ETHER) == -1) { print "ok 23\n"; } else { print "not ok 23\n"; }
100 # ftell(STDIN) (or any std streams) is undefined, it can return -1 or
101 # something else. ftell() on pipes, fifos, and sockets is defined to
104 my $written = "tell_write.txt";
106 END { 1 while unlink($written) }
109 open($tst,">$written") || die "Cannot open $written:$!";
110 binmode $tst if $Is_Dosish;
112 if (tell($tst) == 0) { print "ok 24\n"; } else { print "not ok 24\n"; }
116 if (tell($tst) == 5) { print "ok 25\n"; } else { print "not ok 25\n"; }
120 if (tell($tst) == 10) { print "ok 26\n"; } else { print "not ok 26\n"; }
124 open($tst,"+>>$written") || die "Cannot open $written:$!";
125 binmode $tst if $Is_Dosish;
129 # :stdio does not pass these so ignore them for now
131 if (tell($tst) == 0) { print "ok 27\n"; } else { print "not ok 27\n"; }
135 if ($line eq "fred\n") { print "ok 29\n"; } else { print "not ok 29\n"; }
137 if (tell($tst) == 5) { print "ok 30\n"; } else { print "not ok 30\n"; }
143 if (tell($tst) == 15 ||
144 tell($tst) == 5) # unset PERLIO or PERLIO=stdio (e.g. HP-UX, Solaris)
145 { print "ok 27\n"; } else { print "not ok 27\n"; }
149 open($tst,">$written") || die "Cannot open $written:$!";
152 open($tst,">>$written") || die "Cannot open $written:$!";
154 # This test makes a questionable assumption that the file pointer will
155 # be at eof after opening a file but before seeking, reading, or writing.
156 # Only known failure is on cygwin.
157 my $todo = $^O eq "cygwin" && &PerlIO::get_layers($tst) eq 'stdio'
158 && ' # TODO: file pointer not at eof';
161 { print "ok 28$todo\n"; } else { print "not ok 28$todo\n"; }