NetWare port from Guruprasad S <SGURUPRASAD@novell.com>.
[p5sagit/p5-mst-13.2.git] / t / io / tell.t
CommitLineData
8d063cd8 1#!./perl
2
455ece5e 3# $RCSfile: tell.t,v $$Revision$$Date$
8d063cd8 4
d26ab924 5print "1..23\n";
8d063cd8 6
378cc40b 7$TST = 'tst';
8
2986a63f 9$Is_Dosish = ($^O eq 'MSWin32' or $^O eq 'NetWare' or $^O eq 'dos' or
b82baff6 10 $^O eq 'os2' or $^O eq 'mint' or $^O eq 'cygwin');
8736538c 11
2eb25c99 12open($TST, 'harness') || (die "Can't open harness");
8736538c 13binmode $TST if $Is_Dosish;
8d063cd8 14if (eof(tst)) { print "not ok 1\n"; } else { print "ok 1\n"; }
15
378cc40b 16$firstline = <$TST>;
8d063cd8 17$secondpos = tell;
18
19$x = 0;
20while (<tst>) {
21 if (eof) {$x++;}
22}
23if ($x == 1) { print "ok 2\n"; } else { print "not ok 2\n"; }
24
25$lastpos = tell;
26
27unless (eof) { print "not ok 3\n"; } else { print "ok 3\n"; }
28
378cc40b 29if (seek($TST,0,0)) { print "ok 4\n"; } else { print "not ok 4\n"; }
8d063cd8 30
31if (eof) { print "not ok 5\n"; } else { print "ok 5\n"; }
32
33if ($firstline eq <tst>) { print "ok 6\n"; } else { print "not ok 6\n"; }
34
35if ($secondpos == tell) { print "ok 7\n"; } else { print "not ok 7\n"; }
36
37if (seek(tst,0,1)) { print "ok 8\n"; } else { print "not ok 8\n"; }
38
378cc40b 39if (eof($TST)) { print "not ok 9\n"; } else { print "ok 9\n"; }
8d063cd8 40
41if ($secondpos == tell) { print "ok 10\n"; } else { print "not ok 10\n"; }
42
43if (seek(tst,0,2)) { print "ok 11\n"; } else { print "not ok 11\n"; }
44
45if ($lastpos == tell) { print "ok 12\n"; } else { print "not ok 12\n"; }
46
47unless (eof) { print "not ok 13\n"; } else { print "ok 13\n"; }
455ece5e 48
49if ($. == 0) { print "not ok 14\n"; } else { print "ok 14\n"; }
50
51$curline = $.;
2eb25c99 52open(other, 'harness') || (die "Can't open harness: $!");
2986a63f 53binmode other if (($^O eq 'MSWin32') || ($^O eq 'NetWare'));
455ece5e 54
55{
56 local($.);
57
58 if ($. == 0) { print "not ok 15\n"; } else { print "ok 15\n"; }
59
60 tell other;
61 if ($. == 0) { print "ok 16\n"; } else { print "not ok 16\n"; }
62
63 $. = 5;
64 scalar <other>;
65 if ($. == 6) { print "ok 17\n"; } else { print "not ok 17\n"; }
66}
67
68if ($. == $curline) { print "ok 18\n"; } else { print "not ok 18\n"; }
69
70{
71 local($.);
72
73 scalar <other>;
74 if ($. == 7) { print "ok 19\n"; } else { print "not ok 19\n"; }
75}
76
77if ($. == $curline) { print "ok 20\n"; } else { print "not ok 20\n"; }
78
79{
80 local($.);
81
82 tell other;
83 if ($. == 7) { print "ok 21\n"; } else { print "not ok 21\n"; }
84}
d26ab924 85
86close(other);
87if (tell(other) == -1) { print "ok 22\n"; } else { print "not ok 22\n"; }
88
89if (tell(ether) == -1) { print "ok 23\n"; } else { print "not ok 23\n"; }
90
91# ftell(STDIN) (or any std streams) is undefined, it can return -1 or
92# something else. ftell() on pipes, fifos, and sockets is defined to
93# return -1.
94