Re: [perl #18888] $Exporter::Verbose=1 does not work for testing, $Heavy::Verbose...
[p5sagit/p5-mst-13.2.git] / lib / utf8.t
index 19d88e5..41a7368 100644 (file)
@@ -1,11 +1,20 @@
 #!./perl 
 
+my $has_perlio;
+
 BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
+    unless ($has_perlio = find PerlIO::Layer 'perlio') {
+       print <<EOF;
+# Since you don't have perlio you might get failures with UTF-8 locales.
+EOF
+    }
 }
 
+no utf8; # Ironic, no?
+
 # NOTE!
 #
 # Think carefully before adding tests here.  In general this should be
@@ -28,7 +37,7 @@ BEGIN {
 #
 #
 
-plan tests => 94;
+plan tests => 95;
 
 {
     # bug id 20001009.001
@@ -159,13 +168,13 @@ plan tests => 94;
     use utf8; %a = ("\xE1\xA0"=>"sterling");
     print 'start'; printf '%x,', ord \$_ foreach keys %a; print "end\n";
 BANG
-             qr/^Malformed UTF-8 character \(2 bytes, need 3.+\).*start\d+,end$/s
+             qr/^Malformed UTF-8 character \(\d bytes?, need \d, .+\).*start\d+,end$/sm
             ],
             );
     foreach (@tests) {
         my ($why, $prog, $expect) = @$_;
         open P, ">$progfile" or die "Can't open '$progfile': $!";
-        binmode(P, ":bytes");
+        binmode(P, ":bytes") if $has_perlio;
        print P $show, $prog, '; print $b'
             or die "Print to 'progfile' failed: $!";
         close P or die "Can't close '$progfile': $!";
@@ -256,3 +265,18 @@ BANG
         like ($result, $expect, $why);
     }
 }
+
+#
+# bug fixed by change #17928
+# separate perl used because we rely on 'strict' not yet loaded;
+# before the patch, the eval died with an error like:
+#   "my" variable $strict::VERSION can't be in a package
+#
+ok('' eq runperl(prog => <<'CODE'));
+    my $code = qq{ my \$\xe3\x83\x95\xe3\x83\xbc = 5; };
+    {
+       use utf8;
+       eval $code;
+       print $@ if $@;
+    }
+CODE