summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/XS-APItest/APItest.pm2
-rw-r--r--ext/XS-APItest/APItest.xs7
-rw-r--r--ext/XS-APItest/t/locale.t106
3 files changed, 111 insertions, 4 deletions
diff --git a/ext/XS-APItest/APItest.pm b/ext/XS-APItest/APItest.pm
index 796605f7c0..d4edcac51a 100644
--- a/ext/XS-APItest/APItest.pm
+++ b/ext/XS-APItest/APItest.pm
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Carp;
-our $VERSION = '0.91';
+our $VERSION = '0.92';
require XSLoader;
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs
index 7a18bbf291..e9a55b4030 100644
--- a/ext/XS-APItest/APItest.xs
+++ b/ext/XS-APItest/APItest.xs
@@ -6544,6 +6544,13 @@ test_Gconvert(SV * number, SV * num_digits)
OUTPUT:
RETVAL
+SV *
+test_Perl_langinfo(SV * item)
+ CODE:
+ RETVAL = newSVpv(Perl_langinfo(SvIV(item)), 0);
+ OUTPUT:
+ RETVAL
+
MODULE = XS::APItest PACKAGE = XS::APItest::Backrefs
void
diff --git a/ext/XS-APItest/t/locale.t b/ext/XS-APItest/t/locale.t
index be594b0804..08c16a8499 100644
--- a/ext/XS-APItest/t/locale.t
+++ b/ext/XS-APItest/t/locale.t
@@ -22,9 +22,6 @@ for (@locales) {
}
}
-skip_all("no non-dot radix locales available") unless $non_dot_locale;
-
-plan tests => 2;
SKIP: {
if ($Config{usequadmath}) {
@@ -34,3 +31,106 @@ SKIP: {
use locale;
is(test_Gconvert(4.179, 2), "4.2", "Gconvert doesn't recognize underlying locale inside 'use locale'");
}
+
+my %correct_C_responses = (
+ # Commented out entries are ones which there is room for variation
+ ABDAY_1 => 'Sun',
+ ABDAY_2 => 'Mon',
+ ABDAY_3 => 'Tue',
+ ABDAY_4 => 'Wed',
+ ABDAY_5 => 'Thu',
+ ABDAY_6 => 'Fri',
+ ABDAY_7 => 'Sat',
+ ABMON_1 => 'Jan',
+ ABMON_10 => 'Oct',
+ ABMON_11 => 'Nov',
+ ABMON_12 => 'Dec',
+ ABMON_2 => 'Feb',
+ ABMON_3 => 'Mar',
+ ABMON_4 => 'Apr',
+ ABMON_5 => 'May',
+ ABMON_6 => 'Jun',
+ ABMON_7 => 'Jul',
+ ABMON_8 => 'Aug',
+ ABMON_9 => 'Sep',
+ ALT_DIGITS => '',
+ AM_STR => 'AM',
+ #CODESET => 'ANSI_X3.4-1968',
+ #CRNCYSTR => '-',
+ DAY_1 => 'Sunday',
+ DAY_2 => 'Monday',
+ DAY_3 => 'Tuesday',
+ DAY_4 => 'Wednesday',
+ DAY_5 => 'Thursday',
+ DAY_6 => 'Friday',
+ DAY_7 => 'Saturday',
+ #D_FMT => '%m/%d/%y',
+ #D_T_FMT => '%a %b %e %H:%M:%S %Y',
+ ERA => '',
+ #ERA_D_FMT => '',
+ #ERA_D_T_FMT => '',
+ #ERA_T_FMT => '',
+ MON_1 => 'January',
+ MON_10 => 'October',
+ MON_11 => 'November',
+ MON_12 => 'December',
+ MON_2 => 'February',
+ MON_3 => 'March',
+ MON_4 => 'April',
+ MON_5 => 'May',
+ MON_6 => 'June',
+ MON_7 => 'July',
+ MON_8 => 'August',
+ MON_9 => 'September',
+ #NOEXPR => '^[nN]',
+ PM_STR => 'PM',
+ RADIXCHAR => '.',
+ THOUSEP => '',
+ #T_FMT => '%H:%M:%S',
+ #T_FMT_AMPM => '%I:%M:%S %p',
+ #YESEXPR => '^[yY]',
+ );
+
+my $hdr = "../../perl_langinfo.h";
+open my $fh, "<", $hdr;
+$|=1;
+
+SKIP: {
+ skip "No LC_ALL", 1 unless find_locales( &LC_ALL );
+
+ use POSIX;
+ setlocale(LC_ALL, "C");
+ eval "use I18N::Langinfo qw(langinfo RADIXCHAR); langinfo(RADIXCHAR)";
+ my $has_nl_langinfo = $@ eq "";
+
+ skip "Can't open $hdr for reading: $!", 1 unless $fh;
+
+ my %items;
+
+ # Find all the current items from the header, and their values.
+ # For non-nl_langinfo systems, those values are arbitrary negative numbers
+ # set in the header. Otherwise they are the nl_langinfo approved values,
+ # which for the moment is the item name.
+ while (<$fh>) {
+ chomp;
+ next unless / - \d+ $ /x;
+ s/ ^ .* PERL_//x;
+ m/ (.*) \ (.*) /x;
+ $items{$1} = ($has_nl_langinfo)
+ ? $1
+ : $2;
+ }
+
+ # Get the translation from item name to numeric value.
+ I18N::Langinfo->import(keys %items) if $has_nl_langinfo;
+
+ foreach my $item (sort keys %items) {
+ my $result = test_Perl_langinfo(eval $items{$item});
+ if (exists $correct_C_responses{$item}) {
+ is ($result, $correct_C_responses{$item},
+ "Returns expected value for $item");
+ }
+ }
+}
+
+done_testing();