6 unless(grep /blib/, @INC) {
11 $SIG{__WARN__} = sub { push @WARN, @_ };
20 use charnames ':full';
22 print "not " unless "Here\N{EXCLAMATION MARK}?" eq "Here!?";
26 use bytes; # TEST -utf8 can switch utf8 on
28 print "# \$res=$res \$\@='$@'\nnot "
29 if $res = eval <<'EOE'
30 use charnames ":full";
31 "Here: \N{CYRILLIC SMALL LETTER BE}!";
34 or $@ !~ /above 0xFF/;
36 # print "# \$res=$res \$\@='$@'\n";
38 print "# \$res=$res \$\@='$@'\nnot "
39 if $res = eval <<'EOE'
40 use charnames 'cyrillic';
44 or $@ !~ /CYRILLIC CAPITAL LETTER BE.*above 0xFF/;
48 # If octal representation of unicode char is \0xyzt, then the utf8 is \3xy\2zt
49 if (ord('A') == 65) { # as on ASCII or UTF-8 machines
50 $encoded_be = "\320\261";
51 $encoded_alpha = "\316\261";
52 $encoded_bet = "\327\221";
53 $encoded_deseng = "\360\220\221\215";
55 else { # EBCDIC where UTF-EBCDIC may be used (this may be 1047 specific since
56 # UTF-EBCDIC is codepage specific)
57 $encoded_be = "\270\102\130";
58 $encoded_alpha = "\264\130";
59 $encoded_bet = "\270\125\130";
60 $encoded_deseng = "\336\102\103\124";
68 use charnames ':full';
70 print "not " unless to_bytes("\N{CYRILLIC SMALL LETTER BE}") eq $encoded_be;
73 use charnames qw(cyrillic greek :short);
75 print "not " unless to_bytes("\N{be},\N{alpha},\N{hebrew:bet}")
76 eq "$encoded_be,$encoded_alpha,$encoded_bet";
81 use charnames ':full';
82 print "not " unless "\x{263a}" eq "\N{WHITE SMILING FACE}";
84 print "not " unless length("\x{263a}") == 1;
86 print "not " unless length("\N{WHITE SMILING FACE}") == 1;
88 print "not " unless sprintf("%vx", "\x{263a}") eq "263a";
90 print "not " unless sprintf("%vx", "\N{WHITE SMILING FACE}") eq "263a";
92 print "not " unless sprintf("%vx", "\xFF\N{WHITE SMILING FACE}") eq "ff.263a";
94 print "not " unless sprintf("%vx", "\x{ff}\N{WHITE SMILING FACE}") eq "ff.263a";
99 use charnames qw(:full);
103 my $named = "\N{CUBE ROOT}";
105 print "not " unless ord($x) == ord($named);
110 use charnames qw(:full);
112 print "not " unless "\x{100}\N{CENT SIGN}" eq "\x{100}"."\N{CENT SIGN}";
117 use charnames ':full';
120 unless to_bytes("\N{DESERET SMALL LETTER ENG}") eq $encoded_deseng;
127 no utf8; # naked Latin-1
129 if (ord("Ä") == 0xc4) { # Try to do this only on Latin-1.
130 use charnames ':full';
131 my $text = "\N{LATIN CAPITAL LETTER A WITH DIAERESIS}";
132 print "not " unless $text eq "\xc4" && ord($text) == 0xc4;
135 print "ok 16 # Skip: not Latin-1\n";
140 print "not " unless charnames::viacode(0x1234) eq "ETHIOPIC SYLLABLE SEE";
144 print "not " if defined charnames::viacode(0x0590);
150 sprintf("%04X", charnames::vianame("GOTHIC LETTER AHSA")) eq "10330";
154 defined charnames::vianame("NONE SUCH");
159 # check that caching at least hasn't broken anything
161 print "not " unless charnames::viacode(0x1234) eq "ETHIOPIC SYLLABLE SEE";
165 sprintf("%04X", charnames::vianame("GOTHIC LETTER AHSA")) eq "10330";
170 print "not " unless "\N{CHARACTER TABULATION}" eq "\t";
173 print "not " unless "\N{ESCAPE}" eq "\e";
176 print "not " unless "\N{NULL}" eq "\c@";
181 print "not " unless "\N{CARRIAGE RETURN (CR)}" eq "\n";
184 print "not " unless "\N{CARRIAGE RETURN}" eq "\n";
187 print "not " unless "\N{CR}" eq "\n";
192 print "not " unless "\N{LINE FEED (LF)}" eq "\n";
195 print "not " unless "\N{LINE FEED}" eq "\n";
198 print "not " unless "\N{LF}" eq "\n";
202 my $nel = ord("A") == 193 ? qr/^(?:\x15|\x25)$/ : qr/^\x85$/;
204 print "not " unless "\N{NEXT LINE (NEL)}" =~ $nel;
207 print "not " unless "\N{NEXT LINE}" =~ $nel;
210 print "not " unless "\N{NEL}" =~ $nel;
213 print "not " unless "\N{BYTE ORDER MARK}" eq chr(0xFEFF);
216 print "not " unless "\N{BOM}" eq chr(0xFEFF);
220 use warnings 'deprecated';
222 print "not " unless "\N{HORIZONTAL TABULATION}" eq "\t";
225 print "not " unless grep { /"HORIZONTAL TABULATION" is deprecated/ } @WARN;
228 no warnings 'deprecated';
230 print "not " unless "\N{VERTICAL TABULATION}" eq "\013";
233 print "not " if grep { /"VERTICAL TABULATION" is deprecated/ } @WARN;
237 print "not " unless charnames::viacode(0xFEFF) eq "ZERO WIDTH NO-BREAK SPACE";
242 print "not " unless ord("\N{BOM}") == 0xFEFF;
246 print "not " unless ord("\N{ZWNJ}") == 0x200C;
249 print "not " unless ord("\N{ZWJ}") == 0x200D;
252 print "not " unless "\N{U+263A}" eq "\N{WHITE SMILING FACE}";
257 0x3093 == charnames::vianame("HIRAGANA LETTER N");
261 0x0397 == charnames::vianame("GREEK CAPITAL LETTER ETA");
265 print "not " if defined charnames::viacode(0x110000);
268 print "not " if grep { /you asked for U+110000/ } @WARN;
272 # ---- Alias extensions
274 my $tmpfile = "tmp0000";
275 my $alifile = File::Spec->catfile(File::Spec->updir, qw(lib unicore xyzzy_alias.pl));
277 1 while -e ++$tmpfile;
278 END { if ($tmpfile) { 1 while unlink $tmpfile; } }
282 @prgs = split "\n########\n", <DATA>;
287 my ($code, $exp) = ((split m/\nEXPECT\n/), '$');
288 my ($prog, $fil) = ((split m/\nFILE\n/, $code), "");
289 open my $tmp, "> $tmpfile" or die "Could not open $tmpfile: $!";
290 print $tmp $prog, "\n";
291 close $tmp or die "Could not close $tmpfile: $!";
294 open my $ali, "> $alifile" or die "Could not open $alifile: $!";
296 close $ali or die "Could not close $alifile: $!";
298 my $res = runperl( switches => $switch,
299 progfile => $tmpfile,
302 $res =~ s/[\r\n]+$//;
303 $res =~ s/tmp\d+/-/g; # fake $prog from STDIN
304 $res =~ s/\n%[A-Z]+-[SIWEF]-.*$// # clip off DCL status msg
306 $exp =~ s/[\r\n]+$//;
307 if ($^O eq "MacOS") {
308 $exp =~ s{(\./)?abc\.pm}{:abc.pm}g;
309 $exp =~ s{./abc} {:abc}g;
311 my $pfx = ($res =~ s/^PREFIX\n//);
312 my $rexp = qr{^$exp};
313 if ($res =~ s/^SKIPPED\n//) {
316 elsif (($pfx and $res !~ /^\Q$expected/) or
317 (!$pfx and $res !~ $rexp)) {
325 print "ok ", ++$i, "\n";
326 1 while unlink $tmpfile;
328 1 while unlink $alifile;
331 # [perl #30409] charnames.pm clobbers default variable
333 eval "use charnames ':full';";
334 print "not " unless $_ eq 'foobar';
337 # Unicode slowdown noted by Phil Pennock, traced to a bug fix in index
338 # SADAHIRO Tomoyuki's suggestion is to ensure that the UTF-8ness of both
339 # arguments are indentical before calling index.
340 # To do this can take advantage of the fact that unicore/Name.pl is 7 bit
341 # (or at least should be). So assert that that it's true here.
343 my $names = do "unicore/Name.pl";
344 print defined $names ? "ok 75\n" : "not ok 75\n";
345 if (ord('A') == 65) { # as on ASCII or UTF-8 machines
346 my $non_ascii = $names =~ tr/\0-\177//c;
347 print $non_ascii ? "not ok 76 # $non_ascii\n" : "ok 76\n";
352 # Verify that charnames propagate to eval("")
353 my $evaltry = eval q[ "Eval: \N{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}" ];
355 print "# $@not ok 77\nnot ok 78\n";
358 print "not " unless $evaltry eq "Eval: \N{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}";
364 use charnames ":scoobydoo";
365 "Here: \N{e_ACUTE}!\n";
367 unsupported special ':scoobydoo' in charnames at
369 # wrong type of alias (missing colon)
370 use charnames "alias";
371 "Here: \N{e_ACUTE}!\n";
373 Unknown charname 'e_ACUTE' at
375 # alias without an argument
376 use charnames ":alias";
377 "Here: \N{e_ACUTE}!\n";
379 :alias needs an argument in charnames at
382 use charnames ":alias" => ":full";
383 "Here: \N{e_ACUTE}!\n";
385 :alias cannot use existing pragma :full \(reversed order\?\) at
387 # alias with hashref but no :full
388 use charnames ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
389 "Here: \N{e_ACUTE}!\n";
391 Unknown charname 'LATIN SMALL LETTER E WITH ACUTE' at
393 # alias with hashref but with :short
394 use charnames ":short", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
395 "Here: \N{e_ACUTE}!\n";
397 Unknown charname 'LATIN SMALL LETTER E WITH ACUTE' at
399 # alias with hashref to :full OK
400 use charnames ":full", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
401 "Here: \N{e_ACUTE}!\n";
405 # alias with hashref to :short but using :full
406 use charnames ":full", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE" };
407 "Here: \N{e_ACUTE}!\n";
409 Unknown charname 'LATIN:e WITH ACUTE' at
411 # alias with hashref to :short OK
412 use charnames ":short", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE" };
413 "Here: \N{e_ACUTE}!\n";
417 # alias with bad hashref
418 use charnames ":short", ":alias" => "e_ACUTE";
419 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
421 unicore/e_ACUTE_alias.pl cannot be used as alias file for charnames at
423 # alias with arrayref
424 use charnames ":short", ":alias" => [ e_ACUTE => "LATIN:e WITH ACUTE" ];
425 "Here: \N{e_ACUTE}!\n";
427 Only HASH reference supported as argument to :alias at
429 # alias with bad hashref
430 use charnames ":short", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE", "a_ACUTE" };
431 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
433 Use of uninitialized value
435 # alias with hashref two aliases
436 use charnames ":short", ":alias" => {
437 e_ACUTE => "LATIN:e WITH ACUTE",
440 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
442 Unknown charname '' at
444 # alias with hashref two aliases
445 use charnames ":short", ":alias" => {
446 e_ACUTE => "LATIN:e WITH ACUTE",
447 a_ACUTE => "LATIN:a WITH ACUTE",
449 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
453 # alias with hashref using mixed aliasses
454 use charnames ":short", ":alias" => {
455 e_ACUTE => "LATIN:e WITH ACUTE",
456 a_ACUTE => "LATIN SMALL LETTER A WITH ACUT",
458 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
460 Unknown charname 'LATIN SMALL LETTER A WITH ACUT' at
462 # alias with hashref using mixed aliasses
463 use charnames ":short", ":alias" => {
464 e_ACUTE => "LATIN:e WITH ACUTE",
465 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
467 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
469 Unknown charname 'LATIN SMALL LETTER A WITH ACUTE' at
471 # alias with hashref using mixed aliasses
472 use charnames ":full", ":alias" => {
473 e_ACUTE => "LATIN:e WITH ACUTE",
474 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
476 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
478 Unknown charname 'LATIN:e WITH ACUTE' at
480 # alias with nonexisting file
481 use charnames ":full", ":alias" => "xyzzy";
482 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
484 unicore/xyzzy_alias.pl cannot be used as alias file for charnames at
486 # alias with bad file name
487 use charnames ":full", ":alias" => "xy 7-";
488 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
490 Charnames alias files can only have identifier characters at
492 # alias with non_absolute (existing) file name (which it should /not/ use)
493 use charnames ":full", ":alias" => "perl";
494 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
496 unicore/perl_alias.pl cannot be used as alias file for charnames at
498 # alias with bad file
499 use charnames ":full", ":alias" => "xyzzy";
500 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
505 unicore/xyzzy_alias.pl did not return a \(valid\) list of alias pairs at
507 # alias with file with empty list
508 use charnames ":full", ":alias" => "xyzzy";
509 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
514 Unknown charname 'e_ACUTE' at
516 # alias with file OK but file has :short aliasses
517 use charnames ":full", ":alias" => "xyzzy";
518 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
521 ( e_ACUTE => "LATIN:e WITH ACUTE",
522 a_ACUTE => "LATIN:a WITH ACUTE",
525 Unknown charname 'LATIN:e WITH ACUTE' at
527 # alias with :short and file OK
528 use charnames ":short", ":alias" => "xyzzy";
529 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
532 ( e_ACUTE => "LATIN:e WITH ACUTE",
533 a_ACUTE => "LATIN:a WITH ACUTE",
538 # alias with :short and file OK has :long aliasses
539 use charnames ":short", ":alias" => "xyzzy";
540 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
543 ( e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE",
544 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
547 Unknown charname 'LATIN SMALL LETTER E WITH ACUTE' at
549 # alias with file implicit :full but file has :short aliasses
550 use charnames ":alias" => ":xyzzy";
551 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
554 ( e_ACUTE => "LATIN:e WITH ACUTE",
555 a_ACUTE => "LATIN:a WITH ACUTE",
558 Unknown charname 'LATIN:e WITH ACUTE' at
560 # alias with file implicit :full and file has :long aliasses
561 use charnames ":alias" => ":xyzzy";
562 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
565 ( e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE",
566 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",