14 plan(skip_all => "Examples needs Perl 5.005 or better - you have Perl $]" )
17 # use Test::NoWarnings, if available
20 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
22 plan tests => 30 + $extra ;
26 my $Inc = join " ", map qq["-I$_"] => @INC;
27 $Inc = '"-MExtUtils::testlib"'
28 if ! $ENV{PERL_CORE} && eval " require ExtUtils::testlib; " ;
30 my $Perl = ($ENV{'FULLPERL'} or $^X or 'perl') ;
31 $Perl = qq["$Perl"] if $^O eq 'MSWin32' ;
33 $Perl = "$Perl $Inc -w" ;
34 my $examples = $ENV{PERL_CORE} ? "../ext/Compress/Zlib/examples"
47 my @hello1 = grep(s/$/\n/, split(/\n/, $hello1)) ;
60 my @hello2 = grep(s/$/\n/, split(/\n/, $hello2)) ;
62 my $file1 = "hello1.gz" ;
63 my $file2 = "hello2.gz" ;
64 my $stderr = "err.out" ;
67 unlink $file1, $file2 ;
69 my $gz = gzopen($file1, "wb");
70 $gz->gzwrite($hello1);
73 $gz = gzopen($file2, "wb");
74 $gz->gzwrite($hello2);
80 my $expected = shift ;
82 my $stderr = 'err.out';
85 my $cmd = "$command 2>$stderr";
90 $aok &= is $?, 0, " exit status is 0" ;
92 $aok &= is readFile($stderr), '', " no stderr" ;
94 $aok &= is $stdout, $expected, " expected content is ok"
95 if defined $expected ;
98 diag "Command line: $cmd";
99 my ($file, $line) = (caller)[1,2];
100 diag "Test called from $file, line $line";
110 check "$Perl ${examples}/gzcat.zlib $file1 $file2 ", $hello1 . $hello2 ;
112 title "gzcat - command line" ;
113 check "$Perl ${examples}/gzcat $file1 $file2", $hello1 . $hello2;
115 title "gzcat - stdin" ;
116 check "$Perl ${examples}/gzcat <$file1 ", $hello1;
123 check "$Perl ${examples}/gzgrep the $file1 $file2",
124 join('', grep(/the/, @hello1, @hello2));
126 unlink $file1, $file2 ;
133 writeFile($file1, $hello1) ;
134 writeFile($file2, $hello2) ;
137 # there's no way to set binmode on backticks in Win32 so we won't use $a later
138 check "$Perl ${examples}/filtdef $file1 $file2" ;
140 title "filtdef | filtinf";
141 check "$Perl ${examples}/filtdef $file1 $file2 | $Perl ${examples}/filtinf",
148 writeFile($file1, $hello1) ;
149 check "$Perl ${examples}/gzstream <$file1 >$file2";
152 check "$Perl ${examples}/gzcat $file2", $hello1 ;
157 for ($file1, $file2, $stderr) { 1 while unlink $_ } ;