summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-12-04 14:08:17 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-12-04 14:08:17 +0000
commit2a2d7c2c6d60ef5bc68d07fd1a65641438754fa2 (patch)
treeeb227a3fb301dfb9cca17590e34efa0b2a034619
parent85fdc8b6e74c83540771af9354dcfc6175c9f46e (diff)
downloadperl-2a2d7c2c6d60ef5bc68d07fd1a65641438754fa2.tar.gz
Make the Langinfo test both more lenient (allow
for any symbol not to exists) and stricter (add more symbols). p4raw-id: //depot/perl@13458
-rw-r--r--ext/I18N/Langinfo/Langinfo.t85
1 files changed, 34 insertions, 51 deletions
diff --git a/ext/I18N/Langinfo/Langinfo.t b/ext/I18N/Langinfo/Langinfo.t
index ab22572937..9799934f3b 100644
--- a/ext/I18N/Langinfo/Langinfo.t
+++ b/ext/I18N/Langinfo/Langinfo.t
@@ -5,67 +5,50 @@ BEGIN {
@INC = '../lib';
require Config; import Config;
if ($Config{'extensions'} !~ m!\bI18N/Langinfo\b! ||
- $Config{'extensions'} !~ m!\bPOSIX\b! ||
- $^O eq 'dos') # DJGPP has langinfo() but it seems to largely be a dummy
+ $Config{'extensions'} !~ m!\bPOSIX\b!)
{
print "1..0 # skip: I18N::Langinfo or POSIX unavailable\n";
exit 0;
}
}
-
-use I18N::Langinfo qw(langinfo ABDAY_1 DAY_1 ABMON_1 MON_1);
+
+use I18N::Langinfo qw(langinfo);
use POSIX qw(setlocale LC_ALL);
-use Config;
-
-print "# ABDAY_1 = ", ABDAY_1, "\n";
-
-eval { I18N::Langinfo->import('RADIXCHAR') }; # silly glibcs
-print "# RADIXCHAR = ", RADIXCHAR(), " (eval error = '$@')\n";
-my $has_RADIXCHAR = !$@;
setlocale(LC_ALL, $ENV{LC_ALL} = $ENV{LANG} = "C");
-print "1..5\n";
-
-print "not " unless langinfo(ABDAY_1) eq "Sun";
-print "ok 1\n";
-
-print "not " unless langinfo(DAY_1) eq "Sunday";
-print "ok 2\n";
-
-print "not " unless langinfo(ABMON_1) eq "Jan";
-print "ok 3\n";
-
-print "not " unless langinfo(MON_1) eq "January";
-print "ok 4\n";
-
-my $RADIXCHAR_ok;
-
-if ($has_RADIXCHAR) {
- unless (langinfo(RADIXCHAR()) eq ".") {
- print "not ok 5 - RADIXCHAR not '.' under the C locale\n";
+my %want =
+ (
+ ABDAY_1 => "Sun",
+ DAY_1 => "Sunday",
+ ABMON_1 => "Jan",
+ MON_1 => "January",
+ RADIXCHAR => ".",
+ YESSTR => qr{^y(?:es)?$}i,
+ AM_STR => qr{^(?:am|a\.m\.)$}i,
+ THOUSEP => "",
+ D_T_FMT => qr{^%a %b %[de] %H:%M:%S %Y$},
+ D_FMT => qr{^%m/%d/%y$},
+ T_FMT => qr{^%H:%M:%S$},
+ );
+
+
+my @want = sort keys %want;
+
+print "1..", scalar @want, "\n";
+
+for my $i (1..@want) {
+ my $try = $want[$i-1];
+ eval { I18N::Langinfo->import($try) };
+ unless ($@) {
+ my $got = langinfo(&$try);
+ if (ref $want{$try} && $got =~ $want{$try} || $got eq $want{$try}) {
+ print qq[ok $i - $try is "$got"\n];
+ } else {
+ print qq[not ok $i - $try is "$got" not "$want{$try}"\n];
+ }
} else {
- print "ok 5\n";
- $RADIXCHAR_ok = 1;
- }
-} else {
- print "ok 5 # Skip: you do not have RADIXHCAR\n";
-}
-
-unless ($RADIXCHAR_ok) {
- if ($Config{d_gnulibc} || $Config{cppsymbols} =~ /__GNU_LIBRARY_/) {
- print <<EOM;
-#
-# You are probably using GNU libc. The RADIXCHAR not getting defined
-# by I18N::Langinfo is a known problem in some versions of the
-# GNU libc (caused by the combination of using only enums, not cpp
-# definitions, and of hiding the definitions behind rather obscure
-# feature tests). Upgrading your libc is strongly suggested.
-#
-EOM
+ print qq[ok $i - Skip: $try not defined\n];
}
}
-
-
-