Commit | Line | Data |
8d063cd8 |
1 | #!./perl |
2 | |
455ece5e |
3 | # $RCSfile: tell.t,v $$Revision$$Date$ |
8d063cd8 |
4 | |
d26ab924 |
5 | print "1..23\n"; |
8d063cd8 |
6 | |
378cc40b |
7 | $TST = 'tst'; |
8 | |
8736538c |
9 | $Is_Dosish = ($^O eq 'MSWin32' or $^O eq 'dos' or |
b82baff6 |
10 | $^O eq 'os2' or $^O eq 'mint' or $^O eq 'cygwin'); |
8736538c |
11 | |
2eb25c99 |
12 | open($TST, 'harness') || (die "Can't open harness"); |
8736538c |
13 | binmode $TST if $Is_Dosish; |
8d063cd8 |
14 | if (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; |
20 | while (<tst>) { |
21 | if (eof) {$x++;} |
22 | } |
23 | if ($x == 1) { print "ok 2\n"; } else { print "not ok 2\n"; } |
24 | |
25 | $lastpos = tell; |
26 | |
27 | unless (eof) { print "not ok 3\n"; } else { print "ok 3\n"; } |
28 | |
378cc40b |
29 | if (seek($TST,0,0)) { print "ok 4\n"; } else { print "not ok 4\n"; } |
8d063cd8 |
30 | |
31 | if (eof) { print "not ok 5\n"; } else { print "ok 5\n"; } |
32 | |
33 | if ($firstline eq <tst>) { print "ok 6\n"; } else { print "not ok 6\n"; } |
34 | |
35 | if ($secondpos == tell) { print "ok 7\n"; } else { print "not ok 7\n"; } |
36 | |
37 | if (seek(tst,0,1)) { print "ok 8\n"; } else { print "not ok 8\n"; } |
38 | |
378cc40b |
39 | if (eof($TST)) { print "not ok 9\n"; } else { print "ok 9\n"; } |
8d063cd8 |
40 | |
41 | if ($secondpos == tell) { print "ok 10\n"; } else { print "not ok 10\n"; } |
42 | |
43 | if (seek(tst,0,2)) { print "ok 11\n"; } else { print "not ok 11\n"; } |
44 | |
45 | if ($lastpos == tell) { print "ok 12\n"; } else { print "not ok 12\n"; } |
46 | |
47 | unless (eof) { print "not ok 13\n"; } else { print "ok 13\n"; } |
455ece5e |
48 | |
49 | if ($. == 0) { print "not ok 14\n"; } else { print "ok 14\n"; } |
50 | |
51 | $curline = $.; |
2eb25c99 |
52 | open(other, 'harness') || (die "Can't open harness: $!"); |
455ece5e |
53 | binmode other if $^O eq 'MSWin32'; |
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 | |
68 | if ($. == $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 | |
77 | if ($. == $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 | |
86 | close(other); |
87 | if (tell(other) == -1) { print "ok 22\n"; } else { print "not ok 22\n"; } |
88 | |
89 | if (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 | |