summaryrefslogtreecommitdiff
path: root/lib/locale.t
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2015-09-07 10:03:27 -0600
committerKarl Williamson <khw@cpan.org>2015-09-08 10:05:56 -0600
commit308482c27259302fb2ca8c60b8383609a0e9f314 (patch)
tree5e15ba76b2ea0b5365c1d8b99a65cc0d6f64d923 /lib/locale.t
parentd8f8a4817f5910267c45439ddb7764b371f06276 (diff)
downloadperl-308482c27259302fb2ca8c60b8383609a0e9f314.tar.gz
t/loc_tools.pl: Fix some bugs in locales_enabled()
This code assumed that all locale categories were represented by non-negative whole numbers. However, it turns out that this assumption is wrong, as on AIX, LC_ALL is -1. This commit changes our assumption to take into account that reality; it now assumes that all categories are larger than a much more negative number, and now the new assumption is tested for, and if wrong, the code dies instead of silently doing the wrong thing. There was also a bug where if a locale category wasn't defined on the machine, but the corresponding #ifdef for using that category was still set, the category was improperly assumed to exist
Diffstat (limited to 'lib/locale.t')
-rw-r--r--lib/locale.t14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/locale.t b/lib/locale.t
index 3a2005f481..6b5616c522 100644
--- a/lib/locale.t
+++ b/lib/locale.t
@@ -116,6 +116,20 @@ sub check_taint_not ($;$) {
ok((not is_tainted($_[0])), "verify that isn't tainted$message_tail");
}
+foreach my $category (qw(ALL COLLATE CTYPE MESSAGES MONETARY NUMERIC TIME)) {
+ my $short_result = locales_enabled($category);
+ ok ($short_result == 0 || $short_result == 1,
+ "Verify locales_enabled('$category') returns 0 or 1");
+ debug("locales_enabled('$category') returned '$short_result'");
+ my $long_result = locales_enabled("LC_$category");
+ if (! ok ($long_result == $short_result,
+ " and locales_enabled('LC_$category') returns "
+ . "the same value")
+ ) {
+ debug("locales_enabled('LC_$category') returned $long_result");
+ }
+}
+
"\tb\t" =~ /^m?(\s)(.*)\1$/;
check_taint_not $&, "not tainted outside 'use locale'";
;