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