File: 113issues.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (66 lines) | stat: -rw-r--r-- 1,576 bytes parent folder | download | duplicates (3)
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
BEGIN {
    if ($ENV{PERL_CORE}) {
        chdir 't' if -d 't';
        @INC = ("../lib", "lib/compress");
    }
}

use lib qw(t t/compress);
use strict;
use warnings;
use bytes;

use Test::More ;
use CompTestUtils;
use Data::Dumper;

use IO::Compress::Zip     qw($ZipError);
use IO::Uncompress::Unzip qw($UnzipError);

BEGIN {
    plan skip_all => "Encode is not available"
        if $] < 5.006 ;

    eval { require Encode; Encode->import(); };

    plan skip_all => "Encode is not available"
        if $@ ;

    plan skip_all => "Encode not working in perl $]"
        if $] >= 5.008 && $] < 5.008004 ;

    # use Test::NoWarnings, if available
    my $extra = 0 ;
    $extra = 1
        if eval { require Test::NoWarnings ;  Test::NoWarnings->import; 1 };

    plan tests => 3 + $extra;
}

{
    title "github-34: Calling nextStream on an IO::Uncompress::Zip object in Transparent mode dies when input is uncompressed";
    # https://github.com/pmqs/IO-Compress/issues/34

    my $lex = LexFile->new( my $file1 );

    writeFile($file1, "1234\n5678\n");

    my $in = IO::Uncompress::Unzip->new( $file1,
                                        AutoClose => 1,
                                        Transparent => 1
                                     ) or
        die( "foo.txt: $UnzipError\n" );

    my $data;
    my $status;

    # read first stream
    $data .= $_
        while <$in> ;

    is $data, "1234\n5678\n" ;

    # This line triggers the error below without a fix
    #     Can't call method "reset" on an undefined value
    is $in->nextStream, 0 ;
}