Try to make a missing RADIXCHAR a softer kinder error.
[p5sagit/p5-mst-13.2.git] / ext / I18N / Langinfo / Langinfo.t
CommitLineData
4bbcc6e8 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
fb175bb2 5 @INC = '../lib';
4bbcc6e8 6 require Config; import Config;
b270fb37 7 if ($Config{'extensions'} !~ m!\bI18N/Langinfo\b! ||
8 $Config{'extensions'} !~ m!\bPOSIX\b!)
9 {
10 print "1..0 # skip: I18N::Langinfo or POSIX unavailable\n";
4bbcc6e8 11 exit 0;
12 }
13}
14
bb5b2f6d 15use I18N::Langinfo qw(langinfo ABDAY_1 DAY_1 ABMON_1 MON_1);
642c2bac 16use POSIX qw(setlocale LC_ALL);
69af93f8 17use Config;
4bbcc6e8 18
bb5b2f6d 19print "# ABDAY_1 = ", ABDAY_1, "\n";
20
21eval { I18N::Langinfo->import('RADIXCHAR') }; # silly glibcs
22print "# RADIXCHAR = ", RADIXCHAR(), " (eval error = '$@')\n";
23my $has_RADIXCHAR = !$@;
24
25setlocale(LC_ALL, $ENV{LC_ALL} = $ENV{LANG} = "C");
4bbcc6e8 26
27print "1..5\n";
28
29print "not " unless langinfo(ABDAY_1) eq "Sun";
30print "ok 1\n";
31
32print "not " unless langinfo(DAY_1) eq "Sunday";
33print "ok 2\n";
34
35print "not " unless langinfo(ABMON_1) eq "Jan";
36print "ok 3\n";
37
38print "not " unless langinfo(MON_1) eq "January";
39print "ok 4\n";
40
bb5b2f6d 41my $RADIXCHAR_ok;
42
43if ($has_RADIXCHAR) {
44 unless (langinfo(RADIXCHAR()) eq ".") {
45 print "not ok 5 - RADIXCHAR not '.' under the C locale\n";
46 } else {
47 print "ok 5\n";
48 $RADIXCHAR_ok = 1;
49 }
50} else {
51 print "ok 5 # Skip: you do not have RADIXHCAR\n";
52}
53
54unless ($RADIXCHAR_ok) {
4c1bac79 55 if ($Config{d_gnulibc} || $Config{cppsymbols} =~ /__GNU_LIBRARY_/) {
69af93f8 56 print <<EOM;
57#
58# You are probably using GNU libc. The RADIXCHAR not getting defined
bb5b2f6d 59# by I18N::Langinfo is a known problem in some versions of the
4c1bac79 60# GNU libc (caused by the combination of using only enums, not cpp
61# definitions, and of hiding the definitions behind rather obscure
62# feature tests). Upgrading your libc is strongly suggested.
69af93f8 63#
64EOM
65 }
69af93f8 66}
4bbcc6e8 67
bb5b2f6d 68
69
70