summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2023-03-03 05:00:13 -0700
committerKarl Williamson <khw@cpan.org>2023-03-04 13:04:56 -0700
commitaa32b5f398472074bb2b8c5b037c867d470f215b (patch)
tree9d609d462809fd737a26f20ec26064b0c2833ab9 /ext
parent54c84abedb8585e68baddc0e9bc9fc48eadc63c8 (diff)
downloadperl-aa32b5f398472074bb2b8c5b037c867d470f215b.tar.gz
Fix my_strftime() upper space limit
The comments said that 100:1 expansion factor had long been sufficient. But it turns out that was wrong; there are locales with a higher ratio, that we just didn't notice were failing. This commit adds comments and ups the ratio to 2000:1
Diffstat (limited to 'ext')
-rw-r--r--ext/XS-APItest/t/locale.t38
1 files changed, 28 insertions, 10 deletions
diff --git a/ext/XS-APItest/t/locale.t b/ext/XS-APItest/t/locale.t
index b8eb09a3fd..c727df1298 100644
--- a/ext/XS-APItest/t/locale.t
+++ b/ext/XS-APItest/t/locale.t
@@ -6,11 +6,9 @@ BEGIN {
use XS::APItest;
use Config;
-skip_all("locales not available") unless locales_enabled('LC_NUMERIC');
+skip_all("locales not available") unless locales_enabled();
my @locales = eval { find_locales( &LC_NUMERIC ) };
-skip_all("no LC_NUMERIC locales available") unless @locales;
-
my $comma_locale;
for my $locale (@locales) {
use POSIX;
@@ -24,15 +22,14 @@ for my $locale (@locales) {
}
}
-
SKIP: {
- if ($Config{usequadmath}) {
- skip "no gconvert with usequadmath", 2;
+ if ($Config{usequadmath}) {
+ skip "no gconvert with usequadmath", 2;
+ }
+ is(test_Gconvert(4.179, 2), "4.2", "Gconvert doesn't recognize underlying locale outside 'use locale'");
+ use locale;
+ is(test_Gconvert(4.179, 2), "4.2", "Gconvert doesn't recognize underlying locale inside 'use locale'");
}
- is(test_Gconvert(4.179, 2), "4.2", "Gconvert doesn't recognize underlying locale outside 'use locale'");
- use locale;
- is(test_Gconvert(4.179, 2), "4.2", "Gconvert doesn't recognize underlying locale inside 'use locale'");
-}
sub check_in_bounds($$$) {
my ($value, $lower, $upper) = @_;
@@ -182,4 +179,25 @@ SKIP: {
}
}
+@locales = eval { find_locales( &LC_TIME ) };
+
+SKIP: {
+ skip("no LC_TIME locales available") unless @locales;
+
+ for my $locale (@locales) {
+ use POSIX 'strftime';
+ use locale;
+ setlocale(LC_TIME, $locale) or next;
+
+ # This isn't guaranteed to find failing locales, as it is impractical
+ # to test all possible dates. But it is much better than no test at
+ # all
+ if (strftime('%c', 0, 0, , 12, 18, 11, 87) eq "") {
+ fail('strftime() built-in expansion factor works for all locales');
+ diag("Failed for locale $locale");
+ last;
+ }
+ }
+}
+
done_testing();