Compress::Zlib becomes zlib agnostic
[p5sagit/p5-mst-13.2.git] / t / lib / compress / destroy.pl
CommitLineData
642e522c 1
2use lib 't';
3use strict;
4use warnings;
5use bytes;
6
7use Test::More ;
8use ZlibTestUtils;
9
10BEGIN
11{
12 plan(skip_all => "Destroy not supported in Perl $]")
13 if $] == 5.008 || ( $] >= 5.005 && $] < 5.006) ;
14
15 # use Test::NoWarnings, if available
16 my $extra = 0 ;
17 $extra = 1
18 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
19
1a6a8453 20 plan tests => 7 + $extra ;
642e522c 21
642e522c 22 use_ok('IO::File') ;
23}
24
1a6a8453 25sub run
642e522c 26{
642e522c 27
1a6a8453 28 my $CompressClass = identify();
29 my $UncompressClass = getInverse($CompressClass);
30 my $Error = getErrorRef($CompressClass);
31 my $UnError = getErrorRef($UncompressClass);
32
33 title "Testing $CompressClass";
642e522c 34
35 {
36 # Check that the class destructor will call close
37
9f2e3514 38 my $lex = new LexFile my $name ;
642e522c 39
40 my $hello = <<EOM ;
41hello world
42this is a test
43EOM
44
45
46 {
47 ok my $x = new $CompressClass $name, -AutoClose => 1 ;
48
49 ok $x->write($hello) ;
50 }
51
52 is anyUncompress($name), $hello ;
53 }
54
55 {
56 # Tied filehandle destructor
57
58
9f2e3514 59 my $lex = new LexFile my $name ;
642e522c 60
61 my $hello = <<EOM ;
62hello world
63this is a test
64EOM
65
66 my $fh = new IO::File "> $name" ;
67
68 {
69 ok my $x = new $CompressClass $fh, -AutoClose => 1 ;
70
71 $x->write($hello) ;
72 }
73
74 ok anyUncompress($name) eq $hello ;
75 }
76}
77
1a6a8453 781;