1BEGIN { 2 if ($ENV{PERL_CORE}) { 3 chdir 't' if -d 't'; 4 @INC = ("../lib", "lib/compress"); 5 } 6} 7 8use lib qw(t t/compress); 9use strict; 10use warnings; 11use bytes; 12 13use Test::More ; 14use CompTestUtils; 15use Data::Dumper; 16 17use IO::Compress::Zip qw($ZipError); 18use IO::Uncompress::Unzip qw($UnzipError); 19 20BEGIN { 21 plan skip_all => "Encode is not available" 22 if $] < 5.006 ; 23 24 eval { require Encode; Encode->import(); }; 25 26 plan skip_all => "Encode is not available" 27 if $@ ; 28 29 plan skip_all => "Encode not working in perl $]" 30 if $] >= 5.008 && $] < 5.008004 ; 31 32 # use Test::NoWarnings, if available 33 my $extra = 0 ; 34 $extra = 1 35 if eval { require Test::NoWarnings ; Test::NoWarnings->import; 1 }; 36 37 plan tests => 3 + $extra; 38} 39 40{ 41 title "github-34: Calling nextStream on an IO::Uncompress::Zip object in Transparent mode dies when input is uncompressed"; 42 # https://github.com/pmqs/IO-Compress/issues/34 43 44 my $lex = LexFile->new( my $file1 ); 45 46 writeFile($file1, "1234\n5678\n"); 47 48 my $in = IO::Uncompress::Unzip->new( $file1, 49 AutoClose => 1, 50 Transparent => 1 51 ) or 52 die( "foo.txt: $UnzipError\n" ); 53 54 my $data; 55 my $status; 56 57 # read first stream 58 $data .= $_ 59 while <$in> ; 60 61 is $data, "1234\n5678\n" ; 62 63 # This line triggers the error below without a fix 64 # Can't call method "reset" on an undefined value 65 is $in->nextStream, 0 ; 66} 67