Blame t/seek.t

Packit be0f65
print "1..10\n";
Packit be0f65
Packit be0f65
$str = "abcd";
Packit be0f65
Packit be0f65
#$IO::String::DEBUG++;
Packit be0f65
Packit be0f65
use IO::String;
Packit be0f65
$io = IO::String->new($str);
Packit be0f65
Packit be0f65
sub all_pos
Packit be0f65
{
Packit be0f65
   my($io, $expect) = @_;
Packit be0f65
   $io->getpos == $expect &&
Packit be0f65
   $io->pos    == $expect &&
Packit be0f65
   $io->tell   == $expect &&
Packit be0f65
   $io->seek(0, 1) == $expect &&
Packit be0f65
   $io->sysseek(0, 1) == $expect &&
Packit be0f65
   $] >= 5.006 ? ( tell($io) == $expect &&
Packit be0f65
      	           seek($io, 0, 1) == $expect &&
Packit be0f65
                   sysseek($io, 0, 1) == $expect
Packit be0f65
                 )
Packit be0f65
               : 1;
Packit be0f65
}
Packit be0f65
Packit be0f65
print "not " unless all_pos($io, 0);
Packit be0f65
print "ok 1\n";
Packit be0f65
Packit be0f65
$io->setpos(2);
Packit be0f65
print "not " unless all_pos($io, 2);
Packit be0f65
print "ok 2\n";
Packit be0f65
Packit be0f65
$io->setpos(10);  # XXX should it be defined in terms of seek??
Packit be0f65
print "not " unless all_pos($io, 4);
Packit be0f65
print "ok 3\n";
Packit be0f65
Packit be0f65
$io->seek(10, 0);
Packit be0f65
print "not " unless all_pos($io, 10);
Packit be0f65
print "ok 4\n";
Packit be0f65
Packit be0f65
$io->print("זרו");
Packit be0f65
print "not " unless all_pos($io, 13);
Packit be0f65
print "ok 5\n";
Packit be0f65
Packit be0f65
$io->seek(-4, 2);
Packit be0f65
print "not " unless all_pos($io, 9);
Packit be0f65
print "ok 6\n";
Packit be0f65
Packit be0f65
print "not " unless $io->read($buf, 20) == 4 && $buf eq "\0זרו";
Packit be0f65
print "ok 7\n";
Packit be0f65
Packit be0f65
print "not " unless $io->seek(-10,1) && all_pos($io, 3);
Packit be0f65
print "ok 8\n";
Packit be0f65
Packit be0f65
$io->seek(0,0);
Packit be0f65
print "not " unless all_pos($io, 0);
Packit be0f65
print "ok 9\n";
Packit be0f65
Packit be0f65
if ($] >= 5.006) {
Packit be0f65
   seek($io, 1, 0);
Packit be0f65
   print "not " unless all_pos($io, 1);
Packit be0f65
}
Packit be0f65
print "ok 10\n";
Packit be0f65