9 use IO::Handle qw(SEEK_SET SEEK_CUR SEEK_END);
11 our ($UncompressClass);
14 # use Test::NoWarnings, if available
17 my $st = eval { require Test::NoWarnings ; import Test::NoWarnings; 1; };
21 plan(tests => 597 + $extra) ;
26 my $filename = shift ;
30 my $fil = new $UncompressClass $filename,
36 $data = $init if defined $init ;
37 1 while $fil->read($data) > 0;
45 my $CompressClass = identify();
46 $UncompressClass = getInverse($CompressClass);
47 my $Error = getErrorRef($CompressClass);
48 my $UnError = getErrorRef($UncompressClass);
52 title "Testing $CompressClass Errors";
55 eval qq[\$a = new $CompressClass(\\1) ;] ;
56 like $@, mkEvalErr("^$CompressClass: output buffer is read-only") ;
60 eval qq[\$a = new $CompressClass ] . '$out ;' ;
61 like $@, mkEvalErr("^$CompressClass: output filename is undef or null string");
64 eval qq[\$a = new $CompressClass \$out ;] ;
65 like $@, mkEvalErr("^$CompressClass: output filename is undef or null string");
68 $gz = new $CompressClass(\$x);
70 foreach my $name (qw(read readline getc))
72 eval " \$gz->$name() " ;
73 like $@, mkEvalErr("^$name Not Available: File opened only for output");
76 eval ' $gz->write({})' ;
77 like $@, mkEvalErr("^${CompressClass}::write: not a scalar reference");
78 #like $@, mkEvalErr("^${CompressClass}::write: input parameter not a filename, filehandle, array ref or scalar ref");
80 eval ' $gz->syswrite("abc", 1, 5)' ;
81 like $@, mkEvalErr("^${CompressClass}::write: offset outside string");
83 eval ' $gz->syswrite("abc", 1, -4)' ;
84 like $@, mkEvalErr("^${CompressClass}::write: offset outside string");
89 title "Testing $UncompressClass Errors";
92 eval qq[\$a = new $UncompressClass \$out ;] ;
93 like $@, mkEvalErr("^$UncompressClass: input filename is undef or null string");
95 eval qq[\$a = new $UncompressClass \$out ;] ;
96 like $@, mkEvalErr("^$UncompressClass: input filename is undef or null string");
98 my $lex = new LexFile my $name ;
100 ok ! -e $name, " $name does not exist";
102 eval qq[\$a = new $UncompressClass "$name" ;] ;
103 is $$UnError, "input file '$name' does not exist";
106 my $guz = new $CompressClass(\$gc);
111 my $gz = new $UncompressClass(\$gc);
113 foreach my $name (qw(print printf write))
115 eval " \$gz->$name() " ;
116 like $@, mkEvalErr("^$name Not Available: File opened only for intput");
122 title "Testing $CompressClass and $UncompressClass";
125 my ($a, $x, @x) = ("","","") ;
127 # Buffer not a scalar reference
128 eval qq[\$a = new $CompressClass \\\@x ;] ;
129 like $@, mkEvalErr("^$CompressClass: output parameter not a filename, filehandle or scalar ref");
131 # Buffer not a scalar reference
132 eval qq[\$a = new $UncompressClass \\\@x ;] ;
133 like $@, mkEvalErr("^$UncompressClass: input parameter not a filename, filehandle, array ref or scalar ref");
136 foreach my $Type ( $CompressClass, $UncompressClass)
138 # Check error handling with IO::Compress::Deflate and IO::Uncompress::Inflate
140 my ($a, $x, @x) = ("","","") ;
142 # Odd number of parameters
143 eval qq[\$a = new $Type "abc", -Output ] ;
144 like $@, mkEvalErr("^$Type: Expected even number of parameters, got 1");
147 eval qq[\$a = new $Type "anc", -Fred => 123 ;] ;
148 like $@, mkEvalErr("^$Type: unknown key value\\(s\\) Fred");
151 eval qq[\$a = new $Type ;] ;
152 like $@, mkEvalErr("^$Type: Missing (Input|Output) parameter");
158 # write a very simple compressed file
160 #========================================
163 my $lex = new LexFile my $name ;
172 ok $x = new $CompressClass $name ;
173 is $x->autoflush(1), 0, "autoflush";
174 is $x->autoflush(1), 1, "autoflush";
175 ok $x->opened(), "opened";
177 ok $x->write($hello), "write" ;
178 ok $x->flush(), "flush";
179 ok $x->close, "close" ;
180 ok ! $x->opened(), "! opened";
185 ok my $x = new $UncompressClass $name, -Append => 1 ;
186 ok $x->opened(), "opened";
189 1 while ($len = $x->read($uncomp)) > 0 ;
191 is $len, 0, "read returned 0"
196 ok !$x->opened(), "! opened";
201 # write a very simple compressed file
203 #========================================
206 my $lex = new LexFile my $name ;
215 ok $x = new $CompressClass $name ;
217 is $x->write(''), 0, "Write empty string is ok";
218 is $x->write(undef), 0, "Write undef is ok";
219 ok $x->write($hello), "Write ok" ;
220 ok $x->close, "Close ok" ;
225 my $x = new $UncompressClass $name ;
226 ok $x, "creates $UncompressClass $name" ;
229 $data .= $uncomp while $x->read($uncomp) > 0 ;
231 ok $x->close, "close ok" ;
232 is $data, $hello, "expected output" ;
238 # write a very simple file with using an IO filehandle
240 #========================================
243 my $lex = new LexFile my $name ;
251 my $fh = new IO::File ">$name" ;
252 ok $fh, "opened file $name ok";
253 my $x = new $CompressClass $fh ;
254 ok $x, " created $CompressClass $fh" ;
256 is $x->fileno(), fileno($fh), "fileno match" ;
257 is $x->write(''), 0, "Write empty string is ok";
258 is $x->write(undef), 0, "Write undef is ok";
259 ok $x->write($hello), "write ok" ;
260 ok $x->flush(), "flush";
261 ok $x->close,"close" ;
268 ok my $fh1 = new IO::File "<$name" ;
269 ok $x = new $UncompressClass $fh1, -Append => 1 ;
270 ok $x->fileno() == fileno $fh1 ;
272 1 while $x->read($uncomp) > 0 ;
277 ok $hello eq $uncomp ;
281 # write a very simple file with using a glob filehandle
283 #========================================
286 my $lex = new LexFile my $name ;
287 #my $name = "/tmp/fred";
295 title "$CompressClass: Input from typeglob filehandle";
296 ok open FH, ">$name" ;
298 my $x = new $CompressClass *FH ;
299 ok $x, " create $CompressClass" ;
301 is $x->fileno(), fileno(*FH), " fileno" ;
302 is $x->write(''), 0, " Write empty string is ok";
303 is $x->write(undef), 0, " Write undef is ok";
304 ok $x->write($hello), " Write ok" ;
305 ok $x->flush(), " Flush";
306 ok $x->close, " Close" ;
313 title "$UncompressClass: Input from typeglob filehandle, append output";
315 ok open FH, "<$name" ;
316 ok $x = new $UncompressClass *FH, -Append => 1, Transparent => 0
318 is $x->fileno(), fileno FH, " fileno ok" ;
320 1 while $x->read($uncomp) > 0 ;
322 ok $x->close, " close" ;
326 is $uncomp, $hello, " expected output" ;
330 my $lex = new LexFile my $name ;
331 #my $name = "/tmp/fred";
339 title "Outout to stdout via '-'" ;
341 open(SAVEOUT, ">&STDOUT");
342 my $dummy = fileno SAVEOUT;
343 open STDOUT, ">$name" ;
345 my $x = new $CompressClass '-' ;
349 open(STDOUT, ">&SAVEOUT");
351 ok 1, " wrote to stdout" ;
353 is myGZreadFile($name), $hello, " wrote OK";
357 title "Input from stdin via filename '-'";
361 my $stdinFileno = fileno(STDIN);
362 # open below doesn't return 1 sometines on XP
363 open(SAVEIN, "<&STDIN");
364 ok open(STDIN, "<$name"), " redirect STDIN";
365 my $dummy = fileno SAVEIN;
366 $x = new $UncompressClass '-', Append => 1, Transparent => 0
368 ok $x, " created object" ;
369 is $x->fileno(), $stdinFileno, " fileno ok" ;
371 1 while $x->read($uncomp) > 0 ;
373 ok $x->close, " close" ;
374 open(STDIN, "<&SAVEIN");
375 is $uncomp, $hello, " expected output" ;
380 # write a compressed file to memory
382 #========================================
384 #my $name = "test.gz" ;
385 my $lex = new LexFile my $name ;
395 ok $x = new $CompressClass(\$buffer) ;
397 ok ! defined $x->autoflush(1) ;
398 ok ! defined $x->autoflush(1) ;
399 ok ! defined $x->fileno() ;
400 is $x->write(''), 0, "Write empty string is ok";
401 is $x->write(undef), 0, "Write undef is ok";
402 ok $x->write($hello) ;
406 writeFile($name, $buffer) ;
407 #is anyUncompress(\$buffer), $hello, " any ok";
414 ok $x = new $UncompressClass(\$buffer, Append => 1) ;
416 ok ! defined $x->autoflush(1) ;
417 ok ! defined $x->autoflush(1) ;
418 ok ! defined $x->fileno() ;
419 1 while $x->read($uncomp) > 0 ;
425 ok $buffer eq $keep ;
428 if ($CompressClass ne 'RawDeflate')
431 #========================================
436 ok $x = new $CompressClass(\$buffer) ;
445 ok $x = new $UncompressClass(\$buffer, Append => 1) ;
447 1 while $x->read($uncomp) > 0 ;
453 ok $buffer eq $keep ;
458 # write a larger file
459 #========================================
462 my $lex = new LexFile my $name ;
473 my $x = new $CompressClass $name ;
474 ok $x, " created $CompressClass object";
476 ok $x->write($hello), " write ok" ;
478 ok $x->write("another line"), " write ok" ;
479 $input .= "another line" ;
482 { $contents .= chr int $_ }
483 # generate a long random string
485 { $contents .= chr int rand 256 }
487 ok $x->write($contents), " write ok" ;
488 $input .= $contents ;
489 ok $x->close, " close ok" ;
492 ok myGZreadFile($name) eq $input ;
493 my $x = readFile($name) ;
494 #print "length " . length($x) . " \n";
498 # embed a compressed file in another file
499 #================================
502 my $lex = new LexFile my $name ;
509 my $header = "header info\n" ;
510 my $trailer = "trailer data\n" ;
514 ok $fh = new IO::File ">$name" ;
517 ok $x = new $CompressClass $fh,
521 ok $x->write($hello) ;
529 ok $fh1 = new IO::File "<$name" ;
532 ok $line eq $header ;
534 ok my $x = new $UncompressClass $fh1, Append => 1 ;
536 1 while $x->read($uncomp) > 0 ;
538 ok $uncomp eq $hello ;
540 read($fh1, $rest, 5000);
541 is $x->trailingData() . $rest, $trailer ;
542 #print "# [".$x->trailingData() . "][$rest]\n" ;
549 # these tests come almost 100% from IO::String
551 my $lex = new LexFile my $name ;
553 my $io = $CompressClass->new($name);
555 is $io->tell(), 0, " tell returns 0"; ;
557 my $heisan = "Heisan\n";
558 $io->print($heisan) ;
560 ok ! $io->eof(), " ! eof";
562 is $io->tell(), length($heisan), " tell is " . length($heisan) ;
564 $io->print("a", "b", "c");
568 $io->print("d", "e");
570 $io->print("f", "g", "h");
575 $io->print("D", "E");
577 $io->print("F", "G", "H");
580 my $foo = "1234567890";
582 is $io->syswrite($foo, length($foo)), length($foo), " syswrite ok" ;
584 { is $io->syswrite($foo, length $foo), length $foo, " syswrite ok" }
586 { is $io->syswrite($foo), length $foo, " syswrite ok" }
587 is $io->syswrite($foo, length($foo)), length $foo, " syswrite ok";
588 is $io->write($foo, length($foo), 5), 5, " write 5";
589 is $io->write("xxx\n", 100, -1), 1, " write 1";
592 $io->printf("i(%d)", $_);
593 $io->printf("[%d]\n", $_);
599 ok $io->eof(), " eof";
601 is myGZreadFile($name), "Heisan\nabcde\nf,g,h\nDEF.G.H" .
602 ("1234567890" x 3) . "67890\n" .
603 "i(1)[1]\ni(2)[2]\ni(3)[3]\n\n";
619 my $lex = new LexFile my $name ;
622 my $iow = new $CompressClass $name, %opts;
629 my $io = new $UncompressClass $name ;
632 is $io->input_line_number, 0;
636 my @lines = $io->getlines();
638 or print "# Got " . scalar(@lines) . " lines, expected 6\n" ;
639 is $lines[1], "of a paragraph\n" ;
640 is join('', @lines), $str ;
642 is $io->input_line_number, 6;
643 is $io->tell(), length($str) ;
647 ok ! ( defined($io->getline) ||
648 (@tmp = $io->getlines) ||
649 defined($io->getline) ||
650 defined($io->getc) ||
651 $io->read($buf, 100) != 0) ;
656 local $/; # slurp mode
657 my $io = $UncompressClass->new($name);
659 is $io->input_line_number, 0;
661 my @lines = $io->getlines;
663 is $io->input_line_number, 1;
665 ok @lines == 1 && $lines[0] eq $str;
667 $io = $UncompressClass->new($name);
669 my $line = $io->getline();
675 local $/ = ""; # paragraph mode
676 my $io = $UncompressClass->new($name);
678 is $io->input_line_number, 0;
680 my @lines = $io->getlines();
682 is $io->input_line_number, 2;
685 or print "# Got " . scalar(@lines) . " lines, expected 2\n" ;
686 ok $lines[0] eq "This is an example\nof a paragraph\n\n\n"
687 or print "# $lines[0]\n";
688 ok $lines[1] eq "and a single line.\n\n";
693 my $io = $UncompressClass->new($name);
698 while (my $a = $io->getline()) {
700 $err++ if $. != ++$no;
707 is $io->input_line_number, 3;
709 or print "# Got " . scalar(@lines) . " lines, expected 3\n" ;
710 ok join("-", @lines) eq
711 "This- is- an example\n" .
712 "of a paragraph\n\n\n" .
713 "and a single line.\n\n";
720 my $io = $UncompressClass->new($name);
723 eval { $io->read(1) } ;
724 like $@, mkErr("buffer parameter is read-only");
726 is $io->read($buf, 0), 0, "Requested 0 bytes" ;
728 ok $io->read($buf, 3) == 3 ;
731 ok $io->sysread($buf, 3, 2) == 3 ;
733 or print "# [$buf]\n" ;;
740 # ok read($io, $buf, 20) == 4 ;
741 # ok $buf eq "e.\n\n";
743 # ok read($io, $buf, 20) == 0 ;
752 # Read from non-compressed file
763 my $lex = new LexFile my $name ;
765 writeFile($name, $str);
769 my $io = new $UncompressClass $name, -Transparent => 1 ;
773 ok $io->tell() == 0 ;
774 my @lines = $io->getlines();
776 ok $lines[1] eq "of a paragraph\n" ;
777 ok join('', @lines) eq $str ;
779 is $io->input_line_number, 6;
780 ok $io->tell() == length($str) ;
784 ok ! ( defined($io->getline) ||
785 (@tmp = $io->getlines) ||
786 defined($io->getline) ||
787 defined($io->getc) ||
788 $io->read($buf, 100) != 0) ;
793 local $/; # slurp mode
794 my $io = $UncompressClass->new($name);
796 my @lines = $io->getlines;
798 is $io->input_line_number, 1;
800 ok @lines == 1 && $lines[0] eq $str;
802 $io = $UncompressClass->new($name);
804 my $line = $io->getline;
806 is $io->input_line_number, 1;
812 local $/ = ""; # paragraph mode
813 my $io = $UncompressClass->new($name);
815 my @lines = $io->getlines;
817 is $io->input_line_number, 2;
820 or print "# exected 2 lines, got " . scalar(@lines) . "\n";
821 ok $lines[0] eq "This is an example\nof a paragraph\n\n\n"
822 or print "# [$lines[0]]\n" ;
823 ok $lines[1] eq "and a single line.\n\n";
828 my $io = $UncompressClass->new($name);
833 while (my $a = $io->getline) {
835 $err++ if $. != ++$no;
839 is $io->input_line_number, 3;
845 ok join("-", @lines) eq
846 "This- is- an example\n" .
847 "of a paragraph\n\n\n" .
848 "and a single line.\n\n";
855 my $io = $UncompressClass->new($name);
857 ok $io->read($buf, 3) == 3 ;
860 ok $io->sysread($buf, 3, 2) == 3 ;
868 # ok read($io, $buf, 20) == 4 ;
869 # ok $buf eq "e.\n\n";
871 # ok read($io, $buf, 20) == 0 ;
881 # Vary the length parameter in a read
896 foreach my $bufsize (1, 3, 512, 4096, length($str)-1, length($str), length($str)+1)
898 foreach my $trans (0, 1)
900 foreach my $append (0, 1)
902 title "Read Tests - buf length $bufsize, Transparent $trans, Append $append" ;
904 my $lex = new LexFile my $name ;
907 writeFile($name, $str) ;
910 my $iow = new $CompressClass $name;
916 my $io = $UncompressClass->new($name,
918 -Transparent => $trans);
925 1 while $io->read($buf, $bufsize) > 0;
929 $buf .= $tmp while $io->read($tmp, $bufsize) > 0 ;
931 is length $buf, length $str;
940 foreach my $file (0, 1)
942 foreach my $trans (0, 1)
944 title "seek tests - file $file trans $trans" ;
948 my $lex = new LexFile my $name ;
950 my $first = "beginning" ;
951 my $last = "the end" ;
955 $buffer = $first . "\x00" x 10 . $last;
956 writeFile($name, $buffer);
970 my $iow = new $CompressClass $output ;
971 $iow->print($first) ;
972 ok $iow->seek(5, SEEK_CUR) ;
973 ok $iow->tell() == length($first)+5;
974 ok $iow->seek(0, SEEK_CUR) ;
975 ok $iow->tell() == length($first)+5;
976 ok $iow->seek(length($first)+10, SEEK_SET) ;
977 ok $iow->tell() == length($first)+10;
993 ok myGZreadFile($input) eq $first . "\x00" x 10 . $last ;
995 my $io = $UncompressClass->new($input, Strict => 1);
996 ok $io->seek(length($first), SEEK_CUR)
999 is $io->tell(), length($first);
1001 ok $io->read($buff, 5) ;
1002 is $buff, "\x00" x 5 ;
1003 is $io->tell(), length($first) + 5;
1005 ok $io->seek(0, SEEK_CUR) ;
1006 my $here = $io->tell() ;
1007 is $here, length($first)+5;
1009 ok $io->seek($here+5, SEEK_SET) ;
1010 is $io->tell(), $here+5 ;
1011 ok $io->read($buff, 100) ;
1018 title "seek error cases" ;
1021 my $a = new $CompressClass(\$b) ;
1024 eval { $a->seek(-1, 10) ; };
1025 like $@, mkErr("^${CompressClass}::seek: unknown value, 10, for whence parameter");
1027 eval { $a->seek(-1, SEEK_END) ; };
1028 like $@, mkErr("^${CompressClass}::seek: cannot seek backwards");
1034 my $u = new $UncompressClass(\$b) ;
1036 eval { $u->seek(-1, 10) ; };
1037 like $@, mkErr("^${UncompressClass}::seek: unknown value, 10, for whence parameter");
1039 eval { $u->seek(-1, SEEK_END) ; };
1040 like $@, mkErr("^${UncompressClass}::seek: SEEK_END not allowed");
1042 eval { $u->seek(-1, SEEK_CUR) ; };
1043 like $@, mkErr("^${UncompressClass}::seek: cannot seek backwards");
1046 foreach my $fb (qw(filename buffer filehandle))
1048 foreach my $append (0, 1)
1051 title "$CompressClass -- Append $append, Output to $fb" ;
1053 my $lex = new LexFile my $name ;
1055 my $already = 'already';
1056 my $buffer = $already;
1059 if ($fb eq 'buffer')
1060 { $output = \$buffer }
1061 elsif ($fb eq 'filename')
1064 writeFile($name, $buffer);
1066 elsif ($fb eq 'filehandle')
1068 $output = new IO::File ">$name" ;
1069 print $output $buffer;
1072 my $a = new $CompressClass($output, Append => $append) ;
1073 ok $a, " Created $CompressClass";
1074 my $string = "appended";
1079 if ($fb eq 'buffer')
1086 if $fb eq 'filehandle';
1087 $data = readFile($name);
1090 if ($append || $fb eq 'filehandle')
1092 is substr($data, 0, length($already)), $already, " got prefix";
1093 substr($data, 0, length($already)) = '';
1098 my $x = new $UncompressClass(\$data, Append => 1) ;
1099 ok $x, " created $UncompressClass";
1102 1 while ($len = $x->read($uncomp)) > 0 ;
1105 is $uncomp, $string, ' Got uncompressed data' ;
1111 foreach my $type (qw(buffer filename filehandle))
1113 title "$UncompressClass -- InputLength, read from $type";
1116 my $string = "some data";
1117 my $c = new $CompressClass(\$compressed);
1121 my $appended = "append";
1122 my $comp_len = length $compressed;
1123 $compressed .= $appended;
1125 my $lex = new LexFile my $name ;
1127 writeFile ($name, $compressed);
1129 if ($type eq 'buffer')
1131 $input = \$compressed;
1133 if ($type eq 'filename')
1137 elsif ($type eq 'filehandle')
1139 my $fh = new IO::File "<$name" ;
1140 ok $fh, "opened file $name ok";
1144 my $x = new $UncompressClass($input, InputLength => $comp_len) ;
1145 ok $x, " created $UncompressClass";
1149 $len = $x->read($output, 100);
1150 is $len, length($string);
1151 is $output, $string;
1153 if ($type eq 'filehandle')
1156 $input->read($rest, 1000);
1157 is $rest, $appended;
1163 foreach my $append (0, 1)
1165 title "$UncompressClass -- Append $append" ;
1167 my $lex = new LexFile my $name ;
1169 my $string = "appended";
1171 my $c = new $CompressClass(\$compressed);
1175 my $x = new $UncompressClass(\$compressed, Append => $append) ;
1176 ok $x, " created $UncompressClass";
1178 my $already = 'already';
1179 my $output = $already;
1182 $len = $x->read($output, 100);
1183 is $len, length($string);
1189 is substr($output, 0, length($already)), $already, " got prefix";
1190 substr($output, 0, length($already)) = '';
1192 is $output, $string, ' Got uncompressed data' ;
1196 foreach my $file (0, 1)
1198 foreach my $trans (0, 1)
1200 title "ungetc, File $file, Transparent $trans" ;
1202 my $lex = new LexFile my $name ;
1204 my $string = 'abcdeABCDE';
1212 my $a = new $CompressClass(\$b) ;
1220 writeFile($name, $b);
1228 my $u = $UncompressClass->new($from, Transparent => 1) ;
1232 # do an ungetc before reading
1234 $first = $u->getc();
1237 $first = $u->getc();
1238 is $first, substr($string, 0,1);
1240 $first = $u->getc();
1241 is $first, substr($string, 0,1);
1244 is $u->read($buff, 5), 5 ;
1245 is $buff, substr($string, 0, 5);
1248 is $u->read($buff, length($string)), length($string) ;
1251 is $u->read($buff, 1), 0;
1254 my $extra = 'extra';
1257 is $u->read($buff), length($extra) ;
1260 is $u->read($buff, 1), 0;
1270 title "write tests - invalid data" ;
1272 #my $lex = new LexFile my $name1 ;
1275 #ok ! -e $name1, " File $name1 does not exist";
1278 [ '{ }', "${CompressClass}::write: input parameter not a filename, filehandle, array ref or scalar ref" ],
1279 [ '[ { } ]', "${CompressClass}::write: input parameter not a filename, filehandle, array ref or scalar ref" ],
1280 [ '[ [ { } ] ]', "${CompressClass}::write: input parameter not a filename, filehandle, array ref or scalar ref" ],
1281 [ '[ "" ]', "${CompressClass}::write: input filename is undef or null string" ],
1282 [ '[ undef ]', "${CompressClass}::write: input filename is undef or null string" ],
1283 [ '[ \$Answer ]',"${CompressClass}::write: input and output buffer are identical" ],
1284 #[ "not readable", 'xx' ],
1285 # same filehandle twice, 'xx'
1288 foreach my $data (@data)
1290 my ($send, $get) = @$data ;
1291 title "${CompressClass}::write( $send )";
1293 eval "\$copy = $send";
1294 my $x = new $CompressClass(\$Answer);
1295 ok $x, " Created $CompressClass object";
1296 eval { $x->write($copy) } ;
1297 #like $@, "/^$get/", " error - $get";
1298 like $@, "/not a scalar reference /", " error - not a scalar reference";
1302 # [ '[ $name1 ]', "input file '$name1' does not exist" ],
1303 # #[ "not readable", 'xx' ],
1304 # # same filehandle twice, 'xx'
1307 # foreach my $data (@data)
1309 # my ($send, $get) = @$data ;
1310 # title "${CompressClass}::write( $send )";
1312 # eval "\$copy = $send";
1313 # my $x = new $CompressClass(\$Answer);
1314 # ok $x, " Created $CompressClass object";
1315 # ok ! $x->write($copy), " write fails" ;
1316 # like $$Error, "/^$get/", " error - $get";
1326 # if (! ref $_[0] || ref $_[0] eq 'SCALAR')
1331 # if (ref $_[0] eq 'ARRAY')
1334 # for my $x ( @{ $_[0] })
1336 # push @a, deepCopy($x);
1342 # croak "bad! $_[0]";
1348 # #my $data = shift ;
1349 # my $from = $_[1] ;
1355 # if $_[0] eq $from ;
1360 # if (ref $_[0] eq 'SCALAR')
1363 # if defined ${ $_[0] } && ${ $_[0] } eq $from ;
1368 # if (ref $_[0] eq 'ARRAY')
1370 # for my $x ( @{ $_[0] })
1372 # deepSubst($x, $from, $to);
1376 # #croak "bad! $_[0]";
1380 # title "More write tests" ;
1382 # my $file1 = "file1" ;
1383 # my $file2 = "file2" ;
1384 # my $file3 = "file3" ;
1385 # my $lex = new LexFile $file1, $file2, $file3 ;
1387 # writeFile($file1, "F1");
1388 # writeFile($file2, "F2");
1389 # writeFile($file3, "F3");
1394 # [ '"abcd"', "abcd" ],
1398 # [ '\"abcd"', "abcd" ],
1404 # [ '[\undef]', "" ],
1405 # [ '[\"abcd"]', "abcd" ],
1406 # [ '[\"ab", \"cd"]', "abcd" ],
1407 # [ '[[\"ab"], [\"cd"]]', "abcd" ],
1409 # [ '$file1', $file1 ],
1411 # [ '[$file1, \"abc"]', "F1abc"],
1412 # [ '[\"a", $file1, \"bc"]', "aF1bc"],
1413 # [ '[\"a", $fh1, \"bc"]', "aF1bc"],
1414 # [ '[\"a", $fh1, \"bc", $file2]', "aF1bcF2"],
1415 # [ '[\"a", $fh1, \"bc", $file2, $fh3]', "aF1bcF2F3"],
1419 # foreach my $data (@data)
1421 # my ($send, $get) = @$data ;
1423 # my $fh1 = new IO::File "< $file1" ;
1424 # my $fh2 = new IO::File "< $file2" ;
1425 # my $fh3 = new IO::File "< $file3" ;
1427 # title "${CompressClass}::write( $send )";
1429 # eval "\$copy = $send";
1431 # my $x = new $CompressClass(\$Answer);
1432 # ok $x, " Created $CompressClass object";
1433 # my $len = length $get;
1434 # is $x->write($copy), length($get), " write $len bytes";
1435 # ok $x->close(), " close ok" ;
1437 # is myGZreadFile(\$Answer), $get, " got expected output" ;
1438 # cmp_ok $$Error, '==', 0, " no error";