This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/uni/case.pl: Fix to work on non-ASCII platforms
authorKarl Williamson <khw@cpan.org>
Mon, 24 Nov 2014 18:19:22 +0000 (11:19 -0700)
committerKarl Williamson <khw@cpan.org>
Fri, 6 Mar 2015 04:48:28 +0000 (21:48 -0700)
This involves changes to the three test files that call it

t/uni/case.pl
t/uni/lower.t
t/uni/title.t
t/uni/upper.t

index 72de5e8..d4bfc07 100644 (file)
@@ -5,9 +5,10 @@ BEGIN {
 }
 use strict;
 use warnings;
+use feature 'unicode_strings';
 
 sub unidump {
-    join "", map { sprintf "\\x{%04X}", $_ } unpack "U*", $_[0];
+    join "", map { sprintf "\\x{%04X}", $_ } unpack "W*", $_[0];
 }
 
 sub casetest {
@@ -52,7 +53,7 @@ sub casetest {
         else {  # The return is a list of the characters mapped-to.
                 # prop_invmap() guarantees a single element in the range in
                 # this case, so no adjustments are needed.
-            $spec{$invlist_ref->[$i]} = pack "U0U*" , @{$invmap_ref->[$i]};
+            $spec{$invlist_ref->[$i]} = pack "W*" , @{$invmap_ref->[$i]};
         }
     }
 
@@ -73,7 +74,7 @@ sub casetest {
     my %none;
     for my $i (map { ord } split //,
               "\e !\"#\$%&'()+,-./0123456789:;<=>?\@[\\]^_{|}~\b") {
-       next if pack("U0U", $i) =~ /\w/;
+       next if pack("W", $i) =~ /\w/;
        $none{$i}++ unless $seen{$i};
     }
     print "# ", scalar keys %none, " noncase mappings\n";
@@ -82,10 +83,10 @@ sub casetest {
     my $test = $already_run + 1;
 
     for my $ord (sort keys %simple) {
-       my $char = pack "U0U", $ord;
+       my $char = pack "W", $ord;
         my $disp_input = unidump($char);
 
-        my $expected = pack("U0U", $simple{$ord});
+        my $expected = pack("W", $simple{$ord});
         my $disp_expected = unidump($expected);
 
        foreach my $name (sort keys %funcs) {
@@ -96,7 +97,7 @@ sub casetest {
     }
 
     for my $ord (sort keys %spec) {
-       my $char = chr($ord); $char .= chr(0x100); chop $char;
+       my $char = pack "W", $ord;
         my $disp_input = unidump($char);
 
        my $expected = unidump($spec{$ord});
@@ -109,7 +110,7 @@ sub casetest {
     }
 
     for my $ord (sort { $a <=> $b } keys %none) {
-       my $char = pack "U0U", $ord;
+       my $char = pack "W", $ord;
         my $disp_input = unidump($char);
 
        foreach my $name (sort keys %funcs) {
index 2e6fb2e..1301b48 100644 (file)
@@ -3,6 +3,8 @@ BEGIN {
     require "uni/case.pl";
 }
 
+use feature 'unicode_strings';
+
 casetest(0, # No extra tests run here,
        "Lowercase_Mapping",
         lc                             => sub { lc $_[0] },
index a043529..35c4f77 100644 (file)
@@ -3,6 +3,8 @@ BEGIN {
     require "uni/case.pl";
 }
 
+use feature 'unicode_strings';
+
 casetest(0, # No extra tests run here,
        "Titlecase_Mapping",
         ucfirst                        => sub { ucfirst $_[0] },
index f62b43b..41b235c 100644 (file)
@@ -3,6 +3,8 @@ BEGIN {
     require "uni/case.pl";
 }
 
+use feature 'unicode_strings';
+
 is(uc("\x{3B1}\x{345}\x{301}"), "\x{391}\x{301}\x{399}",
                                                    'Verify moves YPOGEGRAMMENI');