ok $uncomp eq $buffer ;
- unlink $name ;
+ 1 while unlink $name ;
# now check that memGunzip can deal with it.
my $ungzip = Compress::Zlib::memGunzip($dest) ;
ok ! defined $ungzip ;
- unlink $name ;
+ 1 while unlink $name ;
# check corrupt header -- too short
$dest = "x" ;
my $unc = Compress::Zlib::memGunzip($compr) ;
ok defined $unc ;
ok $buffer eq $unc ;
- unlink $name ;
+ 1 while unlink $name ;
}
{
#========================================
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $hello = <<EOM ;
hello world
#========================================
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $hello = <<EOM ;
hello world
}
{
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $hello = <<EOM ;
hello world
#================================
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $hello = <<EOM ;
hello world
# Write
# these tests come almost 100% from IO::String
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $io = $CompressClass->new($name);
EOT
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my %opts = () ;
%opts = (CRC32 => 1, Adler32 => 1)
EOT
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
writeFile($name, $str);
my @tmp;
{
title "Read Tests - buf length $bufsize, Transparent $trans, Append $append" ;
- my $name = "testz.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
if ($trans) {
writeFile($name, $str) ;
my $buffer ;
my $buff ;
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $first = "beginning" ;
my $last = "the end" ;
{
title "$CompressClass -- Append $append, Output to $fb" ;
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $already = 'already';
my $buffer = $already;
my $comp_len = length $compressed;
$compressed .= $appended;
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $input ;
writeFile ($name, $compressed);
{
title "$UncompressClass -- Append $append" ;
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $string = "appended";
my $compressed ;
{
title "ungetc, File $file, Transparent $trans" ;
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $string = 'abcdeABCDE';
my $b ;
{
title "write tests - invalid data" ;
- #my $name1 = "test.gz" ;
- #my $lex = new LexFile $name1 ;
+ #my $lex = new LexFile my $name1 ;
my $Answer ;
#ok ! -e $name1, " File $name1 does not exist";
my $file1 = "hello1.gz" ;
my $file2 = "hello2.gz" ;
my $stderr = "err.out" ;
-unlink $stderr ;
-unlink $file1, $file2 ;
+for ($file1, $file2, $stderr) { 1 while unlink $_ } ;
+
my $gz = gzopen($file1, "wb");
$gz->gzwrite($hello1);
my $expected = shift ;
my $stderr = 'err.out';
- unlink $stderr;
+ 1 while unlink $stderr;
my $cmd = "$command 2>$stderr";
my $stdout = `$cmd` ;
diag "Test called from $file, line $line";
}
- unlink $stderr;
+ 1 while unlink $stderr;
}
# gzcat
check "$Perl ${examples}/gzgrep the $file1 $file2",
join('', grep(/the/, @hello1, @hello2));
-unlink $file1, $file2 ;
+for ($file1, $file2) { 1 while unlink $_ } ;
# filtdef/filtinf
my ($input, $err, $answer, $X, $status, $Answer);
- my $name = "test.gz" ;
- unlink $name ;
+ my $lex = new LexFile my $name;
ok my $x = gzopen($name, "wb");
$input .= $hello;
ok $k->gzeof ;
ok ! $k->gzclose ;
ok $k->gzeof ;
- unlink $name;
}
{
title "gzopen" ;
- my $name = "test.gz" ;
my $s = "\x{df}\x{100}";
my $byte_len = length( Encode::encode_utf8($s) );
my ($uncomp) ;
+ my $lex = new LexFile my $name ;
ok my $fil = gzopen($name, "wb"), " gzopen for write ok" ;
is $fil->gzwrite(Encode::encode_utf8($s)), $byte_len, " wrote $byte_len bytes" ;
ok ! $fil->gzclose, "gzclose ok" ;
- unlink $name ;
-
is $s, Encode::decode_utf8($uncomp), " decode_utf8 ok" ;
}
my $ThisOS_code = $Compress::Zlib::gzip_os_code;
-my $name = "test.gz" ;
-my $lex = new LexFile $name ;
+my $lex = new LexFile my $name ;
{
title "Check Defaults";
ok $x->close ;
substr($truncated, $index) = '' ;
- #my $name = "trunc.gz" ;
- #my $lex = new LexFile $name ;
+ #my $lex = new LexFile my $name ;
#writeFile($name, $truncated) ;
#my $g = new IO::Uncompress::Gunzip $name, -Transparent => 0;
ok $x->close ;
substr($truncated, $index) = '' ;
- #my $name = "trunc.gz" ;
- #my $lex = new LexFile $name ;
+ #my $lex = new LexFile my $name ;
#writeFile($name, $truncated) ;
#my $g = new IO::Uncompress::Gunzip $name, -Transparent => 0;
ok $x->close ;
substr($truncated, $index) = '' ;
- my $name = "trunc.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
writeFile($name, $truncated) ;
my $g = new IO::Uncompress::Gunzip $name, -Transparent => 0;
# Check the Deflate Header Parameters
#========================================
-my $name = "test.gz" ;
-my $lex = new LexFile $name ;
+my $lex = new LexFile my $name ;
{
title "Check default header settings" ;
title "Fingerprint Truncation";
foreach my $i (1)
{
- my $name = "test.gz" ;
- unlink $name ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
ok 1, "Length $i" ;
my $part = substr($compressed, 0, $i);
#
foreach my $i (2 .. $header_size -1)
{
- my $name = "test.gz" ;
- unlink $name ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
ok 1, "Length $i" ;
my $part = substr($compressed, 0, $i);
foreach my $i ($header_size .. length($compressed) - 1 - $trailer_size)
{
- my $name = "test.gz" ;
- unlink $name ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
ok 1, "Length $i" ;
my $part = substr($compressed, 0, $i);
{
foreach my $lax (0, 1)
{
- my $name = "test.gz" ;
- unlink $name ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
ok 1, "Length $i, Lax $lax" ;
my $part = substr($compressed, 0, $i);
foreach my $i (0 .. $blocksize)
{
- my $name = "test.gz" ;
- unlink $name ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
ok 1, "Length $i" ;
my $part = substr($compressed, 0, $i);
foreach my $i ($blocksize+1 .. length($compressed)-1)
{
- my $name = "test.gz" ;
- unlink $name ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
ok 1, "Length $i" ;
my $part = substr($compressed, 0, $i);
for my $useBuf (0 .. 1)
{
print "#\n# BlockSize $blocksize, Length $i, Buffer $useBuf\n#\n" ;
- my $name = "test.gz" ;
- unlink $name ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $prime = substr($compressed, 0, $i);
my $rest = substr($compressed, $i);
ok ! $fil->gzclose ;
ok $fil->gzeof() ;
-unlink $name ;
+1 while unlink $name ;
ok $hello eq $uncomp ;
ok $gzerrno == 0
or print "# gzerrno is $gzerrno\n" ;
-unlink $name ;
+1 while unlink $name ;
ok $number == $uncomp ;
ok $number eq $uncomp ;
ok $f->gzeof() ;
ok ! $f->gzclose ;
-unlink($file) ;
+1 while unlink($file) ;
# gzip - readline tests
# ======================
ok $fil->gzeof() ;
ok ! $fil->gzclose ;
ok $fil->gzeof() ;
-unlink($name) ;
+1 while unlink($name) ;
# a text file with a very long line (bigger than the internal buffer)
my $line1 = ("abcdefghijklmnopq" x 2000) . "\n" ;
ok ! $fil->gzclose ;
ok $fil->gzeof() ;
-unlink $name ;
+1 while unlink $name ;
# a text file which is not termined by an EOL
ok $fil->gzeof() ;
ok ! $fil->gzclose ;
-unlink $name ;
+1 while unlink $name ;
{
my $hello = "hello" ;
my $len = length $hello ;
- unlink $name ;
-
my $f = new IO::File ">$name" ;
ok $f;
ok ! $fil->gzclose ;
ok $fil->gzeof() ;
- unlink $name ;
is $uncomp, $hello, "got expected output" ;
my $hello = "hello" ;
my $len = length $hello ;
- unlink $name ;
-
open F, ">$name" ;
my $fil;
ok ! $fil->gzclose ;
ok $fil->gzeof() ;
- unlink $name ;
-
is $uncomp, $hello ;
my $hello = "hello" ;
my $len = length $hello ;
- unlink $name ;
-
ok open(SAVEOUT, ">&STDOUT"), " save STDOUT";
my $dummy = fileno SAVEOUT;
ok open(STDOUT, ">$name"), " redirect STDOUT" ;
open(STDIN, "<&SAVEIN");
- unlink $name ;
-
is $uncomp, $hello ;
my $fil;
- unlink $name ;
-
# missing parameters
eval ' $fil = gzopen() ' ;
like $@, mkEvalErr('Not enough arguments for Compress::Zlib::gzopen'),
SKIP:
{
- my $name ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
writeFile($name, "abc");
chmod 0444, $name ;
SKIP:
{
- my $name ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
writeFile($name, "abc");
chmod 0222, $name ;
title "gzseek" ;
my $buff ;
- my $name ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $first = "beginning" ;
my $last = "the end" ;
}
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $output ;
if ($fb eq 'buffer')
{
like $@, mkErr("^$TopType: input filename is undef or null string"),
' Input filename empty' ;
- $in = 'abc';
- my $lex1 = new LexFile($in) ;
- writeFile($in, "abc");
- my $out = $in ;
- eval { $a = $Func->($in, $out) ;} ;
+ my $lex1 = new LexFile my $in1 ;
+ writeFile($in1, "abc");
+ my $out = $in1 ;
+ eval { $a = $Func->($in1, $out) ;} ;
like $@, mkErr("^$TopType: input and output filename are identical"),
' Input and Output filename are the same';
like $@, mkErr("^$TopType: input and output buffer are identical"),
' Input and Output buffer are the same';
- my $out_file = "abcde.out";
- my $lex = new LexFile($out_file) ;
+ my $lex = new LexFile my $out_file ;
open OUT, ">$out_file" ;
eval { $a = $Func->(\*OUT, \*OUT) ;} ;
like $@, mkErr("^$TopType: input and output handle are identical"),
my $incumbent = "incumbent data" ;
- my ($file1, $file2) = ("file1", "file2");
- my $lex = new LexFile($file1, $file2) ;
+ #my ($file1, $file2) = ("file1", "file2");
+ my $lex = new LexFile(my $file1, my $file2) ;
writeFile($file1, compressBuffer($TopType,"data1"));
writeFile($file2, compressBuffer($TopType,"data2"));
title "More write tests" ;
- my $file1 = "file1" ;
- my $file2 = "file2" ;
- my $file3 = "file3" ;
- my $lex = new LexFile $file1, $file2, $file3 ;
+ my $lex = new LexFile(my $file1, my $file2, my $file3) ;
writeFile($file1, "F1");
writeFile($file2, "F2");
{
title "Check gzip header default NAME & MTIME settings" ;
- my $file1 = "file1" ;
- my $lex = new LexFile $file1;
+ my $lex = new LexFile my $file1;
my $content = "hello ";
my $hdr ;
{
# Check that the class destructor will call close
- my $name = "test.gz" ;
- unlink $name ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $hello = <<EOM ;
hello world
# Tied filehandle destructor
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $hello = <<EOM ;
hello world
# Write
# these tests come almost 100% from IO::String
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $io = $CompressClass->new($name);
EOT
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $iow = new $CompressClass $name ;
print $iow $str ;
EOT
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
writeFile($name, $str);
my @tmp;
{
title "Read Tests - buf length $bufsize, Transparent $trans, Append $append" ;
- my $name = "testz.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
if ($trans) {
writeFile($name, $str) ;
# Write
# these tests come almost 100% from IO::String
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $io = $CompressClass->new($name);
EOT
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $iow = new $CompressClass $name ;
print $iow $str ;
{
title "seek tests" ;
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $first = "beginning" ;
my $last = "the end" ;
{
title 'fileno' ;
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $hello = <<EOM ;
hello world
else
{ title "$CompressClass - Merge to filehandle that isn't writable" }
- my $out_file = 'abcde.out';
- my $lex = new LexFile($out_file) ;
+ my $lex = new LexFile my $out_file ;
# create empty file
open F, ">$out_file" ; print F "x"; close F;
my $Error = getErrorRef($CompressClass);
- my $out_file = 'abcde.out';
- my $lex = new LexFile($out_file) ;
+ my $lex = new LexFile my $out_file ;
foreach my $to_file ( qw(buffer file handle ) )
{
my $Error = getErrorRef($CompressClass);
- my $out_file = 'abcde.out';
- my $lex = new LexFile($out_file) ;
+ my $lex = new LexFile my $out_file ;
foreach my $to_file ( qw(buffer file handle ) )
{
title "$CompressClass - Merge to file that doesn't exist";
- my $out_file = 'abcd.out';
- my $lex = new LexFile($out_file) ;
+ my $lex = new LexFile my $out_file ;
ok ! -e $out_file, " Destination file, '$out_file', does not exist";
{
my $Error = getErrorRef($CompressClass);
- my $out_file = 'abcde.out';
- my $lex = new LexFile($out_file) ;
+ my $lex = new LexFile my $out_file ;
foreach my $to_file ( qw( buffer file handle ) )
{
my $buffer ;
- my $out_file = 'abcde.out';
- my $lex = new LexFile($out_file) ;
+ my $lex = new LexFile my $out_file ;
foreach my $to_file (0, 1)
{
{
title "whatIsInput" ;
- my $out_file = "abc";
- my $lex = new LexFile($out_file) ;
+ my $lex = new LexFile my $out_file ;
open FH, ">$out_file" ;
is whatIsInput(*FH), 'handle', "Match filehandle" ;
close FH ;
{
title "whatIsOutput" ;
- my $out_file = "abc";
- my $lex = new LexFile($out_file) ;
+ my $lex = new LexFile my $out_file ;
open FH, ">$out_file" ;
is whatIsOutput(*FH), 'handle', "Match filehandle" ;
close FH ;
unless defined $_;
}
chmod 0777, @_;
- unlink @_ ;
+ for (@_) { 1 while unlink $_ } ;
bless [ @_ ], $self ;
}
{
my $self = shift ;
chmod 0777, @{ $self } ;
- unlink @{ $self } ;
+ for (@$self) { 1 while unlink $_ } ;
}
}