SYN SYN
[p5sagit/p5-mst-13.2.git] / t / pragma / locale.t
index c453c47..c8a0df8 100755 (executable)
@@ -2,7 +2,7 @@
 
 BEGIN {
     chdir 't' if -d 't';
-    unshift @INC, '../lib';
+    @INC = '../lib';
     unshift @INC, '.';
     require Config; import Config;
     if (!$Config{d_setlocale} || $Config{ccflags} =~ /\bD?NO_LOCALE\b/) {
@@ -34,7 +34,7 @@ eval {
 # and mingw32 uses said silly CRT
 $have_setlocale = 0 if $^O eq 'MSWin32' && $Config{cc} =~ /^(cl|gcc)/i;
 
-print "1..", ($have_setlocale ? 115 : 98), "\n";
+print "1..", ($have_setlocale ? 116 : 98), "\n";
 
 use vars qw(&LC_ALL);
 
@@ -52,7 +52,7 @@ sub ok {
 # even the default locale will taint under 'use locale'.
 
 sub is_tainted { # hello, camel two.
-    local $^W; # no warnings 'undef'
+    no warnings 'uninitialized' ;
     my $dummy;
     not eval { $dummy = join("", @_), kill 0; 1 }
 }
@@ -286,6 +286,11 @@ Turkish:tr:tr:9 turkish8
 Yiddish:::1 15
 EOF
 
+if ($^O eq 'os390') {
+    $locales =~ s/Svenska Swedish:sv:fi se:1 15\n//;
+    $locales =~ s/Thai:th:th:11 tis620\n//;
+}
+
 sub in_utf8 () { $^H & 0x08 }
 
 if (in_utf8) {
@@ -323,6 +328,9 @@ sub decode_encodings {
            push @enc, $_;
        }
     }
+    if ($^O eq 'os390') {
+       push @enc, qw(IBM-037 IBM-819 IBM-1047);
+    }
 
     return @enc;
 }
@@ -380,6 +388,7 @@ my %Problem;
 my %Okay;
 my %Testing;
 my @Neoalpha;
+my %Neoalpha;
 
 sub tryneoalpha {
     my ($Locale, $i, $test) = @_;
@@ -443,6 +452,7 @@ foreach $Locale (@Locale) {
        @Neoalpha = ();
        for (keys %UPPER, keys %lower) {
            push(@Neoalpha, $_) if (/\W/);
+           $Neoalpha{$_} = $_;
        }
     }
 
@@ -572,9 +582,9 @@ foreach $Locale (@Locale) {
     tryneoalpha($Locale, 104, $c eq $d); 
 
     {
+       use warnings;
        my $w = 0;
        local $SIG{__WARN__} = sub { $w++ };
-       local $^W = 1;
 
        # the == (among other ops) used to warn for locales
        # that had something else than "." as the radix character
@@ -634,11 +644,32 @@ foreach $Locale (@Locale) {
                    lcA($x, $y) == 1 && lcB($x, $y) == 1 ||
                    lcA($x, $z) == 0 && lcB($x, $z) == 0);
     }
+
+    debug "# testing 116 with locale '$Locale'\n";
+    {
+       use locale;
+
+       my @f = ();
+       foreach my $x (keys %UPPER) {
+           my $y = lc $x;
+           next unless uc $y eq $x;
+           push @f, $x unless $x =~ /$y/i && $y =~ /$x/i;
+       }
+       foreach my $x (keys %lower) {
+           my $y = uc $x;
+           next unless lc $y eq $x;
+           push @f, $x unless $x =~ /$y/i && $y =~ /$x/i;
+       }
+       tryneoalpha($Locale, 116, @f == 0);
+       print "# testing 116 failed for locale '$Locale' for characters @f\n"
+            if @f;
+    }
+
 }
 
 # Recount the errors.
 
-foreach (99..115) {
+foreach (99..116) {
     if ($Problem{$_} || !defined $Okay{$_} || !@{$Okay{$_}}) {
        if ($_ == 102) {
            print "# The failure of test 102 is not necessarily fatal.\n";
@@ -654,7 +685,7 @@ foreach (99..115) {
 
 my $didwarn = 0;
 
-foreach (99..115) {
+foreach (99..116) {
     if ($Problem{$_}) {
        my @f = sort keys %{ $Problem{$_} };
        my $f = join(" ", @f);
@@ -679,26 +710,30 @@ EOW
     }
 }
 
-# Tell which locales ere okay.
+# Tell which locales were okay.
 
 if ($didwarn) {
     my @s;
     
     foreach my $l (@Locale) {
        my $p = 0;
-       foreach my $t (102..102) {
+       foreach my $t (102..116) {
            $p++ if $Problem{$t}{$l};
        }
        push @s, $l if $p == 0;
     }
     
-    my $s = join(" ", @s);
-    $s =~ s/(.{50,60}) /$1\n#\t/g;
-
-    warn
-       "# The following locales\n#\n",
-        "#\t", $s, "\n#\n",
-       "# tested okay.\n#\n",
+    if (@s) {
+        my $s = join(" ", @s);
+        $s =~ s/(.{50,60}) /$1\n#\t/g;
+
+        warn
+           "# The following locales\n#\n",
+            "#\t", $s, "\n#\n",
+           "# tested okay.\n#\n",
+    } else {
+        warn "# None of your locales was fully okay.\n";
+    }
 }
 
 # eof