Upgrade to Encode 1.42, from Dan Kogai.
[p5sagit/p5-mst-13.2.git] / ext / Encode / t / KR.t
index fd1c503..e42271b 100644 (file)
@@ -77,47 +77,51 @@ ok(compare($euc,$rnd) == 0);
 
 is($enc->name,'euc-kr');
 
-print "# src :encoding test\n";
-open($src,"<encoding(euc-kr)",$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-kr)",$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-kr)",$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-kr)",$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-kr');