Upgrade to Encode 1.42, from Dan Kogai.
[p5sagit/p5-mst-13.2.git] / ext / Encode / t / JP.t
index c9b1dde..89238b5 100644 (file)
@@ -8,10 +8,6 @@ BEGIN {
       print "1..0 # Skip: Encode was not built\n";
       exit 0;
     }
-    unless (find PerlIO::Layer 'perlio') {
-       print "1..0 # Skip: PerlIO was not built\n";
-       exit 0;
-    }
     if (ord("A") == 193) {
        print "1..0 # Skip: EBCDIC\n";
        exit 0;
@@ -77,47 +73,51 @@ ok(compare($euc,$rnd) == 0);
 
 is($enc->name,'euc-jp');
 
-print "# src :encoding test\n";
-open($src,"<encoding(euc-jp)",$euc) || die "Cannot open $euc:$!";
-binmode($src);
-ok(defined($src) && fileno($src));
-open($dst,">:utf8",$utf) || die "Cannot open $utf:$!";
-binmode($dst);
-ok(defined($dst) || fileno($dst));
-my $out = select($dst);
-while (<$src>)
- {
-  print;
- }
-close($dst);
-close($src);
-
-TODO:
-{
-  local $TODO = 'needs debugging on VMS' if $^O eq 'VMS';
-  ok(compare($utf,$ref) == 0);
+my $skip_perlio;
+eval { require PerlIO::encoding; };
+if ($@){
+    $skip_perlio = 1;
+}else{
+    $skip_perlio = 0;
+    binmode(STDIN);
 }
-select($out);
 
-SKIP:
-{
- #skip "Multi-byte write is broken",3;
- print "# dst :encoding test\n";
- open($src,"<:utf8",$ref) || die "Cannot open $ref:$!";
- binmode($src);
- ok(defined($src) || fileno($src));
- open($dst,">encoding(euc-jp)",$rnd) || die "Cannot open $rnd:$!";
- binmode($dst);
- ok(defined($dst) || fileno($dst));
- my $out = select($dst);
- while (<$src>)
-  {
-   print;
-  }
- close($dst);
- close($src);
- ok(compare($euc,$rnd) == 0);
- select($out);
+$skip_perlio ||= (@ARGV and shift eq 'perlio');
+
+SKIP: {
+    skip "PerlIO Encoding Needed", 6 if $skip_perlio;
+    print "# src :encoding test\n";
+    open($src,"<encoding(euc-jp)",$euc) || die "Cannot open $euc:$!";
+    binmode($src);
+    ok(defined($src) && fileno($src));
+    open($dst,">:utf8",$utf) || die "Cannot open $utf:$!";
+    binmode($dst);
+    ok(defined($dst) || fileno($dst));
+    my $out = select($dst);
+    while (<$src>){ print; }
+    close($dst);
+    close($src);
+
+ TODO:
+    {
+       local $TODO = 'needs debugging on VMS' if $^O eq 'VMS';
+       ok(compare($utf,$ref) == 0);
+    }
+    select($out);
+
+    print "# dst :encoding test\n";
+    open($src,"<:utf8",$ref) || die "Cannot open $ref:$!";
+    binmode($src);
+    ok(defined($src) || fileno($src));
+    open($dst,">encoding(euc-jp)",$rnd) || die "Cannot open $rnd:$!";
+    binmode($dst);
+    ok(defined($dst) || fileno($dst));
+    $out = select($dst);
+    while (<$src>) { print; }
+    close($dst);
+    close($src);
+    ok(compare($euc,$rnd) == 0);
+    select($out);
 }
 
 is($enc->name,'euc-jp');