This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
POSIX math: s = "0" is not happy with -Wwrite-strings.
[perl5.git] / lib / locale.t
index 70766f2..31b40f9 100644 (file)
@@ -917,12 +917,7 @@ foreach my $Locale (@Locale) {
 
     debug "is utf8 locale? = $is_utf8_locale\n";
 
-    my $radix = localeconv()->{decimal_point};
-    if ($radix !~ / ^ [[:ascii:]] + $/x) {
-        use bytes;
-        $radix = disp_chars(split "", $radix);
-    }
-    debug "radix = $radix\n";
+    debug "radix = " . disp_str(localeconv()->{decimal_point}) . "\n";
 
     if (! $is_utf8_locale) {
         use locale;
@@ -1842,18 +1837,20 @@ foreach my $Locale (@Locale) {
 
             # Look for non-ASCII error messages, and verify that the first
             # such is in UTF-8 (the others almost certainly will be like the
-            # first).
+            # first).  This is only done if the current locale has LC_MESSAGES
             $ok14 = 1;
             $ok14_5 = 1;
-            foreach my $err (keys %!) {
-                use Errno;
-                $! = eval "&Errno::$err";   # Convert to strerror() output
-                my $strerror = "$!";
-                if ("$strerror" =~ /\P{ASCII}/) {
-                    $ok14 = utf8::is_utf8($strerror);
-                    no locale;
-                    $ok14_5 = "$!" !~ /\P{ASCII}/;
-                    last;
+            if (setlocale(&POSIX::LC_MESSAGES, $Locale)) {
+                foreach my $err (keys %!) {
+                    use Errno;
+                    $! = eval "&Errno::$err";   # Convert to strerror() output
+                    my $strerror = "$!";
+                    if ("$strerror" =~ /\P{ASCII}/) {
+                        $ok14 = utf8::is_utf8($strerror);
+                        no locale;
+                        $ok14_5 = "$!" !~ /\P{ASCII}/;
+                        last;
+                    }
                 }
             }
 
@@ -1874,13 +1871,15 @@ foreach my $Locale (@Locale) {
         $ok18 = $j eq sprintf("%g:%g", $h, $i);
     }
 
-    { # These tests aren't affected by :not_characters
-
+    $ok19 = $ok20 = 1;
+    if (setlocale(&POSIX::LC_TIME, $Locale)) { # These tests aren't affected by
+                                               # :not_characters
         my @times = CORE::localtime();
 
         use locale;
         $ok19 = POSIX::strftime("%p", @times) ne "%p"; # [perl #119425]
-        my $date = POSIX::strftime("%A %B %Z", @times);
+        my $date = POSIX::strftime("'%A'  '%B'  '%Z'  '%p'", @times);
+        debug("'Day' 'Month' 'TZ' 'am/pm' = ", disp_str($date));
 
         # If there is any non-ascii, it better be UTF-8 in a UTF-8 locale, and
         # not UTF-8 if the locale isn't UTF-8.
@@ -1982,6 +1981,8 @@ foreach my $Locale (@Locale) {
 
     report_result($Locale, ++$locales_test_number, $ok20);
     $test_names{$locales_test_number} = 'Verify that strftime returns date with UTF-8 flag appropriately set';
+    $problematical_tests{$locales_test_number} = 1;   # This is broken in
+                                                      # OS X 10.9.3
 
     report_result($Locale, ++$locales_test_number, $ok21);
     $test_names{$locales_test_number} = '"$!" is ASCII only outside of locale scope';
@@ -2222,12 +2223,14 @@ foreach $test_num ($first_locales_test_number..$final_locales_test_number) {
                     print "# problem is not likely to be Perl's\n";
                 }
             }
-            elsif ($debug) {
+            if ($debug) {
                 print "# $percent_fail% of locales (",
                       scalar(keys $Problem{$test_num}),
                       " of ",
                       scalar(@Locale),
-                      ") fail the following test\n";
+                      ") fail the above test (TODO cut-off is ",
+                      $acceptable_failure_percentage,
+                      "%)\n";
             }
         }
         print "#\n";