2 require '../../t/test.pl';
3 require '../../t/loc_tools.pl'; # to find locales
9 skip_all("locales not available") unless locales_enabled('LC_NUMERIC');
11 my @locales = eval { find_locales( &LC_NUMERIC ) };
12 skip_all("no LC_NUMERIC locales available") unless @locales;
17 setlocale(LC_NUMERIC, $_) or next;
18 my $in = 4.2; # avoid any constant folding bugs
19 if (sprintf("%g", $in) ne "4.2") {
27 if ($Config{usequadmath}) {
28 skip "no gconvert with usequadmath", 2;
30 is(test_Gconvert(4.179, 2), "4.2", "Gconvert doesn't recognize underlying locale outside 'use locale'");
32 is(test_Gconvert(4.179, 2), "4.2", "Gconvert doesn't recognize underlying locale inside 'use locale'");
35 my %correct_C_responses = (
36 # Entries that are undef could have varying returns
96 my $hdr = "../../perl_langinfo.h";
97 open my $fh, "<", $hdr;
101 skip "No LC_ALL", 1 unless find_locales( &LC_ALL );
104 setlocale(LC_ALL, "C");
105 eval "use I18N::Langinfo qw(langinfo RADIXCHAR); langinfo(RADIXCHAR)";
106 my $has_nl_langinfo = $@ eq "";
108 skip "Can't open $hdr for reading: $!", 1 unless $fh;
112 # Find all the current items from the header, and their values.
113 # For non-nl_langinfo systems, those values are arbitrary negative numbers
114 # set in the header. Otherwise they are the nl_langinfo approved values,
115 # which for the moment is the item name.
116 # The relevant lines look like: # define YESSTR -54
119 next unless / - \d+ $ /x;
120 s/ ^ \# \s* define \s*//x;
122 $items{$1} = ($has_nl_langinfo)
123 ? $1 # Yields 'YESSTR'
127 # Get the translation from item name to numeric value.
128 I18N::Langinfo->import(keys %items) if $has_nl_langinfo;
130 foreach my $formal_item (sort keys %items) {
131 if (exists $correct_C_responses{$formal_item}) {
132 my $correct = $correct_C_responses{$formal_item};
133 my $item = eval $items{$formal_item};
134 skip "This platform apparently doesn't support $formal_item", 1 if $@;
135 my $result = test_Perl_langinfo($item);
136 if (defined $correct) {
137 is ($result, $correct,
138 "Returns expected value" . "('$correct') for $formal_item");
142 "Returns a value (in this case '$result') for $formal_item");