Skip to content

Commit 9c6df44

Browse files
ntyniFather Chrysostomos
authored and
Father Chrysostomos
committed
Refactor LC_NUMERIC test out of t/run/fresh_perl.t
Neither lib/locale.t nor t/run/fresh_perl.t should be used for new tests, so take the locale related tests and the setup code from fresh_perl.t to make ground for more.
1 parent 9f1eb87 commit 9c6df44

File tree

3 files changed

+51
-36
lines changed

3 files changed

+51
-36
lines changed

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4802,6 +4802,7 @@ t/re/uniprops.t Test unicode \p{} regex constructs
48024802
t/run/cloexec.t Test close-on-exec.
48034803
t/run/exit.t Test perl's exit status.
48044804
t/run/fresh_perl.t Tests that require a fresh perl.
4805+
t/run/locale.t Tests related to locale handling
48054806
t/run/noswitch.t Test aliasing ARGV for other switch tests
48064807
t/run/runenv.t Test if perl honors its environment variables.
48074808
t/run/script.t See if script invocation works

t/run/fresh_perl.t

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -565,42 +565,6 @@ EOT
565565
EXPECT
566566
ok
567567
########
568-
# This test is here instead of lib/locale.t because
569-
# the bug depends on in the internal state of the locale
570-
# settings and pragma/locale messes up that state pretty badly.
571-
# We need a "fresh run".
572-
BEGIN {
573-
eval { require POSIX };
574-
if ($@) {
575-
exit(0); # running minitest?
576-
}
577-
}
578-
use Config;
579-
my $have_setlocale = $Config{d_setlocale} eq 'define';
580-
$have_setlocale = 0 if $@;
581-
# Visual C's CRT goes silly on strings of the form "en_US.ISO8859-1"
582-
# and mingw32 uses said silly CRT
583-
$have_setlocale = 0 if (($^O eq 'MSWin32' || $^O eq 'NetWare') && $Config{cc} =~ /^(cl|gcc)/i);
584-
exit(0) unless $have_setlocale;
585-
my @locales;
586-
if (-x "/usr/bin/locale" && open(LOCALES, "/usr/bin/locale -a 2>/dev/null|")) {
587-
while(<LOCALES>) {
588-
chomp;
589-
push(@locales, $_);
590-
}
591-
close(LOCALES);
592-
}
593-
exit(0) unless @locales;
594-
for (@locales) {
595-
use POSIX qw(locale_h);
596-
use locale;
597-
setlocale(LC_NUMERIC, $_) or next;
598-
my $s = sprintf "%g %g", 3.1, 3.1;
599-
next if $s eq '3.1 3.1' || $s =~ /^(3.+1) \1$/;
600-
print "$_ $s\n";
601-
}
602-
EXPECT
603-
########
604568
# [ID 20001202.002] and change #8066 added 'at -e line 1';
605569
# reversed again as a result of [perl #17763]
606570
die qr(x)

t/run/locale.t

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!./perl
2+
BEGIN {
3+
chdir 't' if -d 't';
4+
@INC = '../lib';
5+
require './test.pl'; # for fresh_perl_is() etc
6+
}
7+
8+
use strict;
9+
10+
########
11+
# This test is here instead of lib/locale.t because
12+
# the bug depends on in the internal state of the locale
13+
# settings and pragma/locale messes up that state pretty badly.
14+
# We need a "fresh run".
15+
BEGIN {
16+
eval { require POSIX };
17+
if ($@) {
18+
skip_all("could not load the POSIX module"); # running minitest?
19+
}
20+
}
21+
use Config;
22+
my $have_setlocale = $Config{d_setlocale} eq 'define';
23+
$have_setlocale = 0 if $@;
24+
# Visual C's CRT goes silly on strings of the form "en_US.ISO8859-1"
25+
# and mingw32 uses said silly CRT
26+
$have_setlocale = 0 if (($^O eq 'MSWin32' || $^O eq 'NetWare') && $Config{cc} =~ /^(cl|gcc)/i);
27+
skip_all("no setlocale available") unless $have_setlocale;
28+
my @locales;
29+
if (-x "/usr/bin/locale" && open(LOCALES, "/usr/bin/locale -a 2>/dev/null|")) {
30+
while(<LOCALES>) {
31+
chomp;
32+
push(@locales, $_);
33+
}
34+
close(LOCALES);
35+
}
36+
skip_all("no locales available") unless @locales;
37+
38+
plan tests => &last;
39+
fresh_perl_is("for (qw(@locales)) {\n" . <<'EOF',
40+
use POSIX qw(locale_h);
41+
use locale;
42+
setlocale(LC_NUMERIC, "$_") or next;
43+
my $s = sprintf "%g %g", 3.1, 3.1;
44+
next if $s eq '3.1 3.1' || $s =~ /^(3.+1) \1$/;
45+
print "$_ $s\n";
46+
}
47+
EOF
48+
"", {}, "no locales where LC_NUMERIC breaks");
49+
50+
sub last { 1 }

0 commit comments

Comments
 (0)