lib/locale.t: Fix :digit:, :xdigit: tests
authorKarl Williamson <public@khwilliamson.com>
Thu, 15 Aug 2013 18:31:55 +0000 (12:31 -0600)
committerKarl Williamson <public@khwilliamson.com>
Thu, 15 Aug 2013 22:49:30 +0000 (16:49 -0600)
In commit 32e8aa3fdb11b64c2a141bf56441761d978fd17b, I forgot that the
POSIX standard allows \d ([:digit:]) to match either the 10 ASCII
digits, or those plus another 10 locale-dependent ones.  This new commit
tests that the number matched is either 10 or 20, and if not 10, then
\d doesn't have to be a subset of [:xdigit:], so skip that test.

lib/locale.t

index e75f919..5803405 100644 (file)
@@ -521,6 +521,7 @@ if (in_utf8) {
 
 my @Locale;
 my $Locale;
+my @Digit_;
 my @Alnum_;
 
 sub trylocale {
@@ -733,8 +734,8 @@ foreach $Locale (@Locale) {
     if (! $is_utf8_locale) {
         use locale;
         @Alnum_ = sort grep /\w/, map { chr } 0..255;
-
         debug "# w = ", join("",@Alnum_), "\n";
+        @Digit_ = grep /\d/, map { chr } 0..255;
 
         # Sieve the uppercase and the lowercase.
 
@@ -752,6 +753,7 @@ foreach $Locale (@Locale) {
     else {
         use locale ':not_characters';
         @Alnum_ = sort grep /\w/, map { chr } 0..255;
+        @Digit_ = grep /\d/, map { chr } 0..255;
         debug "# w = ", join("",@Alnum_), "\n";
         for (@Alnum_) {
             if (/[^\d_]/) { # skip digits and the _
@@ -1011,7 +1013,13 @@ foreach $Locale (@Locale) {
 
     ++$locales_test_number;
     undef @f;
-    $test_names{$locales_test_number} = 'Verify that [:digit:] is a subset of [:xdigit:]';
+    $test_names{$locales_test_number} = 'Verify that [:digit:] matches either 10 or 20 code points';
+    report_result($Locale, $locales_test_number, @Digit_ == 10 || @Digit_ ==20);
+
+    ++$locales_test_number;
+    undef @f;
+    $test_names{$locales_test_number} = 'Verify that [:digit:] (if is 10 code points) is a subset of [:xdigit:]';
+    if (@Digit_ == 10) {
     for (map { chr } 0..255) {
         if ($is_utf8_locale) {
             use locale ':not_characters';
@@ -1021,6 +1029,7 @@ foreach $Locale (@Locale) {
             push @f, $_ if /[[:digit:]]/  and ! /[[:xdigit:]]/;
         }
     }
+    }
     report_multi_result($Locale, $locales_test_number, \@f);
 
     ++$locales_test_number;