blob: a2671f749aad2f254cb94e59042761d9d5f198f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
use lib 't';
use strict;
use warnings;
use bytes;
use Test::More ;
use ZlibTestUtils;
BEGIN
{
plan(skip_all => "Destroy not supported in Perl $]")
if $] == 5.008 || ( $] >= 5.005 && $] < 5.006) ;
# use Test::NoWarnings, if available
my $extra = 0 ;
$extra = 1
if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
plan tests => 23 + $extra ;
use_ok('IO::Compress::Gzip', qw($GzipError)) ;
use_ok('IO::Compress::Deflate', qw($DeflateError)) ;
use_ok('IO::Uncompress::AnyInflate', qw($AnyInflateError)) ;
use_ok('IO::Compress::RawDeflate', qw($RawDeflateError)) ;
use_ok('IO::File') ;
}
foreach my $CompressClass ('IO::Compress::Gzip',
'IO::Compress::Deflate',
'IO::Compress::RawDeflate')
{
title "Testing $CompressClass";
{
# Check that the class destructor will call close
my $name = "test.gz" ;
unlink $name ;
my $lex = new LexFile $name ;
my $hello = <<EOM ;
hello world
this is a test
EOM
{
ok my $x = new $CompressClass $name, -AutoClose => 1 ;
ok $x->write($hello) ;
}
is anyUncompress($name), $hello ;
}
{
# Tied filehandle destructor
my $name = "test.gz" ;
my $lex = new LexFile $name ;
my $hello = <<EOM ;
hello world
this is a test
EOM
my $fh = new IO::File "> $name" ;
{
ok my $x = new $CompressClass $fh, -AutoClose => 1 ;
$x->write($hello) ;
}
ok anyUncompress($name) eq $hello ;
}
}
|