This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
lib/locale.t: Improve test names; add some names
[perl5.git] / lib / locale.t
CommitLineData
8ebc5c01
PP
1#!./perl -wT
2
66cbab2c
KW
3# This tests plain 'use locale' and adorned 'use locale ":not_characters"'
4# Because these pragmas are compile time, and I (khw) am trying to test
5# without using 'eval' as much as possible, which might cloud the issue, the
6# crucial parts of the code are duplicated in a block for each pragma.
7
6c2e653d
KW
8# To make a TODO test, add the string 'TODO' to its %test_names value
9
e3a2734b
KW
10binmode STDOUT, ':utf8';
11binmode STDERR, ':utf8';
12
8ebc5c01
PP
13BEGIN {
14 chdir 't' if -d 't';
20822f61 15 @INC = '../lib';
f9cbebe1 16 unshift @INC, '.';
b002077a 17 require Config; import Config;
97a0514d 18 if (!$Config{d_setlocale} || $Config{ccflags} =~ /\bD?NO_LOCALE\b/) {
b002077a
CS
19 print "1..0\n";
20 exit;
21 }
73fc293b 22 require './loc_tools.pl';
2de3dbcc 23 $| = 1;
8ebc5c01
PP
24}
25
26use strict;
26c1569f 27use feature 'fc';
8ebc5c01 28
92891c66 29# =1 adds debugging output; =2 increases the verbosity somewhat
108a305e 30my $debug = $ENV{PERL_DEBUG_FULL_TEST} // 0;
284102e8 31
6d5d702a
KW
32# Certain tests have been shown to be problematical for a few locales. Don't
33# fail them unless at least this percentage of the tested locales fail.
8321c25f
KW
34# Some Windows machines are defective in every locale but the C, calling \t
35# printable; superscripts to be digits, etc. See
662399e7
KW
36# http://markmail.org/message/5jwam4xsx4amsdnv. Also on AIX machines, many
37# locales call a no-break space a graphic.
df33771d 38# (There aren't 1000 locales currently in existence, so 99.9 works)
31f658ea
KW
39my $acceptable_failure_percentage = ($^O =~ / ^ ( MSWin32 | AIX ) $ /ix)
40 ? 99.9
41 : 5;
6d5d702a 42
7493b8f2 43# The list of test numbers of the problematic tests.
5b1f18a7 44my %problematical_tests;
7493b8f2
KW
45
46
db4b7445
A
47use Dumpvalue;
48
49my $dumper = Dumpvalue->new(
50 tick => qq{"},
51 quoteHighBit => 0,
52 unctrl => "quote"
53 );
6be75cd7 54sub debug {
db4b7445
A
55 return unless $debug;
56 my($mess) = join "", @_;
57 chop $mess;
58 print $dumper->stringify($mess,1), "\n";
6be75cd7
JH
59}
60
92891c66
KW
61sub debug_more {
62 return unless $debug > 1;
63 return debug(@_);
64}
65
6be75cd7
JH
66sub debugf {
67 printf @_ if $debug;
68}
69
0e053d1e 70$a = 'abc %';
8ebc5c01 71
c213d471
KW
72my $test_num = 0;
73
8ebc5c01 74sub ok {
c213d471 75 my ($result, $message) = @_;
e3a2734b 76 $message = "" unless defined $message;
8ebc5c01
PP
77
78 print 'not ' unless ($result);
c213d471 79 print "ok " . ++$test_num;
e3a2734b
KW
80 print " $message";
81 print "\n";
8ebc5c01
PP
82}
83
84# First we'll do a lot of taint checking for locales.
85# This is the easiest to test, actually, as any locale,
86# even the default locale will taint under 'use locale'.
87
88sub is_tainted { # hello, camel two.
9f1b1f2d 89 no warnings 'uninitialized' ;
8ebc5c01 90 my $dummy;
ba74571d 91 local $@;
8ebc5c01
PP
92 not eval { $dummy = join("", @_), kill 0; 1 }
93}
94
a9b7c637
KW
95sub check_taint ($;$) {
96 my $message_tail = $_[1] // "";
2575405e
KW
97
98 # Extra blanks are so aligns with taint_not output
99 $message_tail = ": $message_tail" if $message_tail;
a9b7c637 100 ok is_tainted($_[0]), "verify that is tainted$message_tail";
8ebc5c01
PP
101}
102
a9b7c637
KW
103sub check_taint_not ($;$) {
104 my $message_tail = $_[1] // "";
2575405e 105 $message_tail = ": $message_tail" if $message_tail;
a9b7c637 106 ok((not is_tainted($_[0])), "verify that isn't tainted$message_tail");
8ebc5c01
PP
107}
108
bf3cd0e6
KW
109"\tb\t" =~ /^m?(\s)(.*)\1$/;
110check_taint_not $&, "not tainted outside 'use locale'";
111;
112
8ebc5c01
PP
113use locale; # engage locale and therefore locale taint.
114
2575405e
KW
115
116check_taint_not $a, '$a';
117
118check_taint uc($a), 'uc($a)';
119check_taint "\U$a", '"\U$a"';
120check_taint ucfirst($a), 'ucfirst($a)';
121check_taint "\u$a", '"\u$a"';
122check_taint lc($a), 'lc($a)';
123check_taint fc($a), 'fc($a)';
124check_taint "\L$a", '"\L$a"';
125check_taint "\F$a", '"\F$a"';
126check_taint lcfirst($a), 'lcfirst($a)';
127check_taint "\l$a", '"\l$a"';
128
129check_taint_not sprintf('%e', 123.456), "sprintf('%e', 123.456)";
130check_taint_not sprintf('%f', 123.456), "sprintf('%f', 123.456)";
131check_taint_not sprintf('%g', 123.456), "sprintf('%g', 123.456)";
132check_taint_not sprintf('%d', 123.456), "sprintf('%d', 123.456)";
133check_taint_not sprintf('%x', 123.456), "sprintf('%x', 123.456)";
8ebc5c01
PP
134
135$_ = $a; # untaint $_
136
137$_ = uc($a); # taint $_
138
2575405e 139check_taint $_, '$_ = uc($a)';
8ebc5c01
PP
140
141/(\w)/; # taint $&, $`, $', $+, $1.
2575405e 142check_taint $&, "\$& from /(\\w)/";
fdf73a7f
KW
143check_taint $`, "\t\$`";
144check_taint $', "\t\$'";
145check_taint $+, "\t\$+";
146check_taint $1, "\t\$1";
147check_taint_not $2, "\t\$2";
8ebc5c01
PP
148
149/(.)/; # untaint $&, $`, $', $+, $1.
2575405e 150check_taint_not $&, "\$& from /(.)/";
fdf73a7f
KW
151check_taint_not $`, "\t\$`";
152check_taint_not $', "\t\$'";
153check_taint_not $+, "\t\$+";
154check_taint_not $1, "\t\$1";
155check_taint_not $2, "\t\$2";
8ebc5c01
PP
156
157/(\W)/; # taint $&, $`, $', $+, $1.
2575405e 158check_taint $&, "\$& from /(\\W)/";
fdf73a7f
KW
159check_taint $`, "\t\$`";
160check_taint $', "\t\$'";
161check_taint $+, "\t\$+";
162check_taint $1, "\t\$1";
163check_taint_not $2, "\t\$2";
8ebc5c01 164
9486279c 165/(.)/; # untaint $&, $`, $', $+, $1.
2575405e 166check_taint_not $&, "\$& from /(.)/";
fdf73a7f
KW
167check_taint_not $`, "\t\$`";
168check_taint_not $', "\t\$'";
169check_taint_not $+, "\t\$+";
170check_taint_not $1, "\t\$1";
171check_taint_not $2, "\t\$2";
9486279c 172
8ebc5c01 173/(\s)/; # taint $&, $`, $', $+, $1.
2575405e 174check_taint $&, "\$& from /(\\s)/";
fdf73a7f
KW
175check_taint $`, "\t\$`";
176check_taint $', "\t\$'";
177check_taint $+, "\t\$+";
178check_taint $1, "\t\$1";
179check_taint_not $2, "\t\$2";
8ebc5c01 180
9486279c 181/(.)/; # untaint $&, $`, $', $+, $1.
2575405e 182check_taint_not $&, "\$& from /(.)/";
9486279c 183
8ebc5c01 184/(\S)/; # taint $&, $`, $', $+, $1.
2575405e 185check_taint $&, "\$& from /(\\S)/";
fdf73a7f
KW
186check_taint $`, "\t\$`";
187check_taint $', "\t\$'";
188check_taint $+, "\t\$+";
189check_taint $1, "\t\$1";
190check_taint_not $2, "\t\$2";
8ebc5c01 191
63baef57 192/(.)/; # untaint $&, $`, $', $+, $1.
2575405e 193check_taint_not $&, "\$& from /(.)/";
63baef57
KW
194
195"a" =~ /(a)|(\w)/; # taint $&, $`, $', $+, $1.
2575405e 196check_taint $&, "\$& from /(a)|(\\w)/";
63baef57
KW
197check_taint $`, "\t\$`";
198check_taint $', "\t\$'";
199check_taint $+, "\t\$+";
200check_taint $1, "\t\$1";
2575405e
KW
201ok($1 eq 'a', ("\t" x 5) . "\$1 is 'a'");
202ok(! defined $2, ("\t" x 5) . "\$2 is undefined");
63baef57
KW
203check_taint_not $2, "\t\$2";
204check_taint_not $3, "\t\$3";
205
206/(.)/; # untaint $&, $`, $', $+, $1.
2575405e 207check_taint_not $&, "\$& from /(.)/";
63baef57
KW
208
209"\N{CYRILLIC SMALL LETTER A}" =~ /(\N{CYRILLIC CAPITAL LETTER A})/i; # no tainting because no locale dependence
2575405e 210check_taint_not $&, "\$& from /(\\N{CYRILLIC CAPITAL LETTER A})/i";
63baef57
KW
211check_taint_not $`, "\t\$`";
212check_taint_not $', "\t\$'";
213check_taint_not $+, "\t\$+";
214check_taint_not $1, "\t\$1";
2575405e 215ok($1 eq "\N{CYRILLIC SMALL LETTER A}", ("\t" x 4) . "\t\$1 is 'small cyrillic a'");
63baef57
KW
216check_taint_not $2, "\t\$2";
217
218/(.)/; # untaint $&, $`, $', $+, $1.
2575405e 219check_taint_not $&, "\$& from /./";
63baef57 220
63baef57 221/(.)/; # untaint $&, $`, $', $+, $1.
2575405e 222check_taint_not $&, "\$& from /(.)/";
63baef57
KW
223
224"a:" =~ /(.)\b(.)/; # taint $&, $`, $', $+, $1.
2575405e 225check_taint $&, "\$& from /(.)\\b(.)/";
63baef57
KW
226check_taint $`, "\t\$`";
227check_taint $', "\t\$'";
228check_taint $+, "\t\$+";
229check_taint $1, "\t\$1";
230check_taint $2, "\t\$2";
231check_taint_not $3, "\t\$3";
232
233/(.)/; # untaint $&, $`, $', $+, $1.
2575405e 234check_taint_not $&, "\$& from /./";
63baef57
KW
235
236"aa" =~ /(.)\B(.)/; # taint $&, $`, $', $+, $1.
2575405e 237check_taint $&, "\$& from /(.)\\B(.)/";
63baef57
KW
238check_taint $`, "\t\$`";
239check_taint $', "\t\$'";
240check_taint $+, "\t\$+";
241check_taint $1, "\t\$1";
242check_taint $2, "\t\$2";
243check_taint_not $3, "\t\$3";
244
245/(.)/; # untaint $&, $`, $', $+, $1.
2575405e 246check_taint_not $&, "\$& from /./";
63baef57
KW
247
248"aaa" =~ /(.).(\1)/i; # notaint because not locale dependent
2575405e 249check_taint_not $&, "\$ & from /(.).(\\1)/";
63baef57
KW
250check_taint_not $`, "\t\$`";
251check_taint_not $', "\t\$'";
252check_taint_not $+, "\t\$+";
253check_taint_not $1, "\t\$1";
254check_taint_not $2, "\t\$2";
2575405e 255check_taint_not $3, "\t\$3";
63baef57
KW
256
257/(.)/; # untaint $&, $`, $', $+, $1.
2575405e 258check_taint_not $&, "\$ & from /./";
63baef57 259
8ebc5c01
PP
260$_ = $a; # untaint $_
261
2575405e 262check_taint_not $_, 'untainting $_ works';
8ebc5c01
PP
263
264/(b)/; # this must not taint
2575405e 265check_taint_not $&, "\$ & from /(b)/";
fdf73a7f
KW
266check_taint_not $`, "\t\$`";
267check_taint_not $', "\t\$'";
268check_taint_not $+, "\t\$+";
269check_taint_not $1, "\t\$1";
270check_taint_not $2, "\t\$2";
8ebc5c01
PP
271
272$_ = $a; # untaint $_
273
2575405e 274check_taint_not $_, 'untainting $_ works';
8ebc5c01
PP
275
276$b = uc($a); # taint $b
277s/(.+)/$b/; # this must taint only the $_
278
2575405e 279check_taint $_, '$_ (wasn\'t tainted) from s/(.+)/$b/ where $b is tainted';
fdf73a7f
KW
280check_taint_not $&, "\t\$&";
281check_taint_not $`, "\t\$`";
282check_taint_not $', "\t\$'";
283check_taint_not $+, "\t\$+";
284check_taint_not $1, "\t\$1";
285check_taint_not $2, "\t\$2";
8ebc5c01
PP
286
287$_ = $a; # untaint $_
288
289s/(.+)/b/; # this must not taint
2575405e 290check_taint_not $_, '$_ (wasn\'t tainted) from s/(.+)/b/';
fdf73a7f
KW
291check_taint_not $&, "\t\$&";
292check_taint_not $`, "\t\$`";
293check_taint_not $', "\t\$'";
294check_taint_not $+, "\t\$+";
295check_taint_not $1, "\t\$1";
296check_taint_not $2, "\t\$2";
8ebc5c01
PP
297
298$b = $a; # untaint $b
299
300($b = $a) =~ s/\w/$&/;
2575405e
KW
301check_taint $b, '$b from ($b = $a) =~ s/\w/$&/'; # $b should be tainted.
302check_taint_not $a, '$a from ($b = $a) =~ s/\w/$&/'; # $a should be not.
8ebc5c01
PP
303
304$_ = $a; # untaint $_
305
306s/(\w)/\l$1/; # this must taint
2575405e 307check_taint $_, '$_ (wasn\'t tainted) from s/(\w)/\l$1/,'; # this must taint
fdf73a7f
KW
308check_taint $&, "\t\$&";
309check_taint $`, "\t\$`";
310check_taint $', "\t\$'";
311check_taint $+, "\t\$+";
312check_taint $1, "\t\$1";
313check_taint_not $2, "\t\$2";
8ebc5c01
PP
314
315$_ = $a; # untaint $_
316
317s/(\w)/\L$1/; # this must taint
2575405e 318check_taint $_, '$_ (wasn\'t tainted) from s/(\w)/\L$1/,';
fdf73a7f
KW
319check_taint $&, "\t\$&";
320check_taint $`, "\t\$`";
321check_taint $', "\t\$'";
322check_taint $+, "\t\$+";
323check_taint $1, "\t\$1";
324check_taint_not $2, "\t\$2";
8ebc5c01
PP
325
326$_ = $a; # untaint $_
327
328s/(\w)/\u$1/; # this must taint
2575405e 329check_taint $_, '$_ (wasn\'t tainted) from s/(\w)/\u$1/';
fdf73a7f
KW
330check_taint $&, "\t\$&";
331check_taint $`, "\t\$`";
332check_taint $', "\t\$'";
333check_taint $+, "\t\$+";
334check_taint $1, "\t\$1";
335check_taint_not $2, "\t\$2";
8ebc5c01
PP
336
337$_ = $a; # untaint $_
338
339s/(\w)/\U$1/; # this must taint
2575405e 340check_taint $_, '$_ (wasn\'t tainted) from s/(\w)/\U$1/';
fdf73a7f
KW
341check_taint $&, "\t\$&";
342check_taint $`, "\t\$`";
343check_taint $', "\t\$'";
344check_taint $+, "\t\$+";
345check_taint $1, "\t\$1";
346check_taint_not $2, "\t\$2";
8ebc5c01 347
faab3281
KW
348# After all this tainting $a should be cool.
349
2575405e 350check_taint_not $a, '$a still not tainted';
faab3281 351
b99851e1
KW
352"a" =~ /([a-z])/;
353check_taint_not $1, '"a" =~ /([a-z])/';
354"foo.bar_baz" =~ /^(.*)[._](.*?)$/; # Bug 120675
355check_taint_not $1, '"foo.bar_baz" =~ /^(.*)[._](.*?)$/';
356
7a9d1c02 357# BE SURE TO COPY ANYTHING YOU ADD to the block below
8ebc5c01 358
66cbab2c
KW
359{ # This is just the previous tests copied here with a different
360 # compile-time pragma.
361
362 use locale ':not_characters'; # engage restricted locale with different
363 # tainting rules
364
365 check_taint_not $a;
366
367 check_taint_not uc($a);
368 check_taint_not "\U$a";
369 check_taint_not ucfirst($a);
370 check_taint_not "\u$a";
371 check_taint_not lc($a);
26c1569f 372 check_taint_not fc($a);
66cbab2c 373 check_taint_not "\L$a";
26c1569f 374 check_taint_not "\F$a";
66cbab2c
KW
375 check_taint_not lcfirst($a);
376 check_taint_not "\l$a";
377
378 check_taint_not sprintf('%e', 123.456);
379 check_taint_not sprintf('%f', 123.456);
380 check_taint_not sprintf('%g', 123.456);
381 check_taint_not sprintf('%d', 123.456);
382 check_taint_not sprintf('%x', 123.456);
383
384 $_ = $a; # untaint $_
385
386 $_ = uc($a); # taint $_
387
388 check_taint_not $_;
389
390 /(\w)/; # taint $&, $`, $', $+, $1.
391 check_taint_not $&;
392 check_taint_not $`;
393 check_taint_not $';
394 check_taint_not $+;
395 check_taint_not $1;
396 check_taint_not $2;
397
398 /(.)/; # untaint $&, $`, $', $+, $1.
399 check_taint_not $&;
400 check_taint_not $`;
401 check_taint_not $';
402 check_taint_not $+;
403 check_taint_not $1;
404 check_taint_not $2;
405
406 /(\W)/; # taint $&, $`, $', $+, $1.
407 check_taint_not $&;
408 check_taint_not $`;
409 check_taint_not $';
410 check_taint_not $+;
411 check_taint_not $1;
412 check_taint_not $2;
413
414 /(\s)/; # taint $&, $`, $', $+, $1.
415 check_taint_not $&;
416 check_taint_not $`;
417 check_taint_not $';
418 check_taint_not $+;
419 check_taint_not $1;
420 check_taint_not $2;
421
422 /(\S)/; # taint $&, $`, $', $+, $1.
423 check_taint_not $&;
424 check_taint_not $`;
425 check_taint_not $';
426 check_taint_not $+;
427 check_taint_not $1;
428 check_taint_not $2;
429
430 $_ = $a; # untaint $_
431
432 check_taint_not $_;
433
434 /(b)/; # this must not taint
435 check_taint_not $&;
436 check_taint_not $`;
437 check_taint_not $';
438 check_taint_not $+;
439 check_taint_not $1;
440 check_taint_not $2;
441
442 $_ = $a; # untaint $_
443
444 check_taint_not $_;
445
446 $b = uc($a); # taint $b
447 s/(.+)/$b/; # this must taint only the $_
448
449 check_taint_not $_;
450 check_taint_not $&;
451 check_taint_not $`;
452 check_taint_not $';
453 check_taint_not $+;
454 check_taint_not $1;
455 check_taint_not $2;
456
457 $_ = $a; # untaint $_
458
459 s/(.+)/b/; # this must not taint
460 check_taint_not $_;
461 check_taint_not $&;
462 check_taint_not $`;
463 check_taint_not $';
464 check_taint_not $+;
465 check_taint_not $1;
466 check_taint_not $2;
467
468 $b = $a; # untaint $b
469
470 ($b = $a) =~ s/\w/$&/;
471 check_taint_not $b; # $b should be tainted.
472 check_taint_not $a; # $a should be not.
473
474 $_ = $a; # untaint $_
475
476 s/(\w)/\l$1/; # this must taint
477 check_taint_not $_;
478 check_taint_not $&;
479 check_taint_not $`;
480 check_taint_not $';
481 check_taint_not $+;
482 check_taint_not $1;
483 check_taint_not $2;
484
485 $_ = $a; # untaint $_
486
487 s/(\w)/\L$1/; # this must taint
488 check_taint_not $_;
489 check_taint_not $&;
490 check_taint_not $`;
491 check_taint_not $';
492 check_taint_not $+;
493 check_taint_not $1;
494 check_taint_not $2;
495
496 $_ = $a; # untaint $_
497
498 s/(\w)/\u$1/; # this must taint
499 check_taint_not $_;
500 check_taint_not $&;
501 check_taint_not $`;
502 check_taint_not $';
503 check_taint_not $+;
504 check_taint_not $1;
505 check_taint_not $2;
506
507 $_ = $a; # untaint $_
508
509 s/(\w)/\U$1/; # this must taint
510 check_taint_not $_;
511 check_taint_not $&;
512 check_taint_not $`;
513 check_taint_not $';
514 check_taint_not $+;
515 check_taint_not $1;
516 check_taint_not $2;
517
518 # After all this tainting $a should be cool.
519
520 check_taint_not $a;
7a9d1c02
KW
521
522 "a" =~ /([a-z])/;
523 check_taint_not $1, '"a" =~ /([a-z])/';
524 "foo.bar_baz" =~ /^(.*)[._](.*?)$/; # Bug 120675
525 check_taint_not $1, '"foo.bar_baz" =~ /^(.*)[._](.*?)$/';
66cbab2c
KW
526}
527
528# Here are in scope of 'use locale'
529
8ebc5c01
PP
530# I think we've seen quite enough of taint.
531# Let us do some *real* locale work now,
284102e8 532# unless setlocale() is missing (i.e. minitest).
8ebc5c01 533
6cf0b567 534# The test number before our first setlocale()
66330f13 535my $final_without_setlocale = $test_num;
6cf0b567 536
284102e8
JH
537# Find locales.
538
6be75cd7
JH
539debug "# Scanning for locales...\n";
540
9b0711ee
KW
541require POSIX; import POSIX ':locale_h';
542
543my @Locale = find_locales([ &POSIX::LC_CTYPE, &POSIX::LC_ALL ]);
4599a1de 544
887ef7ed
PP
545debug "# Locales =\n";
546for ( @Locale ) {
547 debug "# $_\n";
548}
8ebc5c01 549
d369fd5b
KW
550unless (@Locale) {
551 print "1..$test_num\n";
552 exit;
553}
554
d369fd5b
KW
555
556setlocale(&POSIX::LC_ALL, "C");
557
73fc293b
KW
558my %posixes;
559
284102e8 560my %Problem;
2a680da6
JH
561my %Okay;
562my %Testing;
30032ef4 563my @Added_alpha; # Alphas that aren't in the C locale.
c08acc4c 564my %test_names;
284102e8 565
705af3af 566sub disp_chars {
019bf7dd
KW
567 # This returns a display string denoting the input parameter @_, each
568 # entry of which is a single character in the range 0-255. The first part
569 # of the output is a string of the characters in @_ that are ASCII
570 # graphics, and hence unambiguously displayable. They are given by code
571 # point order. The second part is the remaining code points, the ordinals
572 # of which are each displayed as 2-digit hex. Blanks are inserted so as
573 # to keep anything from the first part looking like a 2-digit hex number.
574
575 no locale;
576 my @chars = sort { ord $a <=> ord $b } @_;
577 my $output = "";
019bf7dd
KW
578 my $range_start;
579 my $start_class;
580 push @chars, chr(258); # This sentinel simplifies the loop termination
581 # logic
582 foreach my $i (0 .. @chars - 1) {
583 my $char = $chars[$i];
584 my $range_end;
585 my $class;
586
587 # We avoid using [:posix:] classes, as these are being tested in this
588 # file. Each equivalence class below is for things that can appear in
589 # a range; those that can't be in a range have class -1. 0 for those
590 # which should be output in hex; and >0 for the other ranges
591 if ($char =~ /[A-Z]/) {
592 $class = 2;
593 }
594 elsif ($char =~ /[a-z]/) {
595 $class = 3;
596 }
597 elsif ($char =~ /[0-9]/) {
598 $class = 4;
599 }
78fbfaf5
KW
600 # Uncomment to get literal punctuation displayed instead of hex
601 #elsif ($char =~ /[[\]!"#\$\%&\'()*+,.\/:\\;<=>?\@\^_`{|}~-]/) {
602 # $class = -1; # Punct never appears in a range
603 #}
019bf7dd
KW
604 else {
605 $class = 0; # Output in hex
606 }
607
608 if (! defined $range_start) {
609 if ($class < 0) {
78fbfaf5 610 $output .= " " . $char;
019bf7dd
KW
611 }
612 else {
613 $range_start = ord $char;
614 $start_class = $class;
615 }
616 } # A range ends if not consecutive, or the class-type changes
617 elsif (ord $char != ($range_end = ord($chars[$i-1])) + 1
618 || $class != $start_class)
619 {
620
621 # Here, the current character is not in the range. This means the
622 # previous character must have been. Output the range up through
623 # that one.
624 my $range_length = $range_end - $range_start + 1;
625 if ($start_class > 0) {
626 $output .= " " . chr($range_start);
627 $output .= "-" . chr($range_end) if $range_length > 1;
628 }
629 else {
78fbfaf5
KW
630 $output .= sprintf(" %02X", $range_start);
631 $output .= sprintf("-%02X", $range_end) if $range_length > 1;
019bf7dd
KW
632 }
633
634 # Handle the new current character, as potentially beginning a new
635 # range
636 undef $range_start;
637 redo;
638 }
639 }
640
641 $output =~ s/^ //;
78fbfaf5 642 return $output;
019bf7dd
KW
643}
644
30032ef4
KW
645sub report_result {
646 my ($Locale, $i, $pass_fail, $message) = @_;
15bbd6a2
KW
647 $message //= "";
648 $message = " ($message)" if $message;
30032ef4 649 unless ($pass_fail) {
2a680da6 650 $Problem{$i}{$Locale} = 1;
baae13cb 651 debug "# failed $i ($test_names{$i}) with locale '$Locale'$message\n";
2a680da6
JH
652 } else {
653 push @{$Okay{$i}}, $Locale;
654 }
655}
656
7c844d17
KW
657sub report_multi_result {
658 my ($Locale, $i, $results_ref) = @_;
659
660 # $results_ref points to an array, each element of which is a character that was
661 # in error for this test numbered '$i'. If empty, the test passed
662
663 my $message = "";
664 if (@$results_ref) {
705af3af 665 $message = join " ", "for", disp_chars(@$results_ref);
7c844d17
KW
666 }
667 report_result($Locale, $i, @$results_ref == 0, $message);
668}
669
c4093d7d
KW
670my $first_locales_test_number = $final_without_setlocale + 1;
671my $locales_test_number;
672my $not_necessarily_a_problem_test_number;
6d5d702a 673my $first_casing_test_number;
c4093d7d
KW
674my %setlocale_failed; # List of locales that setlocale() didn't work on
675
73fc293b 676foreach my $Locale (@Locale) {
c4093d7d 677 $locales_test_number = $first_locales_test_number - 1;
78fbfaf5 678 debug "#\n";
284102e8 679 debug "# Locale = $Locale\n";
284102e8 680
a810e350 681 unless (setlocale(&POSIX::LC_ALL, $Locale)) {
c4093d7d 682 $setlocale_failed{$Locale} = $Locale;
284102e8 683 next;
8ebc5c01 684 }
8ebc5c01 685
31f05a37
KW
686 # We test UTF-8 locales only under ':not_characters'; It is easier to
687 # test them in other test files than here. Non- UTF-8 locales are tested
688 # only under plain 'use locale', as otherwise we would have to convert
689 # everything in them to Unicode.
66cbab2c 690
95eaa1bf
KW
691 my %UPPER = (); # All alpha X for which uc(X) == X and lc(X) != X
692 my %lower = (); # All alpha X for which lc(X) == X and uc(X) != X
693 my %BoThCaSe = (); # All alpha X for which uc(X) == lc(X) == X
66cbab2c 694
ab8b8bcc 695 my $is_utf8_locale = is_locale_utf8($Locale);
b9df08e4
KW
696
697 debug "# is utf8 locale? = $is_utf8_locale\n";
698
699 my $radix = localeconv()->{decimal_point};
700 if ($radix !~ / ^ [[:ascii:]] + $/x) {
701 use bytes;
702 $radix = disp_chars(split "", $radix);
703 }
704 debug "# radix = $radix\n";
705
66cbab2c
KW
706 if (! $is_utf8_locale) {
707 use locale;
fb844330
KW
708 @{$posixes{'word'}} = grep /\w/, map { chr } 0..255;
709 @{$posixes{'digit'}} = grep /\d/, map { chr } 0..255;
710 @{$posixes{'space'}} = grep /\s/, map { chr } 0..255;
711 @{$posixes{'alpha'}} = grep /[[:alpha:]]/, map {chr } 0..255;
712 @{$posixes{'alnum'}} = grep /[[:alnum:]]/, map {chr } 0..255;
713 @{$posixes{'ascii'}} = grep /[[:ascii:]]/, map {chr } 0..255;
714 @{$posixes{'blank'}} = grep /[[:blank:]]/, map {chr } 0..255;
715 @{$posixes{'cntrl'}} = grep /[[:cntrl:]]/, map {chr } 0..255;
716 @{$posixes{'graph'}} = grep /[[:graph:]]/, map {chr } 0..255;
717 @{$posixes{'lower'}} = grep /[[:lower:]]/, map {chr } 0..255;
718 @{$posixes{'print'}} = grep /[[:print:]]/, map {chr } 0..255;
98ed56e7 719 @{$posixes{'punct'}} = grep /[[:punct:]]/, map {chr } 0..255;
fb844330
KW
720 @{$posixes{'upper'}} = grep /[[:upper:]]/, map {chr } 0..255;
721 @{$posixes{'xdigit'}} = grep /[[:xdigit:]]/, map {chr } 0..255;
722 @{$posixes{'cased'}} = grep /[[:upper:]]/i, map {chr } 0..255;
e5272a46 723
71e5cbb3
KW
724 # Sieve the uppercase and the lowercase.
725
fb844330 726 for (@{$posixes{'word'}}) {
71e5cbb3
KW
727 if (/[^\d_]/) { # skip digits and the _
728 if (uc($_) eq $_) {
729 $UPPER{$_} = $_;
730 }
731 if (lc($_) eq $_) {
732 $lower{$_} = $_;
733 }
734 }
735 }
66cbab2c
KW
736 }
737 else {
738 use locale ':not_characters';
fb844330
KW
739 @{$posixes{'word'}} = grep /\w/, map { chr } 0..255;
740 @{$posixes{'digit'}} = grep /\d/, map { chr } 0..255;
741 @{$posixes{'space'}} = grep /\s/, map { chr } 0..255;
742 @{$posixes{'alpha'}} = grep /[[:alpha:]]/, map {chr } 0..255;
743 @{$posixes{'alnum'}} = grep /[[:alnum:]]/, map {chr } 0..255;
744 @{$posixes{'ascii'}} = grep /[[:ascii:]]/, map {chr } 0..255;
745 @{$posixes{'blank'}} = grep /[[:blank:]]/, map {chr } 0..255;
746 @{$posixes{'cntrl'}} = grep /[[:cntrl:]]/, map {chr } 0..255;
747 @{$posixes{'graph'}} = grep /[[:graph:]]/, map {chr } 0..255;
748 @{$posixes{'lower'}} = grep /[[:lower:]]/, map {chr } 0..255;
749 @{$posixes{'print'}} = grep /[[:print:]]/, map {chr } 0..255;
98ed56e7 750 @{$posixes{'punct'}} = grep /[[:punct:]]/, map {chr } 0..255;
fb844330
KW
751 @{$posixes{'upper'}} = grep /[[:upper:]]/, map {chr } 0..255;
752 @{$posixes{'xdigit'}} = grep /[[:xdigit:]]/, map {chr } 0..255;
753 @{$posixes{'cased'}} = grep /[[:upper:]]/i, map {chr } 0..255;
754 for (@{$posixes{'word'}}) {
66cbab2c
KW
755 if (/[^\d_]/) { # skip digits and the _
756 if (uc($_) eq $_) {
757 $UPPER{$_} = $_;
758 }
759 if (lc($_) eq $_) {
760 $lower{$_} = $_;
761 }
762 }
763 }
764 }
a160ac48 765
fb844330
KW
766 # Ordered, where possible, in groups of "this is a subset of the next
767 # one"
705af3af
KW
768 debug "# :upper: = ", disp_chars(@{$posixes{'upper'}}), "\n";
769 debug "# :lower: = ", disp_chars(@{$posixes{'lower'}}), "\n";
770 debug "# :cased: = ", disp_chars(@{$posixes{'cased'}}), "\n";
771 debug "# :alpha: = ", disp_chars(@{$posixes{'alpha'}}), "\n";
772 debug "# :alnum: = ", disp_chars(@{$posixes{'alnum'}}), "\n";
773 debug "# w = ", disp_chars(@{$posixes{'word'}}), "\n";
774 debug "# :graph: = ", disp_chars(@{$posixes{'graph'}}), "\n";
775 debug "# :print: = ", disp_chars(@{$posixes{'print'}}), "\n";
776 debug "# d = ", disp_chars(@{$posixes{'digit'}}), "\n";
777 debug "# :xdigit: = ", disp_chars(@{$posixes{'xdigit'}}), "\n";
778 debug "# :blank: = ", disp_chars(@{$posixes{'blank'}}), "\n";
779 debug "# s = ", disp_chars(@{$posixes{'space'}}), "\n";
780 debug "# :punct: = ", disp_chars(@{$posixes{'punct'}}), "\n";
781 debug "# :cntrl: = ", disp_chars(@{$posixes{'cntrl'}}), "\n";
782 debug "# :ascii: = ", disp_chars(@{$posixes{'ascii'}}), "\n";
a160ac48 783
284102e8 784 foreach (keys %UPPER) {
a160ac48 785
097ee67d 786 $BoThCaSe{$_}++ if exists $lower{$_};
284102e8
JH
787 }
788 foreach (keys %lower) {
097ee67d 789 $BoThCaSe{$_}++ if exists $UPPER{$_};
284102e8 790 }
097ee67d 791 foreach (keys %BoThCaSe) {
284102e8
JH
792 delete $UPPER{$_};
793 delete $lower{$_};
794 }
795
e5cc0528
KW
796 my %Unassigned;
797 foreach my $ord ( 0 .. 255 ) {
798 $Unassigned{chr $ord} = 1;
799 }
800 foreach my $class (keys %posixes) {
801 foreach my $char (@{$posixes{$class}}) {
802 delete $Unassigned{$char};
803 }
804 }
805
b9df08e4
KW
806 debug "# UPPER = ", disp_chars(sort { ord $a <=> ord $b } keys %UPPER), "\n";
807 debug "# lower = ", disp_chars(sort { ord $a <=> ord $b } keys %lower), "\n";
808 debug "# BoThCaSe = ", disp_chars(sort { ord $a <=> ord $b } keys %BoThCaSe), "\n";
705af3af 809 debug "# Unassigned = ", disp_chars(sort { ord $a <=> ord $b } keys %Unassigned), "\n";
284102e8 810
baa71cfd 811 my @failures;
3da38613 812 my @fold_failures;
b9df08e4 813 foreach my $x (sort { ord $a <=> ord $b } keys %UPPER) {
baa71cfd 814 my $ok;
3da38613 815 my $fold_ok;
baa71cfd
KW
816 if ($is_utf8_locale) {
817 use locale ':not_characters';
818 $ok = $x =~ /[[:upper:]]/;
3da38613 819 $fold_ok = $x =~ /[[:lower:]]/i;
baa71cfd
KW
820 }
821 else {
822 use locale;
823 $ok = $x =~ /[[:upper:]]/;
3da38613 824 $fold_ok = $x =~ /[[:lower:]]/i;
baa71cfd
KW
825 }
826 push @failures, $x unless $ok;
3da38613 827 push @fold_failures, $x unless $fold_ok;
baa71cfd 828 }
baa71cfd 829 $locales_test_number++;
6d5d702a 830 $first_casing_test_number = $locales_test_number;
95eaa1bf 831 $test_names{$locales_test_number} = 'Verify that /[[:upper:]]/ matches all alpha X for which uc(X) == X and lc(X) != X';
7c844d17 832 report_multi_result($Locale, $locales_test_number, \@failures);
6d5d702a 833
3da38613 834 $locales_test_number++;
6d5d702a 835
95eaa1bf 836 $test_names{$locales_test_number} = 'Verify that /[[:lower:]]/i matches all alpha X for which uc(X) == X and lc(X) != X';
7c844d17 837 report_multi_result($Locale, $locales_test_number, \@fold_failures);
baa71cfd 838
baa71cfd 839 undef @failures;
3da38613 840 undef @fold_failures;
baa71cfd 841
b9df08e4 842 foreach my $x (sort { ord $a <=> ord $b } keys %lower) {
baa71cfd 843 my $ok;
3da38613 844 my $fold_ok;
baa71cfd
KW
845 if ($is_utf8_locale) {
846 use locale ':not_characters';
847 $ok = $x =~ /[[:lower:]]/;
3da38613 848 $fold_ok = $x =~ /[[:upper:]]/i;
baa71cfd
KW
849 }
850 else {
851 use locale;
852 $ok = $x =~ /[[:lower:]]/;
3da38613 853 $fold_ok = $x =~ /[[:upper:]]/i;
baa71cfd
KW
854 }
855 push @failures, $x unless $ok;
3da38613 856 push @fold_failures, $x unless $fold_ok;
baa71cfd
KW
857 }
858
859 $locales_test_number++;
95eaa1bf 860 $test_names{$locales_test_number} = 'Verify that /[[:lower:]]/ matches all alpha X for which lc(X) == X and uc(X) != X';
7c844d17
KW
861 report_multi_result($Locale, $locales_test_number, \@failures);
862
3da38613 863 $locales_test_number++;
95eaa1bf 864 $test_names{$locales_test_number} = 'Verify that /[[:upper:]]/i matches all alpha X for which lc(X) == X and uc(X) != X';
7c844d17 865 report_multi_result($Locale, $locales_test_number, \@fold_failures);
baa71cfd 866
9445c837
KW
867 { # Find the alphabetic characters that are not considered alphabetics
868 # in the default (C) locale.
8ebc5c01 869
284102e8 870 no locale;
71e5cbb3 871
30032ef4 872 @Added_alpha = ();
5e7a1028 873 for (keys %UPPER, keys %lower, keys %BoThCaSe) {
30032ef4 874 push(@Added_alpha, $_) if (/\W/);
284102e8 875 }
8ebc5c01 876 }
8ebc5c01 877
b9df08e4 878 @Added_alpha = sort { ord $a <=> ord $b } @Added_alpha;
8ebc5c01 879
705af3af 880 debug "# Added_alpha = ", disp_chars(@Added_alpha), "\n";
8ebc5c01 881
db31898d 882 # Cross-check the whole 8-bit character set.
8ebc5c01 883
db31898d
KW
884 ++$locales_test_number;
885 my @f;
886 $test_names{$locales_test_number} = 'Verify that \w and [:word:] are identical';
887 for (map { chr } 0..255) {
888 if ($is_utf8_locale) {
889 use locale ':not_characters';
890 push @f, $_ unless /[[:word:]]/ == /\w/;
891 }
892 else {
893 push @f, $_ unless /[[:word:]]/ == /\w/;
894 }
895 }
896 report_multi_result($Locale, $locales_test_number, \@f);
8ebc5c01 897
db31898d
KW
898 ++$locales_test_number;
899 undef @f;
900 $test_names{$locales_test_number} = 'Verify that \d and [:digit:] are identical';
901 for (map { chr } 0..255) {
902 if ($is_utf8_locale) {
903 use locale ':not_characters';
904 push @f, $_ unless /[[:digit:]]/ == /\d/;
905 }
906 else {
907 push @f, $_ unless /[[:digit:]]/ == /\d/;
908 }
909 }
910 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 911
db31898d
KW
912 ++$locales_test_number;
913 undef @f;
914 $test_names{$locales_test_number} = 'Verify that \s and [:space:] are identical';
915 for (map { chr } 0..255) {
916 if ($is_utf8_locale) {
917 use locale ':not_characters';
918 push @f, $_ unless /[[:space:]]/ == /\s/;
919 }
920 else {
921 push @f, $_ unless /[[:space:]]/ == /\s/;
922 }
923 }
924 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 925
db31898d
KW
926 ++$locales_test_number;
927 undef @f;
928 $test_names{$locales_test_number} = 'Verify that [:posix:] and [:^posix:] are mutually exclusive';
929 for (map { chr } 0..255) {
930 if ($is_utf8_locale) {
931 use locale ':not_characters';
932 push @f, $_ unless (/[[:alpha:]]/ xor /[[:^alpha:]]/) ||
933 (/[[:alnum:]]/ xor /[[:^alnum:]]/) ||
934 (/[[:ascii:]]/ xor /[[:^ascii:]]/) ||
935 (/[[:blank:]]/ xor /[[:^blank:]]/) ||
936 (/[[:cntrl:]]/ xor /[[:^cntrl:]]/) ||
937 (/[[:digit:]]/ xor /[[:^digit:]]/) ||
938 (/[[:graph:]]/ xor /[[:^graph:]]/) ||
939 (/[[:lower:]]/ xor /[[:^lower:]]/) ||
940 (/[[:print:]]/ xor /[[:^print:]]/) ||
941 (/[[:space:]]/ xor /[[:^space:]]/) ||
942 (/[[:upper:]]/ xor /[[:^upper:]]/) ||
943 (/[[:word:]]/ xor /[[:^word:]]/) ||
944 (/[[:xdigit:]]/ xor /[[:^xdigit:]]/) ||
945
946 # effectively is what [:cased:] would be if it existed.
947 (/[[:upper:]]/i xor /[[:^upper:]]/i);
948 }
949 else {
950 push @f, $_ unless (/[[:alpha:]]/ xor /[[:^alpha:]]/) ||
951 (/[[:alnum:]]/ xor /[[:^alnum:]]/) ||
952 (/[[:ascii:]]/ xor /[[:^ascii:]]/) ||
953 (/[[:blank:]]/ xor /[[:^blank:]]/) ||
954 (/[[:cntrl:]]/ xor /[[:^cntrl:]]/) ||
955 (/[[:digit:]]/ xor /[[:^digit:]]/) ||
956 (/[[:graph:]]/ xor /[[:^graph:]]/) ||
957 (/[[:lower:]]/ xor /[[:^lower:]]/) ||
958 (/[[:print:]]/ xor /[[:^print:]]/) ||
959 (/[[:space:]]/ xor /[[:^space:]]/) ||
960 (/[[:upper:]]/ xor /[[:^upper:]]/) ||
961 (/[[:word:]]/ xor /[[:^word:]]/) ||
962 (/[[:xdigit:]]/ xor /[[:^xdigit:]]/) ||
963 (/[[:upper:]]/i xor /[[:^upper:]]/i);
964 }
965 }
966 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 967
db31898d
KW
968 # The rules for the relationships are given in:
969 # http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html
32e8aa3f 970
660c7bcc
KW
971
972 ++$locales_test_number;
973 undef @f;
974 $test_names{$locales_test_number} = 'Verify that [:lower:] contains at least a-z';
975 for ('a' .. 'z') {
976 if ($is_utf8_locale) {
977 use locale ':not_characters';
978 push @f, $_ unless /[[:lower:]]/;
979 }
980 else {
981 push @f, $_ unless /[[:lower:]]/;
982 }
983 }
984 report_multi_result($Locale, $locales_test_number, \@f);
985
db31898d
KW
986 ++$locales_test_number;
987 undef @f;
988 $test_names{$locales_test_number} = 'Verify that [:lower:] is a subset of [:alpha:]';
989 for (map { chr } 0..255) {
990 if ($is_utf8_locale) {
991 use locale ':not_characters';
992 push @f, $_ if /[[:lower:]]/ and ! /[[:alpha:]]/;
993 }
994 else {
995 push @f, $_ if /[[:lower:]]/ and ! /[[:alpha:]]/;
996 }
997 }
998 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 999
db31898d
KW
1000 ++$locales_test_number;
1001 undef @f;
660c7bcc
KW
1002 $test_names{$locales_test_number} = 'Verify that [:upper:] contains at least A-Z';
1003 for ('A' .. 'Z') {
1004 if ($is_utf8_locale) {
1005 use locale ':not_characters';
1006 push @f, $_ unless /[[:upper:]]/;
1007 }
1008 else {
1009 push @f, $_ unless /[[:upper:]]/;
1010 }
1011 }
1012 report_multi_result($Locale, $locales_test_number, \@f);
1013
1014 ++$locales_test_number;
1015 undef @f;
db31898d
KW
1016 $test_names{$locales_test_number} = 'Verify that [:upper:] is a subset of [:alpha:]';
1017 for (map { chr } 0..255) {
1018 if ($is_utf8_locale) {
1019 use locale ':not_characters';
1020 push @f, $_ if /[[:upper:]]/ and ! /[[:alpha:]]/;
1021 }
1022 else {
1023 push @f, $_ if /[[:upper:]]/ and ! /[[:alpha:]]/;
1024 }
1025 }
1026 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1027
db31898d
KW
1028 ++$locales_test_number;
1029 undef @f;
1030 $test_names{$locales_test_number} = 'Verify that /[[:lower:]]/i is a subset of [:alpha:]';
1031 for (map { chr } 0..255) {
1032 if ($is_utf8_locale) {
1033 use locale ':not_characters';
1034 push @f, $_ if /[[:lower:]]/i and ! /[[:alpha:]]/;
1035 }
1036 else {
1037 push @f, $_ if /[[:lower:]]/i and ! /[[:alpha:]]/;
1038 }
1039 }
1040 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1041
db31898d
KW
1042 ++$locales_test_number;
1043 undef @f;
1044 $test_names{$locales_test_number} = 'Verify that [:alpha:] is a subset of [:alnum:]';
1045 for (map { chr } 0..255) {
1046 if ($is_utf8_locale) {
1047 use locale ':not_characters';
1048 push @f, $_ if /[[:alpha:]]/ and ! /[[:alnum:]]/;
1049 }
1050 else {
1051 push @f, $_ if /[[:alpha:]]/ and ! /[[:alnum:]]/;
1052 }
1053 }
1054 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1055
db31898d
KW
1056 ++$locales_test_number;
1057 undef @f;
660c7bcc
KW
1058 $test_names{$locales_test_number} = 'Verify that [:digit:] contains at least 0-9';
1059 for ('0' .. '9') {
1060 if ($is_utf8_locale) {
1061 use locale ':not_characters';
1062 push @f, $_ unless /[[:digit:]]/;
1063 }
1064 else {
1065 push @f, $_ unless /[[:digit:]]/;
1066 }
1067 }
1068 report_multi_result($Locale, $locales_test_number, \@f);
1069
1070 ++$locales_test_number;
1071 undef @f;
db31898d
KW
1072 $test_names{$locales_test_number} = 'Verify that [:digit:] is a subset of [:alnum:]';
1073 for (map { chr } 0..255) {
1074 if ($is_utf8_locale) {
1075 use locale ':not_characters';
1076 push @f, $_ if /[[:digit:]]/ and ! /[[:alnum:]]/;
1077 }
1078 else {
1079 push @f, $_ if /[[:digit:]]/ and ! /[[:alnum:]]/;
1080 }
1081 }
1082 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1083
db31898d
KW
1084 ++$locales_test_number;
1085 undef @f;
aac995d2 1086 $test_names{$locales_test_number} = 'Verify that [:digit:] matches either 10 or 20 code points';
fb844330 1087 report_result($Locale, $locales_test_number, @{$posixes{'digit'}} == 10 || @{$posixes{'digit'}} == 20);
aac995d2
KW
1088
1089 ++$locales_test_number;
1090 undef @f;
660c7bcc
KW
1091 $test_names{$locales_test_number} = 'Verify that if there is a second set of digits in [:digit:], they are consecutive';
1092 if (@{$posixes{'digit'}} == 20) {
1093 my $previous_ord;
fc81f5f2 1094 for (map { chr } 0..255) {
660c7bcc
KW
1095 next unless /[[:digit:]]/;
1096 next if /[0-9]/;
1097 if (defined $previous_ord) {
1098 if ($is_utf8_locale) {
1099 use locale ':not_characters';
1100 push @f, $_ if ord $_ != $previous_ord + 1;
1101 }
1102 else {
1103 push @f, $_ if ord $_ != $previous_ord + 1;
1104 }
fc81f5f2 1105 }
660c7bcc 1106 $previous_ord = ord $_;
db31898d
KW
1107 }
1108 }
1109 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1110
db31898d
KW
1111 ++$locales_test_number;
1112 undef @f;
d458c02c
KW
1113 my @xdigit_digits; # :digit: & :xdigit:
1114 $test_names{$locales_test_number} = 'Verify that [:xdigit:] contains one or two blocks of 10 consecutive [:digit:] chars';
db31898d
KW
1115 for (map { chr } 0..255) {
1116 if ($is_utf8_locale) {
1117 use locale ':not_characters';
d458c02c
KW
1118 # For utf8 locales, we actually use a stricter test: that :digit:
1119 # is a subset of :xdigit:, as we know that only 0-9 should match
1120 push @f, $_ if /[[:digit:]]/ and ! /[[:xdigit:]]/;
db31898d
KW
1121 }
1122 else {
d458c02c 1123 push @xdigit_digits, $_ if /[[:digit:]]/ and /[[:xdigit:]]/;
db31898d
KW
1124 }
1125 }
d458c02c
KW
1126 if (! $is_utf8_locale) {
1127
1128 # For non-utf8 locales, @xdigit_digits is a list of the characters
1129 # that are both :xdigit: and :digit:. Because :digit: is stored in
1130 # increasing code point order (unless the tests above failed),
1131 # @xdigit_digits is as well. There should be exactly 10 or
1132 # 20 of these.
1133 if (@xdigit_digits != 10 && @xdigit_digits != 20) {
1134 @f = @xdigit_digits;
1135 }
1136 else {
1137
1138 # Look for contiguity in the series, adding any wrong ones to @f
1139 my @temp = @xdigit_digits;
1140 while (@temp > 1) {
1141 push @f, $temp[1] if ($temp[0] != $temp[1] - 1)
1142
1143 # Skip this test for the 0th character of
1144 # the second block of 10, as it won't be
1145 # contiguous with the previous block
1146 && (! defined $xdigit_digits[10]
1147 || $temp[1] != $xdigit_digits[10]);
1148 shift @temp;
1149 }
1150 }
1151 }
1152
db31898d 1153 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1154
660c7bcc
KW
1155 ++$locales_test_number;
1156 undef @f;
1157 $test_names{$locales_test_number} = 'Verify that [:xdigit:] contains at least A-F, a-f';
1158 for ('A' .. 'F', 'a' .. 'f') {
1159 if ($is_utf8_locale) {
1160 use locale ':not_characters';
1161 push @f, $_ unless /[[:xdigit:]]/;
1162 }
1163 else {
1164 push @f, $_ unless /[[:xdigit:]]/;
1165 }
1166 }
1167 report_multi_result($Locale, $locales_test_number, \@f);
1168
1169 ++$locales_test_number;
1170 undef @f;
1171 $test_names{$locales_test_number} = 'Verify that any additional members of [:xdigit:], are in groups of 6 consecutive code points';
1172 my $previous_ord;
1173 my $count = 0;
d458c02c
KW
1174 for my $chr (map { chr } 0..255) {
1175 next unless $chr =~ /[[:xdigit:]]/;
1176 if ($is_utf8_locale) {
1177 next if $chr =~ /[[:digit:]]/;
1178 }
1179 else {
1180 next if grep { $chr eq $_ } @xdigit_digits;
1181 }
1182 next if $chr =~ /[A-Fa-f]/;
660c7bcc
KW
1183 if (defined $previous_ord) {
1184 if ($is_utf8_locale) {
1185 use locale ':not_characters';
d458c02c 1186 push @f, $chr if ord $chr != $previous_ord + 1;
660c7bcc
KW
1187 }
1188 else {
d458c02c 1189 push @f, $chr if ord $chr != $previous_ord + 1;
660c7bcc
KW
1190 }
1191 }
1192 $count++;
1193 if ($count == 6) {
1194 undef $previous_ord;
1195 }
1196 else {
d458c02c 1197 $previous_ord = ord $chr;
660c7bcc
KW
1198 }
1199 }
1200 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1201
db31898d
KW
1202 ++$locales_test_number;
1203 undef @f;
1204 $test_names{$locales_test_number} = 'Verify that [:xdigit:] is a subset of [:graph:]';
1205 for (map { chr } 0..255) {
1206 if ($is_utf8_locale) {
1207 use locale ':not_characters';
1208 push @f, $_ if /[[:xdigit:]]/ and ! /[[:graph:]]/;
1209 }
1210 else {
1211 push @f, $_ if /[[:xdigit:]]/ and ! /[[:graph:]]/;
1212 }
1213 }
1214 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1215
660c7bcc
KW
1216 # Note that xdigit doesn't have to be a subset of alnum
1217
db31898d
KW
1218 ++$locales_test_number;
1219 undef @f;
1220 $test_names{$locales_test_number} = 'Verify that [:punct:] is a subset of [:graph:]';
1221 for (map { chr } 0..255) {
1222 if ($is_utf8_locale) {
1223 use locale ':not_characters';
1224 push @f, $_ if /[[:punct:]]/ and ! /[[:graph:]]/;
1225 }
1226 else {
1227 push @f, $_ if /[[:punct:]]/ and ! /[[:graph:]]/;
1228 }
1229 }
1230 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1231
db31898d
KW
1232 ++$locales_test_number;
1233 undef @f;
660c7bcc
KW
1234 $test_names{$locales_test_number} = 'Verify that the space character is not in [:graph:]';
1235 if ($is_utf8_locale) {
1236 use locale ':not_characters';
1237 push @f, " " if " " =~ /[[:graph:]]/;
1238 }
1239 else {
1240 push @f, " " if " " =~ /[[:graph:]]/;
1241 }
1242 report_multi_result($Locale, $locales_test_number, \@f);
1243
1244 ++$locales_test_number;
1245 undef @f;
1246 $test_names{$locales_test_number} = 'Verify that [:space:] contains at least [\f\n\r\t\cK ]';
1247 for (' ', "\f", "\n", "\r", "\t", "\cK") {
1248 if ($is_utf8_locale) {
1249 use locale ':not_characters';
1250 push @f, $_ unless /[[:space:]]/;
1251 }
1252 else {
1253 push @f, $_ unless /[[:space:]]/;
1254 }
1255 }
1256 report_multi_result($Locale, $locales_test_number, \@f);
1257
1258 ++$locales_test_number;
1259 undef @f;
1260 $test_names{$locales_test_number} = 'Verify that [:blank:] contains at least [\t ]';
1261 for (' ', "\t") {
1262 if ($is_utf8_locale) {
1263 use locale ':not_characters';
1264 push @f, $_ unless /[[:blank:]]/;
1265 }
1266 else {
1267 push @f, $_ unless /[[:blank:]]/;
1268 }
1269 }
1270 report_multi_result($Locale, $locales_test_number, \@f);
1271
1272 ++$locales_test_number;
1273 undef @f;
db31898d
KW
1274 $test_names{$locales_test_number} = 'Verify that [:blank:] is a subset of [:space:]';
1275 for (map { chr } 0..255) {
1276 if ($is_utf8_locale) {
1277 use locale ':not_characters';
1278 push @f, $_ if /[[:blank:]]/ and ! /[[:space:]]/;
1279 }
1280 else {
1281 push @f, $_ if /[[:blank:]]/ and ! /[[:space:]]/;
1282 }
1283 }
1284 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1285
db31898d
KW
1286 ++$locales_test_number;
1287 undef @f;
1288 $test_names{$locales_test_number} = 'Verify that [:graph:] is a subset of [:print:]';
1289 for (map { chr } 0..255) {
1290 if ($is_utf8_locale) {
1291 use locale ':not_characters';
1292 push @f, $_ if /[[:graph:]]/ and ! /[[:print:]]/;
1293 }
1294 else {
1295 push @f, $_ if /[[:graph:]]/ and ! /[[:print:]]/;
1296 }
1297 }
1298 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1299
db31898d
KW
1300 ++$locales_test_number;
1301 undef @f;
660c7bcc
KW
1302 $test_names{$locales_test_number} = 'Verify that the space character is in [:print:]';
1303 if ($is_utf8_locale) {
1304 use locale ':not_characters';
1305 push @f, " " if " " !~ /[[:print:]]/;
1306 }
1307 else {
1308 push @f, " " if " " !~ /[[:print:]]/;
1309 }
1310 report_multi_result($Locale, $locales_test_number, \@f);
1311
1312 ++$locales_test_number;
1313 undef @f;
db31898d
KW
1314 $test_names{$locales_test_number} = 'Verify that isn\'t both [:cntrl:] and [:print:]';
1315 for (map { chr } 0..255) {
1316 if ($is_utf8_locale) {
1317 use locale ':not_characters';
1318 push @f, $_ if (/[[:print:]]/ and /[[:cntrl:]]/);
1319 }
1320 else {
1321 push @f, $_ if (/[[:print:]]/ and /[[:cntrl:]]/);
1322 }
1323 }
1324 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1325
db31898d
KW
1326 ++$locales_test_number;
1327 undef @f;
660c7bcc
KW
1328 $test_names{$locales_test_number} = 'Verify that isn\'t both [:alpha:] and [:digit:]';
1329 for (map { chr } 0..255) {
1330 if ($is_utf8_locale) {
1331 use locale ':not_characters';
1332 push @f, $_ if /[[:alpha:]]/ and /[[:digit:]]/;
1333 }
1334 else {
1335 push @f, $_ if /[[:alpha:]]/ and /[[:digit:]]/;
1336 }
1337 }
1338 report_multi_result($Locale, $locales_test_number, \@f);
1339
1340 ++$locales_test_number;
1341 undef @f;
db31898d
KW
1342 $test_names{$locales_test_number} = 'Verify that isn\'t both [:alnum:] and [:punct:]';
1343 for (map { chr } 0..255) {
1344 if ($is_utf8_locale) {
1345 use locale ':not_characters';
1346 push @f, $_ if /[[:alnum:]]/ and /[[:punct:]]/;
1347 }
1348 else {
1349 push @f, $_ if /[[:alnum:]]/ and /[[:punct:]]/;
1350 }
1351 }
1352 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1353
db31898d
KW
1354 ++$locales_test_number;
1355 undef @f;
1356 $test_names{$locales_test_number} = 'Verify that isn\'t both [:xdigit:] and [:punct:]';
1357 for (map { chr } 0..255) {
1358 if ($is_utf8_locale) {
1359 use locale ':not_characters';
1360 push @f, $_ if (/[[:punct:]]/ and /[[:xdigit:]]/);
1361 }
1362 else {
1363 push @f, $_ if (/[[:punct:]]/ and /[[:xdigit:]]/);
1364 }
1365 }
1366 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1367
db31898d
KW
1368 ++$locales_test_number;
1369 undef @f;
1370 $test_names{$locales_test_number} = 'Verify that isn\'t both [:graph:] and [:space:]';
1371 for (map { chr } 0..255) {
1372 if ($is_utf8_locale) {
1373 use locale ':not_characters';
1374 push @f, $_ if (/[[:graph:]]/ and /[[:space:]]/);
1375 }
1376 else {
1377 push @f, $_ if (/[[:graph:]]/ and /[[:space:]]/);
1378 }
1379 }
1380 report_multi_result($Locale, $locales_test_number, \@f);
32e8aa3f 1381
7493b8f2 1382 foreach ($first_casing_test_number..$locales_test_number) {
5b1f18a7 1383 $problematical_tests{$_} = 1;
7493b8f2
KW
1384 }
1385
32e8aa3f 1386
db31898d
KW
1387 # Test for read-only scalars' locale vs non-locale comparisons.
1388
1389 {
1390 no locale;
1391 my $ok;
1392 $a = "qwerty";
1393 if ($is_utf8_locale) {
1394 use locale ':not_characters';
1395 $ok = ($a cmp "qwerty") == 0;
1396 }
1397 else {
1398 use locale;
1399 $ok = ($a cmp "qwerty") == 0;
1400 }
1401 report_result($Locale, ++$locales_test_number, $ok);
1402 $test_names{$locales_test_number} = 'Verify that cmp works with a read-only scalar; no- vs locale';
1403 }
8ebc5c01 1404
db31898d
KW
1405 {
1406 my ($from, $to, $lesser, $greater,
1407 @test, %test, $test, $yes, $no, $sign);
284102e8 1408
db31898d
KW
1409 ++$locales_test_number;
1410 $test_names{$locales_test_number} = 'Verify that "le", "ne", etc work';
1411 $not_necessarily_a_problem_test_number = $locales_test_number;
1412 for (0..9) {
1413 # Select a slice.
fb844330
KW
1414 $from = int(($_*@{$posixes{'word'}})/10);
1415 $to = $from + int(@{$posixes{'word'}}/10);
1416 $to = $#{$posixes{'word'}} if ($to > $#{$posixes{'word'}});
1417 $lesser = join('', @{$posixes{'word'}}[$from..$to]);
db31898d
KW
1418 # Select a slice one character on.
1419 $from++; $to++;
fb844330
KW
1420 $to = $#{$posixes{'word'}} if ($to > $#{$posixes{'word'}});
1421 $greater = join('', @{$posixes{'word'}}[$from..$to]);
66cbab2c
KW
1422 if ($is_utf8_locale) {
1423 use locale ':not_characters';
db31898d
KW
1424 ($yes, $no, $sign) = ($lesser lt $greater
1425 ? (" ", "not ", 1)
1426 : ("not ", " ", -1));
66cbab2c
KW
1427 }
1428 else {
1429 use locale;
db31898d
KW
1430 ($yes, $no, $sign) = ($lesser lt $greater
1431 ? (" ", "not ", 1)
1432 : ("not ", " ", -1));
66cbab2c 1433 }
db31898d
KW
1434 # all these tests should FAIL (return 0). Exact lt or gt cannot
1435 # be tested because in some locales, say, eacute and E may test
1436 # equal.
1437 @test =
1438 (
1439 $no.' ($lesser le $greater)', # 1
1440 'not ($lesser ne $greater)', # 2
1441 ' ($lesser eq $greater)', # 3
1442 $yes.' ($lesser ge $greater)', # 4
1443 $yes.' ($lesser ge $greater)', # 5
1444 $yes.' ($greater le $lesser )', # 7
1445 'not ($greater ne $lesser )', # 8
1446 ' ($greater eq $lesser )', # 9
1447 $no.' ($greater ge $lesser )', # 10
1448 'not (($lesser cmp $greater) == -($sign))' # 11
1449 );
1450 @test{@test} = 0 x @test;
1451 $test = 0;
1452 for my $ti (@test) {
66cbab2c
KW
1453 if ($is_utf8_locale) {
1454 use locale ':not_characters';
db31898d 1455 $test{$ti} = eval $ti;
66cbab2c
KW
1456 }
1457 else {
db31898d
KW
1458 # Already in 'use locale';
1459 $test{$ti} = eval $ti;
66cbab2c 1460 }
db31898d
KW
1461 $test ||= $test{$ti}
1462 }
1463 report_result($Locale, $locales_test_number, $test == 0);
1464 if ($test) {
1465 debug "# lesser = '$lesser'\n";
1466 debug "# greater = '$greater'\n";
1467 debug "# lesser cmp greater = ",
1468 $lesser cmp $greater, "\n";
1469 debug "# greater cmp lesser = ",
1470 $greater cmp $lesser, "\n";
1471 debug "# (greater) from = $from, to = $to\n";
1472 for my $ti (@test) {
1473 debugf("# %-40s %-4s", $ti,
1474 $test{$ti} ? 'FAIL' : 'ok');
1475 if ($ti =~ /\(\.*(\$.+ +cmp +\$[^\)]+)\.*\)/) {
1476 debugf("(%s == %4d)", $1, eval $1);
66cbab2c 1477 }
db31898d
KW
1478 debug "\n#";
1479 }
1480
1481 last;
1482 }
1483 }
1484 }
c4093d7d 1485
66cbab2c
KW
1486 my $ok1;
1487 my $ok2;
1488 my $ok3;
1489 my $ok4;
1490 my $ok5;
1491 my $ok6;
1492 my $ok7;
1493 my $ok8;
1494 my $ok9;
1495 my $ok10;
1496 my $ok11;
1497 my $ok12;
1498 my $ok13;
1500bd91 1499 my $ok14;
28acfe03
KW
1500 my $ok15;
1501 my $ok16;
e46375fa
KW
1502 my $ok17;
1503 my $ok18;
66cbab2c
KW
1504
1505 my $c;
1506 my $d;
1507 my $e;
1508 my $f;
1509 my $g;
e46375fa
KW
1510 my $h;
1511 my $i;
1512 my $j;
66cbab2c
KW
1513
1514 if (! $is_utf8_locale) {
71e5cbb3 1515 use locale;
6be75cd7 1516
71e5cbb3 1517 my ($x, $y) = (1.23, 1.23);
6be75cd7 1518
71e5cbb3
KW
1519 $a = "$x";
1520 printf ''; # printf used to reset locale to "C"
1521 $b = "$y";
1522 $ok1 = $a eq $b;
6be75cd7 1523
71e5cbb3
KW
1524 $c = "$x";
1525 my $z = sprintf ''; # sprintf used to reset locale to "C"
1526 $d = "$y";
1527 $ok2 = $c eq $d;
1528 {
66cbab2c 1529
71e5cbb3
KW
1530 use warnings;
1531 my $w = 0;
1532 local $SIG{__WARN__} =
1533 sub {
1534 print "# @_\n";
1535 $w++;
1536 };
6be75cd7 1537
71e5cbb3
KW
1538 # The == (among other ops) used to warn for locales
1539 # that had something else than "." as the radix character.
6be75cd7 1540
71e5cbb3
KW
1541 $ok3 = $c == 1.23;
1542 $ok4 = $c == $x;
1543 $ok5 = $c == $d;
1544 {
1545 no locale;
66cbab2c 1546
b79536ea 1547 $e = "$x";
71e5cbb3
KW
1548
1549 $ok6 = $e == 1.23;
1550 $ok7 = $e == $x;
1551 $ok8 = $e == $c;
1552 }
66cbab2c 1553
71e5cbb3
KW
1554 $f = "1.23";
1555 $g = 2.34;
e46375fa
KW
1556 $h = 1.5;
1557 $i = 1.25;
1558 $j = "$h:$i";
66cbab2c 1559
71e5cbb3
KW
1560 $ok9 = $f == 1.23;
1561 $ok10 = $f == $x;
1562 $ok11 = $f == $c;
1563 $ok12 = abs(($f + $g) - 3.57) < 0.01;
1564 $ok13 = $w == 0;
28acfe03 1565 $ok14 = $ok15 = $ok16 = 1; # Skip for non-utf8 locales
71e5cbb3 1566 }
e46375fa
KW
1567 {
1568 no locale;
1569 $ok17 = "1.5:1.25" eq sprintf("%g:%g", $h, $i);
1570 }
1571 $ok18 = $j eq sprintf("%g:%g", $h, $i);
66cbab2c
KW
1572 }
1573 else {
1574 use locale ':not_characters';
1575
1576 my ($x, $y) = (1.23, 1.23);
1577 $a = "$x";
1578 printf ''; # printf used to reset locale to "C"
1579 $b = "$y";
1580 $ok1 = $a eq $b;
1581
1582 $c = "$x";
1583 my $z = sprintf ''; # sprintf used to reset locale to "C"
1584 $d = "$y";
1585 $ok2 = $c eq $d;
1586 {
1587 use warnings;
1588 my $w = 0;
1589 local $SIG{__WARN__} =
1590 sub {
1591 print "# @_\n";
1592 $w++;
1593 };
1594 $ok3 = $c == 1.23;
1595 $ok4 = $c == $x;
1596 $ok5 = $c == $d;
1597 {
1598 no locale;
b79536ea 1599 $e = "$x";
66cbab2c
KW
1600
1601 $ok6 = $e == 1.23;
1602 $ok7 = $e == $x;
1603 $ok8 = $e == $c;
1604 }
1605
1606 $f = "1.23";
1607 $g = 2.34;
e46375fa
KW
1608 $h = 1.5;
1609 $i = 1.25;
1610 $j = "$h:$i";
66cbab2c
KW
1611
1612 $ok9 = $f == 1.23;
1613 $ok10 = $f == $x;
1614 $ok11 = $f == $c;
1615 $ok12 = abs(($f + $g) - 3.57) < 0.01;
1616 $ok13 = $w == 0;
1500bd91
KW
1617
1618 # Look for non-ASCII error messages, and verify that the first
b17e32ea
KW
1619 # such is NOT in UTF-8 (the others almost certainly will be like
1620 # the first) See [perl #119499].
1500bd91
KW
1621 $ok14 = 1;
1622 foreach my $err (keys %!) {
1623 use Errno;
1624 $! = eval "&Errno::$err"; # Convert to strerror() output
1625 my $strerror = "$!";
1626 if ("$strerror" =~ /\P{ASCII}/) {
b17e32ea 1627 $ok14 = ! utf8::is_utf8($strerror);
1500bd91
KW
1628 last;
1629 }
1630 }
28acfe03
KW
1631
1632 # Similarly, we verify that a non-ASCII radix is in UTF-8. This
1633 # also catches if there is a disparity between sprintf and
1634 # stringification.
1635
1636 my $string_g = "$g";
2ef12107 1637 my $sprintf_g = sprintf("%g", $g);
28acfe03 1638
2ef12107
KW
1639 $ok15 = $string_g =~ / ^ \p{ASCII}+ $ /x || utf8::is_utf8($string_g);
1640 $ok16 = $sprintf_g eq $string_g;
66cbab2c 1641 }
e46375fa
KW
1642 {
1643 no locale;
1644 $ok17 = "1.5:1.25" eq sprintf("%g:%g", $h, $i);
1645 }
1646 $ok18 = $j eq sprintf("%g:%g", $h, $i);
66cbab2c
KW
1647 }
1648
30032ef4 1649 report_result($Locale, ++$locales_test_number, $ok1);
66cbab2c
KW
1650 $test_names{$locales_test_number} = 'Verify that an intervening printf doesn\'t change assignment results';
1651 my $first_a_test = $locales_test_number;
1652
1653 debug "# $first_a_test..$locales_test_number: \$a = $a, \$b = $b, Locale = $Locale\n";
1654
30032ef4 1655 report_result($Locale, ++$locales_test_number, $ok2);
66cbab2c
KW
1656 $test_names{$locales_test_number} = 'Verify that an intervening sprintf doesn\'t change assignment results';
1657
1658 my $first_c_test = $locales_test_number;
1659
30032ef4 1660 report_result($Locale, ++$locales_test_number, $ok3);
71e5cbb3 1661 $test_names{$locales_test_number} = 'Verify that a different locale radix works when doing "==" with a constant';
b057411d 1662 $problematical_tests{$locales_test_number} = 1;
6be75cd7 1663
30032ef4 1664 report_result($Locale, ++$locales_test_number, $ok4);
71e5cbb3 1665 $test_names{$locales_test_number} = 'Verify that a different locale radix works when doing "==" with a scalar';
b057411d 1666 $problematical_tests{$locales_test_number} = 1;
66cbab2c 1667
30032ef4 1668 report_result($Locale, ++$locales_test_number, $ok5);
71e5cbb3 1669 $test_names{$locales_test_number} = 'Verify that a different locale radix works when doing "==" with a scalar and an intervening sprintf';
b057411d 1670 $problematical_tests{$locales_test_number} = 1;
66cbab2c 1671
71e5cbb3 1672 debug "# $first_c_test..$locales_test_number: \$c = $c, \$d = $d, Locale = $Locale\n";
66cbab2c 1673
30032ef4 1674 report_result($Locale, ++$locales_test_number, $ok6);
b79536ea 1675 $test_names{$locales_test_number} = 'Verify that can assign stringified under inner no-locale block';
71e5cbb3 1676 my $first_e_test = $locales_test_number;
6be75cd7 1677
30032ef4 1678 report_result($Locale, ++$locales_test_number, $ok7);
71e5cbb3 1679 $test_names{$locales_test_number} = 'Verify that "==" with a scalar still works in inner no locale';
66cbab2c 1680
30032ef4 1681 report_result($Locale, ++$locales_test_number, $ok8);
71e5cbb3 1682 $test_names{$locales_test_number} = 'Verify that "==" with a scalar and an intervening sprintf still works in inner no locale';
b057411d 1683 $problematical_tests{$locales_test_number} = 1;
c4093d7d 1684
71e5cbb3 1685 debug "# $first_e_test..$locales_test_number: \$e = $e, no locale\n";
2a680da6 1686
30032ef4 1687 report_result($Locale, ++$locales_test_number, $ok9);
71e5cbb3 1688 $test_names{$locales_test_number} = 'Verify that after a no-locale block, a different locale radix still works when doing "==" with a constant';
b057411d 1689 $problematical_tests{$locales_test_number} = 1;
71e5cbb3 1690 my $first_f_test = $locales_test_number;
6be75cd7 1691
30032ef4 1692 report_result($Locale, ++$locales_test_number, $ok10);
71e5cbb3 1693 $test_names{$locales_test_number} = 'Verify that after a no-locale block, a different locale radix still works when doing "==" with a scalar';
b057411d 1694 $problematical_tests{$locales_test_number} = 1;
66cbab2c 1695
30032ef4 1696 report_result($Locale, ++$locales_test_number, $ok11);
71e5cbb3 1697 $test_names{$locales_test_number} = 'Verify that after a no-locale block, a different locale radix still works when doing "==" with a scalar and an intervening sprintf';
b057411d 1698 $problematical_tests{$locales_test_number} = 1;
906f284f 1699
30032ef4 1700 report_result($Locale, ++$locales_test_number, $ok12);
71e5cbb3 1701 $test_names{$locales_test_number} = 'Verify that after a no-locale block, a different locale radix can participate in an addition and function call as numeric';
b057411d 1702 $problematical_tests{$locales_test_number} = 1;
c4093d7d 1703
30032ef4 1704 report_result($Locale, ++$locales_test_number, $ok13);
71e5cbb3 1705 $test_names{$locales_test_number} = 'Verify that don\'t get warning under "==" even if radix is not a dot';
b057411d 1706 $problematical_tests{$locales_test_number} = 1;
c4093d7d 1707
30032ef4 1708 report_result($Locale, ++$locales_test_number, $ok14);
b17e32ea 1709 $test_names{$locales_test_number} = 'Verify that non-ASCII UTF-8 error messages are NOT in UTF-8';
1500bd91 1710
30032ef4 1711 report_result($Locale, ++$locales_test_number, $ok15);
28acfe03
KW
1712 $test_names{$locales_test_number} = 'Verify that a number with a UTF-8 radix has a UTF-8 stringification';
1713
30032ef4 1714 report_result($Locale, ++$locales_test_number, $ok16);
28acfe03
KW
1715 $test_names{$locales_test_number} = 'Verify that a sprintf of a number with a UTF-8 radix yields UTF-8';
1716
e46375fa
KW
1717 report_result($Locale, ++$locales_test_number, $ok17);
1718 $test_names{$locales_test_number} = 'Verify that a sprintf of a number outside locale scope uses a dot radix';
1719
1720 report_result($Locale, ++$locales_test_number, $ok18);
1721 $test_names{$locales_test_number} = 'Verify that a sprintf of a number back within locale scope uses locale radix';
1722
71e5cbb3 1723 debug "# $first_f_test..$locales_test_number: \$f = $f, \$g = $g, back to locale = $Locale\n";
906f284f 1724
26d80d95
LC
1725 # Does taking lc separately differ from taking
1726 # the lc "in-line"? (This was the bug 19990704.002, change #3568.)
1727 # The bug was in the caching of the 'o'-magic.
66cbab2c 1728 if (! $is_utf8_locale) {
2a680da6 1729 use locale;
6be75cd7 1730
2a680da6
JH
1731 sub lcA {
1732 my $lc0 = lc $_[0];
1733 my $lc1 = lc $_[1];
1734 return $lc0 cmp $lc1;
1735 }
6be75cd7 1736
2a680da6
JH
1737 sub lcB {
1738 return lc($_[0]) cmp lc($_[1]);
1739 }
6be75cd7 1740
2a680da6
JH
1741 my $x = "ab";
1742 my $y = "aa";
1743 my $z = "AB";
6be75cd7 1744
30032ef4 1745 report_result($Locale, ++$locales_test_number,
2a680da6
JH
1746 lcA($x, $y) == 1 && lcB($x, $y) == 1 ||
1747 lcA($x, $z) == 0 && lcB($x, $z) == 0);
6be75cd7 1748 }
66cbab2c
KW
1749 else {
1750 use locale ':not_characters';
1751
1752 sub lcC {
1753 my $lc0 = lc $_[0];
1754 my $lc1 = lc $_[1];
1755 return $lc0 cmp $lc1;
1756 }
1757
1758 sub lcD {
1759 return lc($_[0]) cmp lc($_[1]);
1760 }
1761
1762 my $x = "ab";
1763 my $y = "aa";
1764 my $z = "AB";
1765
30032ef4 1766 report_result($Locale, ++$locales_test_number,
66cbab2c
KW
1767 lcC($x, $y) == 1 && lcD($x, $y) == 1 ||
1768 lcC($x, $z) == 0 && lcD($x, $z) == 0);
1769 }
1770 $test_names{$locales_test_number} = 'Verify "lc(foo) cmp lc(bar)" is the same as using intermediaries for the cmp';
d8093b23 1771
26d80d95
LC
1772 # Does lc of an UPPER (if different from the UPPER) match
1773 # case-insensitively the UPPER, and does the UPPER match
1774 # case-insensitively the lc of the UPPER. And vice versa.
3ba0e062 1775 {
ef4a39e5
JH
1776 use locale;
1777 no utf8;
1778 my $re = qr/[\[\(\{\*\+\?\|\^\$\\]/;
1779
1780 my @f = ();
c4093d7d 1781 ++$locales_test_number;
c08acc4c 1782 $test_names{$locales_test_number} = 'Verify case insensitive matching works';
b9df08e4 1783 foreach my $x (sort { ord $a <=> ord $b } keys %UPPER) {
66cbab2c 1784 if (! $is_utf8_locale) {
71e5cbb3
KW
1785 my $y = lc $x;
1786 next unless uc $y eq $x;
92891c66
KW
1787 debug_more( "# UPPER=", disp_chars(($x)),
1788 "; lc=", disp_chars(($y)), "; ",
4eac893c 1789 "; fc=", disp_chars((fc $x)), "; ",
92891c66
KW
1790 disp_chars(($x)), "=~/", disp_chars(($y)), "/i=",
1791 $x =~ /$y/i ? 1 : 0,
1792 "; ",
1793 disp_chars(($y)), "=~/", disp_chars(($x)), "/i=",
1794 $y =~ /$x/i ? 1 : 0,
1795 "\n");
71e5cbb3
KW
1796 #
1797 # If $x and $y contain regular expression characters
1798 # AND THEY lowercase (/i) to regular expression characters,
1799 # regcomp() will be mightily confused. No, the \Q doesn't
1800 # help here (maybe regex engine internal lowercasing
1801 # is done after the \Q?) An example of this happening is
1802 # the bg_BG (Bulgarian) locale under EBCDIC (OS/390 USS):
1803 # the chr(173) (the "[") is the lowercase of the chr(235).
1804 #
1805 # Similarly losing EBCDIC locales include cs_cz, cs_CZ,
1806 # el_gr, el_GR, en_us.IBM-037 (!), en_US.IBM-037 (!),
1807 # et_ee, et_EE, hr_hr, hr_HR, hu_hu, hu_HU, lt_LT,
1808 # mk_mk, mk_MK, nl_nl.IBM-037, nl_NL.IBM-037,
1809 # pl_pl, pl_PL, ro_ro, ro_RO, ru_ru, ru_RU,
1810 # sk_sk, sk_SK, sl_si, sl_SI, tr_tr, tr_TR.
1811 #
1812 # Similar things can happen even under (bastardised)
1813 # non-EBCDIC locales: in many European countries before the
1814 # advent of ISO 8859-x nationally customised versions of
1815 # ISO 646 were devised, reusing certain punctuation
1816 # characters for modified characters needed by the
1817 # country/language. For example, the "|" might have
1818 # stood for U+00F6 or LATIN SMALL LETTER O WITH DIAERESIS.
1819 #
1820 if ($x =~ $re || $y =~ $re) {
1821 print "# Regex characters in '$x' or '$y', skipping test $locales_test_number for locale '$Locale'\n";
1822 next;
1823 }
69d77f94 1824 push @f, $x unless $x =~ /$y/i && $y =~ /$x/i;
26c1569f
KW
1825
1826 # fc is not a locale concept, so Perl uses lc for it.
1827 push @f, $x unless lc $x eq fc $x;
66cbab2c
KW
1828 }
1829 else {
1830 use locale ':not_characters';
1831 my $y = lc $x;
1832 next unless uc $y eq $x;
92891c66
KW
1833 debug_more( "# UPPER=", disp_chars(($x)),
1834 "; lc=", disp_chars(($y)), "; ",
4eac893c 1835 "; fc=", disp_chars((fc $x)), "; ",
92891c66
KW
1836 disp_chars(($x)), "=~/", disp_chars(($y)), "/i=",
1837 $x =~ /$y/i ? 1 : 0,
1838 "; ",
1839 disp_chars(($y)), "=~/", disp_chars(($x)), "/i=",
1840 $y =~ /$x/i ? 1 : 0,
1841 "\n");
66cbab2c 1842
66cbab2c 1843 push @f, $x unless $x =~ /$y/i && $y =~ /$x/i;
26c1569f
KW
1844
1845 # The places where Unicode's lc is different from fc are
1846 # skipped here by virtue of the 'next unless uc...' line above
1847 push @f, $x unless lc $x eq fc $x;
66cbab2c 1848 }
c00ff1c7 1849 }
ef4a39e5 1850
b9df08e4 1851 foreach my $x (sort { ord $a <=> ord $b } keys %lower) {
66cbab2c 1852 if (! $is_utf8_locale) {
71e5cbb3
KW
1853 my $y = uc $x;
1854 next unless lc $y eq $x;
92891c66
KW
1855 debug_more( "# lower=", disp_chars(($x)),
1856 "; uc=", disp_chars(($y)), "; ",
4eac893c 1857 "; fc=", disp_chars((fc $x)), "; ",
92891c66
KW
1858 disp_chars(($x)), "=~/", disp_chars(($y)), "/i=",
1859 $x =~ /$y/i ? 1 : 0,
1860 "; ",
1861 disp_chars(($y)), "=~/", disp_chars(($x)), "/i=",
1862 $y =~ /$x/i ? 1 : 0,
1863 "\n");
71e5cbb3
KW
1864 if ($x =~ $re || $y =~ $re) { # See above.
1865 print "# Regex characters in '$x' or '$y', skipping test $locales_test_number for locale '$Locale'\n";
1866 next;
1867 }
69d77f94 1868 push @f, $x unless $x =~ /$y/i && $y =~ /$x/i;
26c1569f
KW
1869
1870 push @f, $x unless lc $x eq fc $x;
66cbab2c
KW
1871 }
1872 else {
1873 use locale ':not_characters';
1874 my $y = uc $x;
1875 next unless lc $y eq $x;
92891c66
KW
1876 debug_more( "# lower=", disp_chars(($x)),
1877 "; uc=", disp_chars(($y)), "; ",
4eac893c 1878 "; fc=", disp_chars((fc $x)), "; ",
92891c66
KW
1879 disp_chars(($x)), "=~/", disp_chars(($y)), "/i=",
1880 $x =~ /$y/i ? 1 : 0,
1881 "; ",
1882 disp_chars(($y)), "=~/", disp_chars(($x)), "/i=",
1883 $y =~ /$x/i ? 1 : 0,
1884 "\n");
66cbab2c 1885 push @f, $x unless $x =~ /$y/i && $y =~ /$x/i;
26c1569f
KW
1886
1887 push @f, $x unless lc $x eq fc $x;
66cbab2c 1888 }
c00ff1c7 1889 }
7c844d17 1890 report_multi_result($Locale, $locales_test_number, \@f);
5b1f18a7 1891 $problematical_tests{$locales_test_number} = 1;
d8093b23 1892 }
78787052
JL
1893
1894 # [perl #109318]
1895 {
1896 my @f = ();
1897 ++$locales_test_number;
1898 $test_names{$locales_test_number} = 'Verify atof with locale radix and negative exponent';
b057411d 1899 $problematical_tests{$locales_test_number} = 1;
78787052
JL
1900
1901 my $radix = POSIX::localeconv()->{decimal_point};
1902 my @nums = (
1903 "3.14e+9", "3${radix}14e+9", "3.14e-9", "3${radix}14e-9",
1904 "-3.14e+9", "-3${radix}14e+9", "-3.14e-9", "-3${radix}14e-9",
1905 );
1906
1907 if (! $is_utf8_locale) {
1908 use locale;
1909 for my $num (@nums) {
1910 push @f, $num
1911 unless sprintf("%g", $num) =~ /3.+14/;
1912 }
1913 }
1914 else {
1915 use locale ':not_characters';
1916 for my $num (@nums) {
1917 push @f, $num
1918 unless sprintf("%g", $num) =~ /3.+14/;
1919 }
1920 }
1921
30032ef4 1922 report_result($Locale, $locales_test_number, @f == 0);
78787052
JL
1923 if (@f) {
1924 print "# failed $locales_test_number locale '$Locale' numbers @f\n"
1925 }
1926 }
8ebc5c01 1927}
284102e8 1928
c4093d7d 1929my $final_locales_test_number = $locales_test_number;
6cf0b567 1930
2a680da6
JH
1931# Recount the errors.
1932
0d3899b1 1933foreach $test_num ($first_locales_test_number..$final_locales_test_number) {
c4093d7d
KW
1934 if (%setlocale_failed) {
1935 print "not ";
1936 }
0d3899b1 1937 elsif ($Problem{$test_num} || !defined $Okay{$test_num} || !@{$Okay{$test_num}}) {
c4093d7d 1938 if (defined $not_necessarily_a_problem_test_number
0d3899b1 1939 && $test_num == $not_necessarily_a_problem_test_number)
c4093d7d
KW
1940 {
1941 print "# The failure of test $not_necessarily_a_problem_test_number is not necessarily fatal.\n";
b4e009be 1942 print "# It usually indicates a problem in the environment,\n";
284102e8
JH
1943 print "# not in Perl itself.\n";
1944 }
5b1f18a7 1945 if ($Okay{$test_num} && grep { $_ == $test_num } keys %problematical_tests) {
d401967c 1946 no warnings 'experimental::autoderef';
0a974e2d 1947 # Round to nearest .1%
0d3899b1 1948 my $percent_fail = (int(.5 + (1000 * scalar(keys $Problem{$test_num})
0a974e2d
KW
1949 / scalar(@Locale))))
1950 / 10;
31f658ea 1951 if (! $debug && $percent_fail < $acceptable_failure_percentage)
f5627fc1 1952 {
0d3899b1 1953 $test_names{$test_num} .= 'TODO';
6d5d702a
KW
1954 print "# ", 100 - $percent_fail, "% of locales pass the following test, so it is likely that the failures\n";
1955 print "# are errors in the locale definitions. The test is marked TODO, as the\n";
1956 print "# problem is not likely to be Perl's\n";
1957 }
1958 }
f5627fc1
KW
1959 print "#\n";
1960 if ($debug) {
1961 print "# The code points that had this failure are given above. Look for lines\n";
0d3899b1 1962 print "# that match 'failed $test_num'\n";
f5627fc1
KW
1963 }
1964 else {
1965 print "# For more details, rerun, with environment variable PERL_DEBUG_FULL_TEST=1.\n";
0d3899b1 1966 print "# Then look at that output for lines that match 'failed $test_num'\n";
108a305e 1967 }
284102e8 1968 print "not ";
8ebc5c01 1969 }
0d3899b1
KW
1970 print "ok $test_num";
1971 if (defined $test_names{$test_num}) {
6c2e653d 1972 # If TODO is in the test name, make it thus
0d3899b1
KW
1973 my $todo = $test_names{$test_num} =~ s/TODO\s*//;
1974 print " $test_names{$test_num}";
6c2e653d
KW
1975 print " # TODO" if $todo;
1976 }
c4093d7d 1977 print "\n";
8ebc5c01 1978}
fb73857a 1979
c4093d7d 1980$test_num = $final_locales_test_number;
c213d471 1981
4bc67723 1982unless ( $^O =~ m!^(dragonfly|openbsd|bitrig|mirbsd)$! ) {
083ace8f 1983 # perl #115808
fbd840df
KW
1984 use warnings;
1985 my $warned = 0;
1986 local $SIG{__WARN__} = sub {
1987 $warned = $_[0] =~ /uninitialized/;
1988 };
1989 my $z = "y" . setlocale(&POSIX::LC_ALL, "xyzzy");
1990 ok($warned, "variable set to setlocale(BAD LOCALE) is considered uninitialized");
1991}
1992
094a2f8c 1993# Test that tainting and case changing works on utf8 strings. These tests are
1f5852c9
KW
1994# placed last to avoid disturbing the hard-coded test numbers that existed at
1995# the time these were added above this in this file.
0099bb8d
KW
1996# This also tests that locale overrides unicode_strings in the same scope for
1997# non-utf8 strings.
a810e350 1998setlocale(&POSIX::LC_ALL, "C");
094a2f8c
KW
1999{
2000 use locale;
0099bb8d 2001 use feature 'unicode_strings';
094a2f8c 2002
26c1569f 2003 foreach my $function ("uc", "ucfirst", "lc", "lcfirst", "fc") {
094a2f8c
KW
2004 my @list; # List of code points to test for $function
2005
2006 # Used to calculate the changed case for ASCII characters by using the
2007 # ord, instead of using one of the functions under test.
2008 my $ascii_case_change_delta;
2009 my $above_latin1_case_change_delta; # Same for the specific ords > 255
2010 # that we use
2011
445bf929 2012 # We test an ASCII character, which should change case;
094a2f8c 2013 # a Latin1 character, which shouldn't change case under this C locale,
094a2f8c 2014 # an above-Latin1 character that when the case is changed would cross
445bf929
KW
2015 # the 255/256 boundary, so doesn't change case
2016 # (the \x{149} is one of these, but changes into 2 characters, the
094a2f8c
KW
2017 # first one of which doesn't cross the boundary.
2018 # the final one in each list is an above-Latin1 character whose case
445bf929
KW
2019 # does change. The code below uses its position in its list as a
2020 # marker to indicate that it, unlike the other code points above
2021 # ASCII, has a successful case change
2022 #
2023 # All casing operations under locale (but not :not_characters) should
2024 # taint
094a2f8c 2025 if ($function =~ /^u/) {
094a2f8c
KW
2026 @list = ("", "a", "\xe0", "\xff", "\x{fb00}", "\x{149}", "\x{101}");
2027 $ascii_case_change_delta = -32;
2028 $above_latin1_case_change_delta = -1;
2029 }
2030 else {
1ca267a5 2031 @list = ("", "A", "\xC0", "\x{17F}", "\x{100}");
094a2f8c
KW
2032 $ascii_case_change_delta = +32;
2033 $above_latin1_case_change_delta = +1;
2034 }
66cbab2c 2035 foreach my $is_utf8_locale (0 .. 1) {
71e5cbb3
KW
2036 foreach my $j (0 .. $#list) {
2037 my $char = $list[$j];
0099bb8d
KW
2038
2039 for my $encoded_in_utf8 (0 .. 1) {
faf0c248
KW
2040 my $should_be;
2041 my $changed;
2042 if (! $is_utf8_locale) {
2043 $should_be = ($j == $#list)
2044 ? chr(ord($char) + $above_latin1_case_change_delta)
2045 : (length $char == 0 || ord($char) > 127)
2046 ? $char
2047 : chr(ord($char) + $ascii_case_change_delta);
2048
2049 # This monstrosity is in order to avoid using an eval,
2050 # which might perturb the results
2051 $changed = ($function eq "uc")
2052 ? uc($char)
2053 : ($function eq "ucfirst")
2054 ? ucfirst($char)
2055 : ($function eq "lc")
2056 ? lc($char)
2057 : ($function eq "lcfirst")
2058 ? lcfirst($char)
26c1569f
KW
2059 : ($function eq "fc")
2060 ? fc($char)
faf0c248
KW
2061 : die("Unexpected function \"$function\"");
2062 }
2063 else {
2064 {
2065 no locale;
71e5cbb3 2066
faf0c248
KW
2067 # For utf8-locales the case changing functions
2068 # should work just like they do outside of locale.
2069 # Can use eval here because not testing it when
2070 # not in locale.
2071 $should_be = eval "$function('$char')";
2072 die "Unexpected eval error $@ from 'eval \"$function('$char')\"'" if $@;
71e5cbb3 2073
faf0c248
KW
2074 }
2075 use locale ':not_characters';
2076 $changed = ($function eq "uc")
2077 ? uc($char)
2078 : ($function eq "ucfirst")
2079 ? ucfirst($char)
2080 : ($function eq "lc")
2081 ? lc($char)
2082 : ($function eq "lcfirst")
2083 ? lcfirst($char)
26c1569f
KW
2084 : ($function eq "fc")
2085 ? fc($char)
faf0c248 2086 : die("Unexpected function \"$function\"");
71e5cbb3 2087 }
faf0c248
KW
2088 ok($changed eq $should_be,
2089 "$function(\"$char\") in C locale "
2090 . (($is_utf8_locale)
2091 ? "(use locale ':not_characters'"
2092 : "(use locale")
2093 . (($encoded_in_utf8)
2094 ? "; encoded in utf8)"
2095 : "; not encoded in utf8)")
2096 . " should be \"$should_be\", got \"$changed\"");
2097
445bf929
KW
2098 # Tainting shouldn't happen for use locale :not_character
2099 # (a utf8 locale)
2100 (! $is_utf8_locale)
faf0c248
KW
2101 ? check_taint($changed)
2102 : check_taint_not($changed);
2103
2104 # Use UTF-8 next time through the loop
2105 utf8::upgrade($char);
0099bb8d 2106 }
66cbab2c 2107 }
094a2f8c
KW
2108 }
2109 }
2110}
2111
1bfe8fea
KW
2112# Give final advice.
2113
2114my $didwarn = 0;
2115
2116foreach ($first_locales_test_number..$final_locales_test_number) {
2117 if ($Problem{$_}) {
2118 my @f = sort keys %{ $Problem{$_} };
2119 my $f = join(" ", @f);
2120 $f =~ s/(.{50,60}) /$1\n#\t/g;
2121 print
2122 "#\n",
2123 "# The locale ", (@f == 1 ? "definition" : "definitions"), "\n#\n",
2124 "#\t", $f, "\n#\n",
2125 "# on your system may have errors because the locale test $_\n",
2126 "# \"$test_names{$_}\"\n",
2127 "# failed in ", (@f == 1 ? "that locale" : "those locales"),
2128 ".\n";
2129 print <<EOW;
2130#
2131# If your users are not using these locales you are safe for the moment,
2132# but please report this failure first to perlbug\@perl.com using the
2133# perlbug script (as described in the INSTALL file) so that the exact
2134# details of the failures can be sorted out first and then your operating
2135# system supplier can be alerted about these anomalies.
2136#
2137EOW
2138 $didwarn = 1;
2139 }
2140}
2141
2142# Tell which locales were okay and which were not.
2143
2144if ($didwarn) {
2145 my (@s, @F);
2146
2147 foreach my $l (@Locale) {
2148 my $p = 0;
2149 if ($setlocale_failed{$l}) {
2150 $p++;
2151 }
2152 else {
2153 foreach my $t
2154 ($first_locales_test_number..$final_locales_test_number)
2155 {
2156 $p++ if $Problem{$t}{$l};
2157 }
2158 }
2159 push @s, $l if $p == 0;
2160 push @F, $l unless $p == 0;
2161 }
2162
2163 if (@s) {
2164 my $s = join(" ", @s);
2165 $s =~ s/(.{50,60}) /$1\n#\t/g;
2166
a5cf558a 2167 print
1bfe8fea
KW
2168 "# The following locales\n#\n",
2169 "#\t", $s, "\n#\n",
2170 "# tested okay.\n#\n",
2171 } else {
a5cf558a 2172 print "# None of your locales were fully okay.\n";
1bfe8fea
KW
2173 }
2174
2175 if (@F) {
2176 my $F = join(" ", @F);
2177 $F =~ s/(.{50,60}) /$1\n#\t/g;
2178
c7e7f6b7
KW
2179 my $details = "";
2180 unless ($debug) {
2181 $details = "# For more details, rerun, with environment variable PERL_DEBUG_FULL_TEST=1.\n";
2182 }
2183 elsif ($debug == 1) {
2184 $details = "# For even more details, rerun, with environment variable PERL_DEBUG_FULL_TEST=2.\n";
2185 }
2186
a5cf558a 2187 print
1bfe8fea
KW
2188 "# The following locales\n#\n",
2189 "#\t", $F, "\n#\n",
2190 "# had problems.\n#\n",
c7e7f6b7 2191 $details;
1bfe8fea 2192 } else {
a5cf558a 2193 print "# None of your locales were broken.\n";
1bfe8fea
KW
2194 }
2195}
2196
fdf053ee 2197print "1..$test_num\n";
906f284f 2198
90248788 2199# eof