(was Re: PerlIO regerssion tests?)
[p5sagit/p5-mst-13.2.git] / t / io / utf8.t
index 52b641d..1a7d27f 100755 (executable)
@@ -3,12 +3,14 @@
 BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
-    unless (exists $open::layers{'perlio'}) {
+    unless (find PerlIO::Layer 'perlio') {
        print "1..0 # Skip: not perlio\n";
        exit 0;
     }
 }
 
+no utf8; # needed for use utf8 not griping about the raw octets
+
 $| = 1;
 my $total_tests = 25;
 if (ord('A') == 193) { $total_tests = 24; } # EBCDIC platforms do not warn on UTF-8
@@ -135,8 +137,13 @@ print "ok 21\n";
 
 # Now let's make it suffer.
 open F, ">", "a" or die $!;
-eval { print F $a; };
-print "not " unless $@ and $@ =~ /Wide character in print/i;
+my $w;
+{
+    use warnings 'utf8';
+    local $SIG{__WARN__} = sub { $w = $_[0] };
+    print F $a;
+}
+print "not " if ($@ || $w !~ /Wide character in print/i);
 print "ok 22\n";
 }
 
@@ -174,5 +181,6 @@ $x = <F>; chomp $x;
 eval { sprintf "%vd\n", $x; }
 }
 
+close F;
 unlink('a');