Upgrade to Encode 2.00.
[p5sagit/p5-mst-13.2.git] / ext / Encode / t / enc_module.t
index 21f0621..7cc150c 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: enc_module.t,v 1.3 2003/03/09 20:07:37 dankogai Exp dankogai $
+# $Id: enc_module.t,v 2.0 2004/05/16 20:55:18 dankogai Exp $
 # This file is in euc-jp
 BEGIN {
     require Config; import Config;
@@ -27,22 +27,27 @@ use File::Basename;
 use File::Spec;
 use File::Compare qw(compare_text);
 
+my $DEBUG = shift || 0;
 my $dir = dirname(__FILE__);
 my $file0 = File::Spec->catfile($dir,"enc_module.enc");
 my $file1 = File::Spec->catfile($dir,"$$.enc");
 
 my $obj = Mod_EUCJP->new;
-local $SIG{__WARN__} = sub{}; # to silence reopening STD(IN|OUT) w/o closing
+local $SIG{__WARN__} = sub{ $DEBUG and print STDERR @_ };
+# to silence reopening STD(IN|OUT) w/o closing unless $DEBUG
 
 open STDOUT, ">", $file1 or die "$file1:$!";
 print $obj->str, "\n";
 $obj->set("¥Æ¥¹¥Èʸ»úÎó");
 print $obj->str, "\n";
-close STDOUT;
+
+# Please do not move this to a point after the comparison -- Craig Berry
+# and "unless $^O eq 'freebsd'" is needed for FreeBSD (toy-)?thread
+# -- dankogai
+close STDOUT unless $^O eq 'freebsd';
 
 my $cmp = compare_text($file0, $file1);
 is($cmp, 0, "encoding vs. STDOUT");
-unlink $file1 unless $cmp;
 
 my @cmp = qw/½é´üʸ»úÎó ¥Æ¥¹¥Èʸ»úÎó/;
 open STDIN, "<", $file0 or die "$file0:$!";
@@ -53,5 +58,6 @@ while(<STDIN>){
     is ($cmp[$i++], $_, "encoding vs. STDIN - $i");
 }
 
+unlink $file1 unless $cmp;
 __END__