This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Scalar-List-Utils to CPAN version 1.26
[perl5.git] / cpan / IO-Zlib / t / getline.t
CommitLineData
8d0ec8cf
RGS
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
82d8f834 16print "1..23\n";
8d0ec8cf
RGS
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"));
82d8f834
SP
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());
8d0ec8cf 46eval '$file->getlines';
82d8f834
SP
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());
8d0ec8cf
RGS
56
57unlink($name);