xref: /openbsd/gnu/usr.bin/perl/dist/IO/t/io_tell.t (revision 09467b48)
1#!./perl
2
3BEGIN {
4    $tell_file = "Makefile.PL";
5}
6
7use Config;
8
9BEGIN {
10    if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bIO\b/ && $^O ne 'VMS') {
11	print "1..0\n";
12	exit 0;
13    }
14}
15
16print "1..13\n";
17
18use IO::File;
19
20$tst = IO::File->new("$tell_file","r") || die("Can't open $tell_file");
21binmode $tst; # its a nop unless it matters. Was only if ($^O eq 'MSWin32' or $^O eq 'dos');
22if ($tst->eof) { print "not ok 1\n"; } else { print "ok 1\n"; }
23
24$firstline = <$tst>;
25$secondpos = tell;
26
27$x = 0;
28while (<$tst>) {
29    if (eof) {$x++;}
30}
31if ($x == 1) { print "ok 2\n"; } else { print "not ok 2\n"; }
32
33$lastpos = tell;
34
35unless (eof) { print "not ok 3\n"; } else { print "ok 3\n"; }
36
37if ($tst->seek(0,0)) { print "ok 4\n"; } else { print "not ok 4\n"; }
38
39if (eof) { print "not ok 5\n"; } else { print "ok 5\n"; }
40
41if ($firstline eq <$tst>) { print "ok 6\n"; } else { print "not ok 6\n"; }
42
43if ($secondpos == tell) { print "ok 7\n"; } else { print "not ok 7\n"; }
44
45if ($tst->seek(0,1)) { print "ok 8\n"; } else { print "not ok 8\n"; }
46
47if ($tst->eof) { print "not ok 9\n"; } else { print "ok 9\n"; }
48
49if ($secondpos == tell) { print "ok 10\n"; } else { print "not ok 10\n"; }
50
51if ($tst->seek(0,2)) { print "ok 11\n"; } else { print "not ok 11\n"; }
52
53if ($lastpos == $tst->tell) { print "ok 12\n"; } else { print "not ok 12\n"; }
54
55unless (eof) { print "not ok 13\n"; } else { print "ok 13\n"; }
56