This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/run/locale.t: Add, revise tests
authorKarl Williamson <khw@cpan.org>
Sun, 4 Mar 2018 17:47:08 +0000 (10:47 -0700)
committerKarl Williamson <khw@cpan.org>
Sun, 4 Mar 2018 18:53:10 +0000 (11:53 -0700)
This enhances the test added in bee74f4b9818f0ca72926dd6b4dfdbc6b75c59ef
so that it is doing a valid setlocale, and adds a similar test for doing
an invalid one.

t/run/locale.t

index a61b948..f1bb6f2 100644 (file)
@@ -118,7 +118,7 @@ SKIP: {
 }
 
 SKIP: {
-    skip("no locale available where LC_NUMERIC makes a difference", &last - 8 )
+    skip("no locale available where LC_NUMERIC makes a difference", &last - 9 )
        if !$different;     # -7 is 5 tests before this block; 2 after
     note("using the '$different' locale for LC_NUMERIC tests");
     {
@@ -427,18 +427,43 @@ EOF
 
     }
 
-    {
-        fresh_perl(<<"EOF",
-                use locale;
-                use POSIX;
-                POSIX::setlocale(LC_ALL, "LC_NUMERIC=de_DE.utf8;LC_CTYPE=de_DE.utf8;LC_COLLATE=de_DE.utf8;LC_TIME=de_DE.utf8;LC_MESSAGES=de_DE.utf8;LC_MONETARY=de_DE.utf8;LC_ADDRESS=de_DE.utf8;LC_IDENTIFICATION=de_DE.utf8;LC_MEASUREMENT=de_DE.utf8;LC_PAPER=de_DE.utf8;LC_TELEPHONE=de_DE.utf8");
-EOF
-            {});
-        ok ($? == 0, "In complicated LC_ALL, final individ category doesn't need a \';'");
+SKIP: {
 
+    my @valid_categories = valid_locale_categories();
+
+    my $valid_string = "";
+    my $invalid_string = "";
+
+    foreach my $category (@valid_categories) {
+        if ($category ne "LC_ALL") {
+            $invalid_string .= ";" if $invalid_string ne "";
+            $invalid_string .= "$category=foo_BAR";
+
+            $valid_string .= ";" if $valid_string ne "";
+            $valid_string .= "$category=$non_C_locale";
+        }
     }
 
+    fresh_perl(<<"EOF",
+            use locale;
+            use POSIX;
+            POSIX::setlocale(LC_ALL, "$invalid_string");
+EOF
+        {});
+    is ($?, 0, "In setting complicated invalid LC_ALL, final individ category doesn't need a \';'");
+
+    skip("no non-C locale available", 2 ) unless $non_C_locale;
+    fresh_perl(<<"EOF",
+            use locale;
+            use POSIX;
+            POSIX::setlocale(LC_ALL, "$valid_string");
+EOF
+        {});
+    is ($?, 0, "In setting complicated valid LC_ALL, final individ category doesn't need a \';'");
+
+}
+
 # IMPORTANT: When adding tests before the following line, be sure to update
 # its skip count:
 #       skip("no locale available where LC_NUMERIC makes a difference", ...)
-sub last { 38 }
+sub last { 39 }