summaryrefslogtreecommitdiff
path: root/t/run
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-07-09 09:38:00 -0600
committerKarl Williamson <khw@cpan.org>2014-07-09 10:12:23 -0600
commita7fa5053628a560ab7de68cb98a8894c82546246 (patch)
tree1a9a760019609d139d90681a65fd1a2652692ed3 /t/run
parent162eb2b8d6b30227ebd3aaaf7d984b5052030517 (diff)
downloadperl-a7fa5053628a560ab7de68cb98a8894c82546246.tar.gz
t/run/locale.t: setting to POSIX may be same as C
On some (? all) systems, setting the locale to POSIX may cause it to actually set it to C. In these tests we want to exclude C, hence we have to exclude POSIX as well. Some systems may not have any other locales, so this commit also properly skips tests on those. Thanks to Matthew Horsfall for figuring this out
Diffstat (limited to 't/run')
-rw-r--r--t/run/locale.t23
1 files changed, 16 insertions, 7 deletions
diff --git a/t/run/locale.t b/t/run/locale.t
index 7af7875f8c..47bd1a312c 100644
--- a/t/run/locale.t
+++ b/t/run/locale.t
@@ -26,15 +26,21 @@ skip_all("no locales available") unless @locales;
plan tests => &last;
+my $non_C_locale;
foreach my $locale (@locales) {
- next if $locale eq "C";
- setlocale(LC_NUMERIC, $locale) or next;
- isnt(setlocale(LC_NUMERIC), "C", "retrieving current non-C LC_ALL doesn't give 'C'");
- setlocale(LC_ALL, $locale) or next;
- isnt(setlocale(LC_ALL), "C", "retrieving current non-C LC_ALL doesn't give 'C'");
+ next if $locale eq "C" || $locale eq 'POSIX';
+ $non_C_locale = $locale;
last;
}
+SKIP: {
+ skip("no non-C locale available", 2 ) unless $non_C_locale;
+ setlocale(LC_NUMERIC, $non_C_locale);
+ isnt(setlocale(LC_NUMERIC), "C", "retrieving current non-C LC_NUMERIC doesn't give 'C'");
+ setlocale(LC_ALL, $non_C_locale);
+ isnt(setlocale(LC_ALL), "C", "retrieving current non-C LC_ALL doesn't give 'C'");
+}
+
fresh_perl_is("for (qw(@locales)) {\n" . <<'EOF',
use POSIX qw(locale_h);
use locale;
@@ -104,8 +110,8 @@ SKIP: {
}
SKIP: {
- skip("no locale available where LC_NUMERIC makes a difference", &last - 5 )
- if !$different; # -5 is 3 tests before this block; 2 after
+ skip("no locale available where LC_NUMERIC makes a difference", &last - 7 )
+ if !$different; # -7 is 5 tests before this block; 2 after
note("using the '$different' locale for LC_NUMERIC tests");
{
local $ENV{LC_NUMERIC} = $different;
@@ -418,4 +424,7 @@ EOF
}
+# 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 { 37 }