1use IO::Zlib; 2 3sub ok 4{ 5 my ($no, $ok) = @_ ; 6 7 #++ $total ; 8 #++ $totalBad unless $ok ; 9 10 print "ok $no\n" if $ok ; 11 print "not ok $no\n" unless $ok ; 12} 13 14$name="test.gz"; 15 16print "1..23\n"; 17 18@text = (<<EOM, <<EOM, <<EOM, <<EOM) ; 19this is line 1 20EOM 21the second line 22EOM 23the line after the previous line 24EOM 25the final line 26EOM 27 28$text = join("", @text) ; 29 30ok(1, $file = IO::Zlib->new($name, "wb")); 31ok(2, $file->print($text)); 32ok(3, $file->close()); 33 34ok(4, $file = IO::Zlib->new($name, "rb")); 35ok(5, !$file->eof()); 36ok(6, $file->getline() eq $text[0]); 37ok(7, $file->getline() eq $text[1]); 38ok(8, $file->getline() eq $text[2]); 39ok(9, $file->getline() eq $text[3]); 40ok(10, !defined($file->getline())); 41ok(11, $file->eof()); 42ok(12, $file->close()); 43 44ok(13, $file = IO::Zlib->new($name, "rb")); 45ok(14, !$file->eof()); 46eval '$file->getlines'; 47ok(15, $@ =~ /^IO::Zlib::getlines: must be called in list context /); 48ok(16, @lines = $file->getlines()); 49ok(17, @lines == @text); 50ok(18, $lines[0] eq $text[0]); 51ok(19, $lines[1] eq $text[1]); 52ok(20, $lines[2] eq $text[2]); 53ok(21, $lines[3] eq $text[3]); 54ok(22, $file->eof()); 55ok(23, $file->close()); 56 57unlink($name); 58