6 require Config; import Config;
7 if ($Config{'extensions'} !~ m!\bI18N/Langinfo\b! ||
8 $Config{'extensions'} !~ m!\bPOSIX\b!)
10 print "1..0 # skip: I18N::Langinfo or POSIX unavailable\n";
15 use I18N::Langinfo qw(langinfo);
16 use POSIX qw(setlocale LC_ALL);
18 setlocale(LC_ALL, $ENV{LC_ALL} = $ENV{LANG} = "C");
20 print "1..1\n"; # We loaded okay. That's about all we can hope for.
24 # Background: the langinfo() (in C known as nl_langinfo()) interface
25 # is supposed to be a portable way to fetch various language/country
26 # (locale) dependent constants like "the first day of the week" or
27 # "the decimal separator". Give a portable (numeric) constant,
28 # get back a language-specific string. That's a comforting fantasy.
29 # Now tune in for blunt reality: vendors seem to have implemented for
30 # those constants whatever they felt like implementing. The UNIX
31 # standard says that one should have the RADIXCHAR constant for the
32 # decimal separator. Not so for many Linux and BSD implementations.
33 # One should have the CODESET constant for returning the current
34 # codeset (say, ISO 8859-1). Not so. So let's give up any real
35 # testing (leave the old testing code here for old times' sake,
45 AM_STR => qr{^(?:am|a\.m\.)$}i,
47 D_T_FMT => qr{^%a %b %[de] %H:%M:%S %Y$},
48 D_FMT => qr{^%m/%d/%y$},
49 T_FMT => qr{^%H:%M:%S$},
53 my @want = sort keys %want;
55 print "1..", scalar @want, "\n";
57 for my $i (1..@want) {
58 my $try = $want[$i-1];
59 eval { I18N::Langinfo->import($try) };
61 my $got = langinfo(&$try);
62 if (ref $want{$try} && $got =~ $want{$try} || $got eq $want{$try}) {
63 print qq[ok $i - $try is "$got"\n];
65 print qq[not ok $i - $try is "$got" not "$want{$try}"\n];
68 print qq[ok $i - Skip: $try not defined\n];