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; };
23 plan(tests => 564 + $extra) ;
31 my $filename = shift ;
35 my $fil = new $UncompressClass $filename,
41 $data = $init if defined $init ;
42 1 while $fil->read($data) > 0;
51 my $CompressClass = identify();
52 $UncompressClass = getInverse($CompressClass);
53 my $Error = getErrorRef($CompressClass);
54 my $UnError = getErrorRef($UncompressClass);
58 title "Testing $CompressClass Errors";
61 eval qq[\$a = new $CompressClass(\\1) ;] ;
62 like $@, mkEvalErr("^$CompressClass: output buffer is read-only") ;
66 eval qq[\$a = new $CompressClass ] . '$out ;' ;
67 like $@, mkEvalErr("^$CompressClass: output filename is undef or null string");
70 eval qq[\$a = new $CompressClass \$out ;] ;
71 like $@, mkEvalErr("^$CompressClass: output filename is undef or null string");
74 $gz = new $CompressClass(\$x);
76 foreach my $name (qw(read readline getc))
78 eval " \$gz->$name() " ;
79 like $@, mkEvalErr("^$name Not Available: File opened only for output");
82 eval ' $gz->write({})' ;
83 like $@, mkEvalErr("^${CompressClass}::write: not a scalar reference");
84 #like $@, mkEvalErr("^${CompressClass}::write: input parameter not a filename, filehandle, array ref or scalar ref");
86 eval ' $gz->syswrite("abc", 1, 5)' ;
87 like $@, mkEvalErr("^${CompressClass}::write: offset outside string");
89 eval ' $gz->syswrite("abc", 1, -4)' ;
90 like $@, mkEvalErr("^${CompressClass}::write: offset outside string");
95 title "Testing $UncompressClass Errors";
98 eval qq[\$a = new $UncompressClass \$out ;] ;
99 like $@, mkEvalErr("^$UncompressClass: input filename is undef or null string");
101 eval qq[\$a = new $UncompressClass \$out ;] ;
102 like $@, mkEvalErr("^$UncompressClass: input filename is undef or null string");
104 my $lex = new LexFile my $name ;
106 ok ! -e $name, " $name does not exist";
108 eval qq[\$a = new $UncompressClass "$name" ;] ;
109 is $$UnError, "input file '$name' does not exist";
112 my $guz = new $CompressClass(\$gc);
117 my $gz = new $UncompressClass(\$gc);
119 foreach my $name (qw(print printf write))
121 eval " \$gz->$name() " ;
122 like $@, mkEvalErr("^$name Not Available: File opened only for intput");
128 title "Testing $CompressClass and $UncompressClass";
131 my ($a, $x, @x) = ("","","") ;
133 # Buffer not a scalar reference
134 eval qq[\$a = new $CompressClass \\\@x ;] ;
135 like $@, mkEvalErr("^$CompressClass: output parameter not a filename, filehandle or scalar ref");
137 # Buffer not a scalar reference
138 eval qq[\$a = new $UncompressClass \\\@x ;] ;
139 like $@, mkEvalErr("^$UncompressClass: input parameter not a filename, filehandle, array ref or scalar ref");
142 foreach my $Type ( $CompressClass, $UncompressClass)
144 # Check error handling with IO::Compress::Deflate and IO::Uncompress::Inflate
146 my ($a, $x, @x) = ("","","") ;
148 # Odd number of parameters
149 eval qq[\$a = new $Type "abc", -Output ] ;
150 like $@, mkEvalErr("^$Type: Expected even number of parameters, got 1");
153 eval qq[\$a = new $Type "anc", -Fred => 123 ;] ;
154 like $@, mkEvalErr("^$Type: unknown key value\\(s\\) Fred");
157 eval qq[\$a = new $Type ;] ;
158 like $@, mkEvalErr("^$Type: Missing (Input|Output) parameter");
164 # write a very simple compressed file
166 #========================================
169 my $lex = new LexFile my $name ;
178 ok $x = new $CompressClass $name ;
180 ok $x->write($hello), "write" ;
181 ok $x->flush(), "flush";
182 ok $x->close, "close" ;
187 ok my $x = new $UncompressClass $name, -Append => 1 ;
190 1 while ($len = $x->read($uncomp)) > 0 ;
192 is $len, 0, "read returned 0"
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 ;
294 title "$CompressClass: Input from typeglob filehandle";
295 ok open FH, ">$name" ;
297 my $x = new $CompressClass *FH ;
298 ok $x, " create $CompressClass" ;
300 is $x->fileno(), fileno(*FH), " fileno" ;
301 is $x->write(''), 0, " Write empty string is ok";
302 is $x->write(undef), 0, " Write undef is ok";
303 ok $x->write($hello), " Write ok" ;
304 ok $x->flush(), " Flush";
305 ok $x->close, " Close" ;
312 title "$UncompressClass: Input from typeglob filehandle, append output";
314 ok open FH, "<$name" ;
315 ok $x = new $UncompressClass *FH, -Append => 1, Transparent => 0
317 is $x->fileno(), fileno FH, " fileno ok" ;
319 1 while $x->read($uncomp) > 0 ;
321 ok $x->close, " close" ;
325 is $uncomp, $hello, " expected output" ;
329 my $lex = new LexFile my $name ;
337 title "Outout to stdout via '-'" ;
339 open(SAVEOUT, ">&STDOUT");
340 my $dummy = fileno SAVEOUT;
341 open STDOUT, ">$name" ;
343 my $x = new $CompressClass '-' ;
347 open(STDOUT, ">&SAVEOUT");
349 ok 1, " wrote to stdout" ;
353 title "Input from stdin via filename '-'";
357 my $stdinFileno = fileno(STDIN);
358 # open below doesn't return 1 sometines on XP
359 open(SAVEIN, "<&STDIN");
360 ok open(STDIN, "<$name"), " redirect STDIN";
361 my $dummy = fileno SAVEIN;
362 $x = new $UncompressClass '-', Append => 1;
363 ok $x, " created object" ;
364 is $x->fileno(), $stdinFileno, " fileno ok" ;
366 1 while $x->read($uncomp) > 0 ;
368 ok $x->close, " close" ;
369 open(STDIN, "<&SAVEIN");
370 is $uncomp, $hello, " expected output" ;
375 # write a compressed file to memory
377 #========================================
379 my $name = "test.gz" ;
389 ok $x = new $CompressClass(\$buffer) ;
391 ok ! defined $x->fileno() ;
392 is $x->write(''), 0, "Write empty string is ok";
393 is $x->write(undef), 0, "Write undef is ok";
394 ok $x->write($hello) ;
398 writeFile($name, $buffer) ;
399 #is anyUncompress(\$buffer), $hello, " any ok";
406 ok $x = new $UncompressClass(\$buffer, Append => 1) ;
408 ok ! defined $x->fileno() ;
409 1 while $x->read($uncomp) > 0 ;
415 ok $buffer eq $keep ;
418 if ($CompressClass ne 'RawDeflate')
421 #========================================
426 ok $x = new $CompressClass(\$buffer) ;
435 ok $x = new $UncompressClass(\$buffer, Append => 1) ;
437 1 while $x->read($uncomp) > 0 ;
443 ok $buffer eq $keep ;
448 # write a larger file
449 #========================================
452 my $lex = new LexFile my $name ;
463 my $x = new $CompressClass $name ;
464 ok $x, " created $CompressClass object";
466 ok $x->write($hello), " write ok" ;
468 ok $x->write("another line"), " write ok" ;
469 $input .= "another line" ;
472 { $contents .= chr int $_ }
473 # generate a long random string
475 { $contents .= chr int rand 256 }
477 ok $x->write($contents), " write ok" ;
478 $input .= $contents ;
479 ok $x->close, " close ok" ;
482 ok myGZreadFile($name) eq $input ;
483 my $x = readFile($name) ;
484 #print "length " . length($x) . " \n";
488 # embed a compressed file in another file
489 #================================
492 my $lex = new LexFile my $name ;
499 my $header = "header info\n" ;
500 my $trailer = "trailer data\n" ;
504 ok $fh = new IO::File ">$name" ;
507 ok $x = new $CompressClass $fh,
511 ok $x->write($hello) ;
519 ok $fh1 = new IO::File "<$name" ;
522 ok $line eq $header ;
524 ok my $x = new $UncompressClass $fh1, Append => 1 ;
526 1 while $x->read($uncomp) > 0 ;
528 ok $uncomp eq $hello ;
530 read($fh1, $rest, 5000);
531 is $x->trailingData() . $rest, $trailer ;
532 #print "# [".$x->trailingData() . "][$rest]\n" ;
539 # these tests come almost 100% from IO::String
541 my $lex = new LexFile my $name ;
543 my $io = $CompressClass->new($name);
545 is $io->tell(), 0, " tell returns 0"; ;
547 my $heisan = "Heisan\n";
548 $io->print($heisan) ;
550 ok ! $io->eof(), " ! eof";
552 is $io->tell(), length($heisan), " tell is " . length($heisan) ;
554 $io->print("a", "b", "c");
558 $io->print("d", "e");
560 $io->print("f", "g", "h");
565 $io->print("D", "E");
567 $io->print("F", "G", "H");
570 my $foo = "1234567890";
572 is $io->syswrite($foo, length($foo)), length($foo), " syswrite ok" ;
574 { is $io->syswrite($foo, length $foo), length $foo, " syswrite ok" }
576 { is $io->syswrite($foo), length $foo, " syswrite ok" }
577 is $io->syswrite($foo, length($foo)), length $foo, " syswrite ok";
578 is $io->write($foo, length($foo), 5), 5, " write 5";
579 is $io->write("xxx\n", 100, -1), 1, " write 1";
582 $io->printf("i(%d)", $_);
583 $io->printf("[%d]\n", $_);
589 ok $io->eof(), " eof";
591 is myGZreadFile($name), "Heisan\nabcde\nf,g,h\nDEF.G.H" .
592 ("1234567890" x 3) . "67890\n" .
593 "i(1)[1]\ni(2)[2]\ni(3)[3]\n\n";
609 my $lex = new LexFile my $name ;
612 my $iow = new $CompressClass $name, %opts;
619 my $io = new $UncompressClass $name ;
624 my @lines = $io->getlines();
626 or print "# Got " . scalar(@lines) . " lines, expected 6\n" ;
627 is $lines[1], "of a paragraph\n" ;
628 is join('', @lines), $str ;
630 is $io->tell(), length($str) ;
634 ok ! ( defined($io->getline) ||
635 (@tmp = $io->getlines) ||
636 defined($io->getline) ||
637 defined($io->getc) ||
638 $io->read($buf, 100) != 0) ;
643 local $/; # slurp mode
644 my $io = $UncompressClass->new($name);
646 my @lines = $io->getlines;
648 ok @lines == 1 && $lines[0] eq $str;
650 $io = $UncompressClass->new($name);
652 my $line = $io->getline();
658 local $/ = ""; # paragraph mode
659 my $io = $UncompressClass->new($name);
661 my @lines = $io->getlines();
664 or print "# Got " . scalar(@lines) . " lines, expected 2\n" ;
665 ok $lines[0] eq "This is an example\nof a paragraph\n\n\n"
666 or print "# $lines[0]\n";
667 ok $lines[1] eq "and a single line.\n\n";
672 my $io = $UncompressClass->new($name);
677 while (my $a = $io->getline()) {
679 $err++ if $. != ++$no;
686 or print "# Got " . scalar(@lines) . " lines, expected 3\n" ;
687 ok join("-", @lines) eq
688 "This- is- an example\n" .
689 "of a paragraph\n\n\n" .
690 "and a single line.\n\n";
697 my $io = $UncompressClass->new($name);
700 eval { $io->read(1) } ;
701 like $@, mkErr("buffer parameter is read-only");
703 is $io->read($buf, 0), 0, "Requested 0 bytes" ;
705 ok $io->read($buf, 3) == 3 ;
708 ok $io->sysread($buf, 3, 2) == 3 ;
710 or print "# [$buf]\n" ;;
717 # ok read($io, $buf, 20) == 4 ;
718 # ok $buf eq "e.\n\n";
720 # ok read($io, $buf, 20) == 0 ;
729 # Read from non-compressed file
740 my $lex = new LexFile my $name ;
742 writeFile($name, $str);
746 my $io = new $UncompressClass $name, -Transparent => 1 ;
750 ok $io->tell() == 0 ;
751 my @lines = $io->getlines();
753 ok $lines[1] eq "of a paragraph\n" ;
754 ok join('', @lines) eq $str ;
756 ok $io->tell() == length($str) ;
760 ok ! ( defined($io->getline) ||
761 (@tmp = $io->getlines) ||
762 defined($io->getline) ||
763 defined($io->getc) ||
764 $io->read($buf, 100) != 0) ;
769 local $/; # slurp mode
770 my $io = $UncompressClass->new($name);
772 my @lines = $io->getlines;
774 ok @lines == 1 && $lines[0] eq $str;
776 $io = $UncompressClass->new($name);
778 my $line = $io->getline;
784 local $/ = ""; # paragraph mode
785 my $io = $UncompressClass->new($name);
787 my @lines = $io->getlines;
790 or print "# exected 2 lines, got " . scalar(@lines) . "\n";
791 ok $lines[0] eq "This is an example\nof a paragraph\n\n\n"
792 or print "# [$lines[0]]\n" ;
793 ok $lines[1] eq "and a single line.\n\n";
798 my $io = $UncompressClass->new($name);
803 while (my $a = $io->getline) {
805 $err++ if $. != ++$no;
812 ok join("-", @lines) eq
813 "This- is- an example\n" .
814 "of a paragraph\n\n\n" .
815 "and a single line.\n\n";
822 my $io = $UncompressClass->new($name);
824 ok $io->read($buf, 3) == 3 ;
827 ok $io->sysread($buf, 3, 2) == 3 ;
835 # ok read($io, $buf, 20) == 4 ;
836 # ok $buf eq "e.\n\n";
838 # ok read($io, $buf, 20) == 0 ;
848 # Vary the length parameter in a read
863 foreach my $bufsize (1, 3, 512, 4096, length($str)-1, length($str), length($str)+1)
865 foreach my $trans (0, 1)
867 foreach my $append (0, 1)
869 title "Read Tests - buf length $bufsize, Transparent $trans, Append $append" ;
871 my $lex = new LexFile my $name ;
874 writeFile($name, $str) ;
877 my $iow = new $CompressClass $name;
883 my $io = $UncompressClass->new($name,
885 -Transparent => $trans);
892 1 while $io->read($buf, $bufsize) > 0;
896 $buf .= $tmp while $io->read($tmp, $bufsize) > 0 ;
898 is length $buf, length $str;
907 foreach my $file (0, 1)
909 foreach my $trans (0, 1)
911 title "seek tests - file $file trans $trans" ;
915 my $lex = new LexFile my $name ;
917 my $first = "beginning" ;
918 my $last = "the end" ;
922 $buffer = $first . "\x00" x 10 . $last;
923 writeFile($name, $buffer);
937 my $iow = new $CompressClass $output ;
938 $iow->print($first) ;
939 ok $iow->seek(5, SEEK_CUR) ;
940 ok $iow->tell() == length($first)+5;
941 ok $iow->seek(0, SEEK_CUR) ;
942 ok $iow->tell() == length($first)+5;
943 ok $iow->seek(length($first)+10, SEEK_SET) ;
944 ok $iow->tell() == length($first)+10;
960 ok myGZreadFile($input) eq $first . "\x00" x 10 . $last ;
962 my $io = $UncompressClass->new($input, Strict => 1);
963 ok $io->seek(length($first), SEEK_CUR) ;
965 is $io->tell(), length($first);
967 ok $io->read($buff, 5) ;
968 is $buff, "\x00" x 5 ;
969 is $io->tell(), length($first) + 5;
971 ok $io->seek(0, SEEK_CUR) ;
972 my $here = $io->tell() ;
973 is $here, length($first)+5;
975 ok $io->seek($here+5, SEEK_SET) ;
976 is $io->tell(), $here+5 ;
977 ok $io->read($buff, 100) ;
984 title "seek error cases" ;
987 my $a = new $CompressClass(\$b) ;
990 eval { $a->seek(-1, 10) ; };
991 like $@, mkErr("^${CompressClass}::seek: unknown value, 10, for whence parameter");
993 eval { $a->seek(-1, SEEK_END) ; };
994 like $@, mkErr("^${CompressClass}::seek: cannot seek backwards");
1000 my $u = new $UncompressClass(\$b) ;
1002 eval { $u->seek(-1, 10) ; };
1003 like $@, mkErr("^${UncompressClass}::seek: unknown value, 10, for whence parameter");
1005 eval { $u->seek(-1, SEEK_END) ; };
1006 like $@, mkErr("^${UncompressClass}::seek: SEEK_END not allowed");
1008 eval { $u->seek(-1, SEEK_CUR) ; };
1009 like $@, mkErr("^${UncompressClass}::seek: cannot seek backwards");
1012 foreach my $fb (qw(filename buffer filehandle))
1014 foreach my $append (0, 1)
1017 title "$CompressClass -- Append $append, Output to $fb" ;
1019 my $lex = new LexFile my $name ;
1021 my $already = 'already';
1022 my $buffer = $already;
1025 if ($fb eq 'buffer')
1026 { $output = \$buffer }
1027 elsif ($fb eq 'filename')
1030 writeFile($name, $buffer);
1032 elsif ($fb eq 'filehandle')
1034 $output = new IO::File ">$name" ;
1035 print $output $buffer;
1038 my $a = new $CompressClass($output, Append => $append) ;
1039 ok $a, " Created $CompressClass";
1040 my $string = "appended";
1045 if ($fb eq 'buffer')
1052 if $fb eq 'filehandle';
1053 $data = readFile($name);
1056 if ($append || $fb eq 'filehandle')
1058 is substr($data, 0, length($already)), $already, " got prefix";
1059 substr($data, 0, length($already)) = '';
1064 my $x = new $UncompressClass(\$data, Append => 1) ;
1065 ok $x, " created $UncompressClass";
1068 1 while ($len = $x->read($uncomp)) > 0 ;
1071 is $uncomp, $string, ' Got uncompressed data' ;
1077 foreach my $type (qw(buffer filename filehandle))
1079 title "$UncompressClass -- InputLength, read from $type";
1082 my $string = "some data";
1083 my $c = new $CompressClass(\$compressed);
1087 my $appended = "append";
1088 my $comp_len = length $compressed;
1089 $compressed .= $appended;
1091 my $lex = new LexFile my $name ;
1093 writeFile ($name, $compressed);
1095 if ($type eq 'buffer')
1097 $input = \$compressed;
1099 if ($type eq 'filename')
1103 elsif ($type eq 'filehandle')
1105 my $fh = new IO::File "<$name" ;
1106 ok $fh, "opened file $name ok";
1110 my $x = new $UncompressClass($input, InputLength => $comp_len) ;
1111 ok $x, " created $UncompressClass";
1115 $len = $x->read($output, 100);
1116 is $len, length($string);
1117 is $output, $string;
1119 if ($type eq 'filehandle')
1122 $input->read($rest, 1000);
1123 is $rest, $appended;
1129 foreach my $append (0, 1)
1131 title "$UncompressClass -- Append $append" ;
1133 my $lex = new LexFile my $name ;
1135 my $string = "appended";
1137 my $c = new $CompressClass(\$compressed);
1141 my $x = new $UncompressClass(\$compressed, Append => $append) ;
1142 ok $x, " created $UncompressClass";
1144 my $already = 'already';
1145 my $output = $already;
1148 $len = $x->read($output, 100);
1149 is $len, length($string);
1155 is substr($output, 0, length($already)), $already, " got prefix";
1156 substr($output, 0, length($already)) = '';
1158 is $output, $string, ' Got uncompressed data' ;
1162 foreach my $file (0, 1)
1164 foreach my $trans (0, 1)
1166 title "ungetc, File $file, Transparent $trans" ;
1168 my $lex = new LexFile my $name ;
1170 my $string = 'abcdeABCDE';
1178 my $a = new $CompressClass(\$b) ;
1186 writeFile($name, $b);
1194 my $u = $UncompressClass->new($from, Transparent => 1) ;
1198 # do an ungetc before reading
1200 $first = $u->getc();
1203 $first = $u->getc();
1204 is $first, substr($string, 0,1);
1206 $first = $u->getc();
1207 is $first, substr($string, 0,1);
1210 is $u->read($buff, 5), 5 ;
1211 is $buff, substr($string, 0, 5);
1214 is $u->read($buff, length($string)), length($string) ;
1217 is $u->read($buff, 1), 0;
1220 my $extra = 'extra';
1223 is $u->read($buff), length($extra) ;
1226 is $u->read($buff, 1), 0;
1236 title "write tests - invalid data" ;
1238 #my $lex = new LexFile my $name1 ;
1241 #ok ! -e $name1, " File $name1 does not exist";
1244 [ '{ }', "${CompressClass}::write: input parameter not a filename, filehandle, array ref or scalar ref" ],
1245 [ '[ { } ]', "${CompressClass}::write: input parameter not a filename, filehandle, array ref or scalar ref" ],
1246 [ '[ [ { } ] ]', "${CompressClass}::write: input parameter not a filename, filehandle, array ref or scalar ref" ],
1247 [ '[ "" ]', "${CompressClass}::write: input filename is undef or null string" ],
1248 [ '[ undef ]', "${CompressClass}::write: input filename is undef or null string" ],
1249 [ '[ \$Answer ]',"${CompressClass}::write: input and output buffer are identical" ],
1250 #[ "not readable", 'xx' ],
1251 # same filehandle twice, 'xx'
1254 foreach my $data (@data)
1256 my ($send, $get) = @$data ;
1257 title "${CompressClass}::write( $send )";
1259 eval "\$copy = $send";
1260 my $x = new $CompressClass(\$Answer);
1261 ok $x, " Created $CompressClass object";
1262 eval { $x->write($copy) } ;
1263 #like $@, "/^$get/", " error - $get";
1264 like $@, "/not a scalar reference /", " error - not a scalar reference";
1268 # [ '[ $name1 ]', "input file '$name1' does not exist" ],
1269 # #[ "not readable", 'xx' ],
1270 # # same filehandle twice, 'xx'
1273 # foreach my $data (@data)
1275 # my ($send, $get) = @$data ;
1276 # title "${CompressClass}::write( $send )";
1278 # eval "\$copy = $send";
1279 # my $x = new $CompressClass(\$Answer);
1280 # ok $x, " Created $CompressClass object";
1281 # ok ! $x->write($copy), " write fails" ;
1282 # like $$Error, "/^$get/", " error - $get";
1292 # if (! ref $_[0] || ref $_[0] eq 'SCALAR')
1297 # if (ref $_[0] eq 'ARRAY')
1300 # for my $x ( @{ $_[0] })
1302 # push @a, deepCopy($x);
1308 # croak "bad! $_[0]";
1314 # #my $data = shift ;
1315 # my $from = $_[1] ;
1321 # if $_[0] eq $from ;
1326 # if (ref $_[0] eq 'SCALAR')
1329 # if defined ${ $_[0] } && ${ $_[0] } eq $from ;
1334 # if (ref $_[0] eq 'ARRAY')
1336 # for my $x ( @{ $_[0] })
1338 # deepSubst($x, $from, $to);
1342 # #croak "bad! $_[0]";
1346 # title "More write tests" ;
1348 # my $file1 = "file1" ;
1349 # my $file2 = "file2" ;
1350 # my $file3 = "file3" ;
1351 # my $lex = new LexFile $file1, $file2, $file3 ;
1353 # writeFile($file1, "F1");
1354 # writeFile($file2, "F2");
1355 # writeFile($file3, "F3");
1360 # [ '"abcd"', "abcd" ],
1364 # [ '\"abcd"', "abcd" ],
1370 # [ '[\undef]', "" ],
1371 # [ '[\"abcd"]', "abcd" ],
1372 # [ '[\"ab", \"cd"]', "abcd" ],
1373 # [ '[[\"ab"], [\"cd"]]', "abcd" ],
1375 # [ '$file1', $file1 ],
1377 # [ '[$file1, \"abc"]', "F1abc"],
1378 # [ '[\"a", $file1, \"bc"]', "aF1bc"],
1379 # [ '[\"a", $fh1, \"bc"]', "aF1bc"],
1380 # [ '[\"a", $fh1, \"bc", $file2]', "aF1bcF2"],
1381 # [ '[\"a", $fh1, \"bc", $file2, $fh3]', "aF1bcF2F3"],
1385 # foreach my $data (@data)
1387 # my ($send, $get) = @$data ;
1389 # my $fh1 = new IO::File "< $file1" ;
1390 # my $fh2 = new IO::File "< $file2" ;
1391 # my $fh3 = new IO::File "< $file3" ;
1393 # title "${CompressClass}::write( $send )";
1395 # eval "\$copy = $send";
1397 # my $x = new $CompressClass(\$Answer);
1398 # ok $x, " Created $CompressClass object";
1399 # my $len = length $get;
1400 # is $x->write($copy), length($get), " write $len bytes";
1401 # ok $x->close(), " close ok" ;
1403 # is myGZreadFile(\$Answer), $get, " got expected output" ;
1404 # cmp_ok $$Error, '==', 0, " no error";