20 plan(skip_all => "Examples needs Perl 5.005 or better - you have Perl $]" )
23 # use Test::NoWarnings, if available
26 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
28 plan tests => 30 + $extra ;
32 my $Inc = join " ", map qq["-I$_"] => @INC;
33 $Inc = '"-MExtUtils::testlib"'
34 if ! $ENV{PERL_CORE} && eval " require ExtUtils::testlib; " ;
36 my $Perl = ($ENV{'FULLPERL'} or $^X or 'perl') ;
37 $Perl = qq["$Perl"] if $^O eq 'MSWin32' ;
39 $Perl = "$Perl $Inc -w" ;
40 my $examples = $ENV{PERL_CORE} ? "../ext/Compress/Zlib/examples"
53 my @hello1 = grep(s/$/\n/, split(/\n/, $hello1)) ;
66 my @hello2 = grep(s/$/\n/, split(/\n/, $hello2)) ;
68 my $file1 = "hello1.gz" ;
69 my $file2 = "hello2.gz" ;
70 my $stderr = "err.out" ;
73 unlink $file1, $file2 ;
75 my $gz = gzopen($file1, "wb");
76 $gz->gzwrite($hello1);
79 $gz = gzopen($file2, "wb");
80 $gz->gzwrite($hello2);
86 my $expected = shift ;
88 my $stderr = 'err.out';
91 my $cmd = "$command 2>$stderr";
96 $aok &= is $?, 0, " exit status is 0" ;
98 $aok &= is readFile($stderr), '', " no stderr" ;
100 $aok &= is $stdout, $expected, " expected content is ok"
101 if defined $expected ;
104 diag "Command line: $cmd";
105 my ($file, $line) = (caller)[1,2];
106 diag "Test called from $file, line $line";
116 check "$Perl ${examples}/gzcat.zlib $file1 $file2 ", $hello1 . $hello2 ;
118 title "gzcat - command line" ;
119 check "$Perl ${examples}/gzcat $file1 $file2", $hello1 . $hello2;
121 title "gzcat - stdin" ;
122 check "$Perl ${examples}/gzcat <$file1 ", $hello1;
129 check "$Perl ${examples}/gzgrep the $file1 $file2",
130 join('', grep(/the/, @hello1, @hello2));
132 unlink $file1, $file2 ;
139 writeFile($file1, $hello1) ;
140 writeFile($file2, $hello2) ;
143 # there's no way to set binmode on backticks in Win32 so we won't use $a later
144 check "$Perl ${examples}/filtdef $file1 $file2" ;
146 title "filtdef | filtinf";
147 check "$Perl ${examples}/filtdef $file1 $file2 | $Perl ${examples}/filtinf",
154 writeFile($file1, $hello1) ;
155 check "$Perl ${examples}/gzstream <$file1 >$file2";
158 check "$Perl ${examples}/gzcat $file2", $hello1 ;
163 for ($file1, $file2, $stderr) { 1 while unlink $_ } ;