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