10 #++ $totalBad unless $ok ;
12 print "ok $no\n" if $ok ;
13 print "not ok $no\n" unless $ok ;
14 printf "# Failed test at line %d\n", (caller)[2] unless $ok ;
21 my($filename, @strings) = @_ ;
22 open (F, ">$filename")
23 or die "Cannot open $filename: $!\n" ;
35 open (F, "<$filename")
36 or die "Cannot open $filename: $!\n" ;
45 my $Inc = join " ", map qq["-I$_"] => @INC;
48 $Perl = ($ENV{'FULLPERL'} or $^X or 'perl') ;
49 $Perl = qq["$Perl"] if $^O eq 'MSWin32' ;
52 my $examples = $ENV{PERL_CORE} ? "../ext/Compress/Zlib/examples" : "./examples";
64 my @hello1 = grep(s/$/\n/, split(/\n/, $hello1)) ;
77 my @hello2 = grep(s/$/\n/, split(/\n/, $hello2)) ;
86 my $file1 = "hello1.gz" ;
87 my $file2 = "hello2.gz" ;
88 unlink $file1, $file2 ;
90 my $hello1_uue = <<'EOM';
91 M'XL("(W#+3$" VAE;&QO,0#+2,W)R><JR<@L5@ BKD2%DM3B$J[<U.+BQ/14
92 ;K@J%$A#@JB@% Z"Z5(74O!0N &D:".,V
95 my $hello2_uue = <<'EOM';
96 M'XL("*[#+3$" VAE;&QO,@#C\L@O3ZGD*LG(+%8 HI*,5*[BU.3\O!2NM,R<
97 A5*X*A0(0X*HH!0.NHM3$G)Q*D#*%5* : #) E6<^
100 # Write a test .gz file
103 writeFile($file1, unpack("u", $hello1_uue)) ;
104 writeFile($file2, unpack("u", $hello2_uue)) ;
108 $a = `$Perl $Inc ${examples}/gzcat $file1 $file2 2>&1` ;
111 or print "# \$\? == [$?]\n";
112 ok(2, $a eq $hello1 . $hello2)
113 or print "# got $a\n";
114 #print "? = $? [$a]\n";
120 $a = ($^O eq 'MSWin32' || $^O eq 'VMS'
121 ? `$Perl $Inc ${examples}/gzgrep "^x" $file1 $file2 2>&1`
122 : `$Perl $Inc ${examples}/gzgrep '^x' $file1 $file2 2>&1`) ;
124 or print "# \$\? == [$?]\n";
126 ok(4, $a eq join('', grep(/^x/, @hello1, @hello2)))
127 or print "# got $a\n";
128 #print "? = $? [$a]\n";
131 unlink $file1, $file2 ;
138 my $stderr = "err.out" ;
140 writeFile($file1, $hello1) ;
141 writeFile($file2, $hello2) ;
143 # there's no way to set binmode on backticks in Win32 so we won't use $a later
144 $a = `$Perl $Inc ${examples}/filtdef $file1 $file2 2>$stderr` ;
146 or print "# \$\? == [$?]\n";
147 ok(6, -s $stderr == 0) ;
150 $a = `$Perl $Inc ${examples}/filtdef $file1 $file2 | $Perl $Inc ${examples}/filtinf 2>$stderr`;
152 or print "# \$\? == [$?]\n";
153 ok(8, -s $stderr == 0) ;
154 ok(9, $a eq $hello1 . $hello2)
155 or print "# got $a\n";
161 writeFile($file1, $hello1) ;
162 $a = `$Perl $Inc ${examples}/gzstream <$file1 >$file2 2>$stderr` ;
164 or print "# \$\? == [$?]\n";
165 ok(11, -s $stderr == 0) ;
167 my $b = `$Perl $Inc ${examples}/gzcat $file2 2>&1` ;
169 or print "# \$\? == [$?]\n";
170 ok(13, $b eq $hello1 )
171 or print "# got $b\n";
178 for ($file1, $file2, $stderr) { 1 while unlink $_ } ;