Skip to content

Commit

Permalink
version::07locale.t: Use I18N::Langinfo, not POSIX::localeconv()
Browse files Browse the repository at this point in the history
The former is always present; the latter might not be.
  • Loading branch information
khwilliamson committed Nov 20, 2023
1 parent 42e7ff4 commit 38ebf1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions cpan/version/t/07locale.t
Expand Up @@ -14,6 +14,19 @@ BEGIN {
use_ok('version', 0.9930);
}

sub radix { # Returns the radix character for the current locale.

# Use localeconv() on earlier perls; if it is just a stub, assume a dot.
if (! $^V or $^V lt v5.37.4) {
return localeconv()->{decimal_point} || ".";
}

# localeconv() may be a stub on some platforms. But on later perls,
# langinfo() will always exist and returns the best available value.
use if $^V && $^V ge v5.37.4, 'I18N::Langinfo' => qw(langinfo RADIXCHAR);
return langinfo(RADIXCHAR);
}

SKIP: {
skip 'No locale testing for Perl < 5.6.0', 7 if $] < 5.006;
skip 'No locale testing without d_setlocale', 7
Expand All @@ -38,10 +51,10 @@ SKIP: {
while (<DATA>) {
chomp;
$loc = setlocale( LC_ALL, $_);
last if $loc && localeconv()->{decimal_point} eq ',';
last if $loc && radix() eq ',';
}
skip 'Cannot test locale handling without a comma locale', 6
unless $loc and localeconv()->{decimal_point} eq ',';
unless $loc and radix() eq ',';

setlocale(LC_NUMERIC, $loc);
$ver = 1.23; # has to be floating point number
Expand Down
4 changes: 2 additions & 2 deletions t/porting/customized.dat
Expand Up @@ -21,5 +21,5 @@ Time::Piece cpan/Time-Piece/Piece.pm 8cec8b66183ceddb9bf2b6af35dcdd345bc9adfa
Time::Piece cpan/Time-Piece/Piece.xs 543152540ee17788a638b2c5746b86c3d04401d1
Win32API::File cpan/Win32API-File/File.pm 8fd212857f821cb26648878b96e57f13bf21b99e
Win32API::File cpan/Win32API-File/File.xs beb870fed4490d2faa547b4a8576b8d64d1d27c5
version cpan/version/lib/version.pm 8080cfe1fb21d5248c8ff5133b298d249d11e8e8
version cpan/version/t/07locale.t 6731c4a69ef8deaead7b084b69b603b7cc8a189a
version cpan/version/lib/version.pm a963b513cf812bd7f4d28b3422efd9904e70a34c
version cpan/version/t/07locale.t e3ee07d9f9159acb807a7fa29c712cc64f9b950b

0 comments on commit 38ebf1f

Please sign in to comment.