This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/op/warn.t: Generalize for non-ASCII platforms
authorKarl Williamson <public@khwilliamson.com>
Tue, 16 Apr 2013 17:50:04 +0000 (11:50 -0600)
committerKarl Williamson <khw@cpan.org>
Fri, 6 Mar 2015 04:48:26 +0000 (21:48 -0700)
t/op/warn.t

index 4d679c2..42b88f8 100644 (file)
@@ -3,7 +3,7 @@
 
 BEGIN {
     chdir 't' if -d 't';
-    require './test.pl';
+    require './test.pl'; require './charset_tools.pl';
     set_up_inc('../lib');
 }
 
@@ -121,22 +121,25 @@ fresh_perl_like(
 
 SKIP: {
     skip_if_miniperl('miniperl ignores -C', 1);
+   $ee = uni_to_native("\xee");
+   $bytes = byte_utf8a_to_utf8n("\xc3\xae");
 fresh_perl_like(
- '
-   $a = "\xee\n";
-   print STDERR $a; warn $a;
-   utf8::upgrade($a);
-   print STDERR $a; warn $a;
',
-  qr/^\xc3\xae(?:\r?\n\xc3\xae){3}/,
+ "
+   \$a = \"$ee\n\";
+   print STDERR \$a; warn \$a;
+   utf8::upgrade(\$a);
+   print STDERR \$a; warn \$a;
",
+  qr/^$bytes(?:\r?\n$bytes){3}/,
   { switches => ['-CE'] },
  'warn respects :utf8 layer'
 );
 }
 
+$bytes = byte_utf8a_to_utf8n("\xc4\xac");
 fresh_perl_like(
  'warn chr 300',
-  qr/^Wide character in warn .*\n\xc4\xac at /,
+  qr/^Wide character in warn .*\n$bytes at /,
   { switches => [ "-C0" ] },
  'Wide character in warn (not print)'
 );