use File::Basename;
use File::Temp qw/tempfile/;
use POSIX qw/locale_h/;
-use Test::More tests => 9;
+use Test::More tests => 7;
use Config;
BEGIN {
}
SKIP: {
- skip 'No locale testing for Perl < 5.6.0', 8 if $] < 5.006;
- skip 'No locale testing without d_setlocale', 8 if(!$Config{d_setlocale});
+ skip 'No locale testing for Perl < 5.6.0', 6 if $] < 5.006;
+ skip 'No locale testing without d_setlocale', 6 if(!$Config{d_setlocale});
# test locale handling
my $warning;
$loc = setlocale( LC_ALL, $_);
last if localeconv()->{decimal_point} eq ',';
}
- skip 'Cannot test locale handling without a comma locale', 7
+ skip 'Cannot test locale handling without a comma locale', 5
unless $loc and localeconv()->{decimal_point} eq ',';
diag ("Testing locale handling with $loc") unless $ENV{PERL_CORE};
ok ($v eq "1.23", "Locale doesn't apply to version objects");
ok ($v == $ver, "Comparison to locale floating point");
- {
- no locale;
- ok ("$ver eq '1.23'", "Outside of scope of use locale");
- }
-
- ok("\"$ver\"+1 gt 2.22" && \"$ver\"+1 lt 2.24",
- "Can do math when radix is not a dot"); # [perl 115800]
-
setlocale( LC_ALL, $orig_loc); # reset this before possible skip
skip 'Cannot test RT#46921 with Perl < 5.008', 1
if ($] < 5.008);
# try to find out a locale where LC_NUMERIC makes a difference
my $original_locale = setlocale(LC_NUMERIC);
-my ($base, $different, $difference);
+my ($base, $different, $comma, $difference);
for ("C", @locales) { # prefer C for the base if available
BEGIN {
if($Config{d_setlocale}) {
} else {
$different ||= $_;
$difference ||= $s;
+ $comma ||= $_ if localeconv()->{decimal_point} eq ',';
}
- last if $base && $different;
+ last if $base && $different && $comma;
}
setlocale(LC_NUMERIC, $original_locale);
"", {}, "version does not clobber version (via eval)");
}
-
for ($different) {
local $ENV{LC_NUMERIC} = $_;
local $ENV{LC_ALL}; # so it never overrides LC_NUMERIC
EOF
"sprintf() and printf() look at LC_NUMERIC regardless of constant folding");
}
+
+ unless ($comma) {
+ skip("no locale available where LC_NUMERIC is a comma", 2);
+ }
+ else {
+
+ fresh_perl_is(<<"EOF",
+ my \$i = 1.5;
+ {
+ use locale;
+ use POSIX;
+ POSIX::setlocale(POSIX::LC_NUMERIC(),"$comma");
+ print \$i, "\n";
+ }
+ print \$i, "\n";
+EOF
+ "1,5\n1.5", {}, "Radix print properly in locale scope, and without");
+
+ fresh_perl_is(<<"EOF",
+ my \$i = 1.5; # Should be exactly representable as a base 2
+ # fraction, so can use 'eq' below
+ use locale;
+ use POSIX;
+ POSIX::setlocale(POSIX::LC_NUMERIC(),"$comma");
+ print \$i, "\n";
+ \$i += 1;
+ print \$i, "\n";
+EOF
+ "1,5\n2,5", {}, "Can do math when radix is a comma"); # [perl 115800]
+ }
+
} # SKIP
-sub last { 9 }
+sub last { 11 }