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