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@";
179 print "not " unless "\N{LINE FEED (LF)}" eq "\n";
182 print "not " unless "\N{LINE FEED}" eq "\n";
185 print "not " unless "\N{LF}" eq "\n";
188 my $nel = ord("A") == 193 ? qr/^(?:\x15|\x25)$/ : qr/^\x85$/;
190 print "not " unless "\N{NEXT LINE (NEL)}" =~ $nel;
193 print "not " unless "\N{NEXT LINE}" =~ $nel;
196 print "not " unless "\N{NEL}" =~ $nel;
199 print "not " unless "\N{BYTE ORDER MARK}" eq chr(0xFEFF);
202 print "not " unless "\N{BOM}" eq chr(0xFEFF);
206 use warnings 'deprecated';
208 print "not " unless "\N{HORIZONTAL TABULATION}" eq "\t";
211 print "not " unless grep { /"HORIZONTAL TABULATION" is deprecated/ } @WARN;
214 no warnings 'deprecated';
216 print "not " unless "\N{VERTICAL TABULATION}" eq "\013";
219 print "not " if grep { /"VERTICAL TABULATION" is deprecated/ } @WARN;
223 print "not " unless charnames::viacode(0xFEFF) eq "ZERO WIDTH NO-BREAK SPACE";
228 print "not " unless ord("\N{BOM}") == 0xFEFF;
232 print "not " unless ord("\N{ZWNJ}") == 0x200C;
235 print "not " unless ord("\N{ZWJ}") == 0x200D;
238 print "not " unless "\N{U+263A}" eq "\N{WHITE SMILING FACE}";
243 0x3093 == charnames::vianame("HIRAGANA LETTER N");
247 0x0397 == charnames::vianame("GREEK CAPITAL LETTER ETA");
251 print "not " if defined charnames::viacode(0x110000);
254 print "not " if grep { /you asked for U+110000/ } @WARN;
258 # ---- Alias extensions
260 my $alifile = File::Spec->catfile(File::Spec->updir, qw(lib unicore xyzzy_alias.pl));
265 @prgs = split "\n########\n", <DATA>;
270 my ($code, $exp) = ((split m/\nEXPECT\n/), '$');
271 my ($prog, $fil) = ((split m/\nFILE\n/, $code), "");
272 my $tmpfile = tempfile();
273 open my $tmp, "> $tmpfile" or die "Could not open $tmpfile: $!";
274 print $tmp $prog, "\n";
275 close $tmp or die "Could not close $tmpfile: $!";
278 open my $ali, "> $alifile" or die "Could not open $alifile: $!";
280 close $ali or die "Could not close $alifile: $!";
282 my $res = runperl( switches => $switch,
283 progfile => $tmpfile,
286 $res =~ s/[\r\n]+$//;
287 $res =~ s/tmp\d+/-/g; # fake $prog from STDIN
288 $res =~ s/\n%[A-Z]+-[SIWEF]-.*$// # clip off DCL status msg
290 $exp =~ s/[\r\n]+$//;
291 my $pfx = ($res =~ s/^PREFIX\n//);
292 my $rexp = qr{^$exp};
293 if ($res =~ s/^SKIPPED\n//) {
296 elsif (($pfx and $res !~ /^\Q$expected/) or
297 (!$pfx and $res !~ $rexp)) {
305 print "ok ", ++$i, "\n";
307 1 while unlink $alifile;
310 # [perl #30409] charnames.pm clobbers default variable
312 eval "use charnames ':full';";
313 print "not " unless $_ eq 'foobar';
316 # Unicode slowdown noted by Phil Pennock, traced to a bug fix in index
317 # SADAHIRO Tomoyuki's suggestion is to ensure that the UTF-8ness of both
318 # arguments are indentical before calling index.
319 # To do this can take advantage of the fact that unicore/Name.pl is 7 bit
320 # (or at least should be). So assert that that it's true here.
322 my $names = do "unicore/Name.pl";
323 print defined $names ? "ok 75\n" : "not ok 75\n";
324 if (ord('A') == 65) { # as on ASCII or UTF-8 machines
325 my $non_ascii = $names =~ tr/\0-\177//c;
326 print $non_ascii ? "not ok 76 # $non_ascii\n" : "ok 76\n";
331 # Verify that charnames propagate to eval("")
332 my $evaltry = eval q[ "Eval: \N{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}" ];
334 print "# $@not ok 77\nnot ok 78\n";
337 print "not " unless $evaltry eq "Eval: \N{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}";
341 # Verify that db includes the normative NameAliases.txt names
342 print "not " unless "\N{U+1D0C5}" eq "\N{BYZANTINE MUSICAL SYMBOL FTHORA SKLIRON CHROMA VASIS}";
347 use charnames ":scoobydoo";
348 "Here: \N{e_ACUTE}!\n";
350 unsupported special ':scoobydoo' in charnames at
352 # wrong type of alias (missing colon)
353 use charnames "alias";
354 "Here: \N{e_ACUTE}!\n";
356 Unknown charname 'e_ACUTE' at
358 # alias without an argument
359 use charnames ":alias";
360 "Here: \N{e_ACUTE}!\n";
362 :alias needs an argument in charnames at
365 use charnames ":alias" => ":full";
366 "Here: \N{e_ACUTE}!\n";
368 :alias cannot use existing pragma :full \(reversed order\?\) at
370 # alias with hashref but no :full
371 use charnames ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
372 "Here: \N{e_ACUTE}!\n";
374 Unknown charname 'LATIN SMALL LETTER E WITH ACUTE' at
376 # alias with hashref but with :short
377 use charnames ":short", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
378 "Here: \N{e_ACUTE}!\n";
380 Unknown charname 'LATIN SMALL LETTER E WITH ACUTE' at
382 # alias with hashref to :full OK
383 use charnames ":full", ":alias" => { e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE" };
384 "Here: \N{e_ACUTE}!\n";
388 # alias with hashref to :short but using :full
389 use charnames ":full", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE" };
390 "Here: \N{e_ACUTE}!\n";
392 Unknown charname 'LATIN:e WITH ACUTE' at
394 # alias with hashref to :short OK
395 use charnames ":short", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE" };
396 "Here: \N{e_ACUTE}!\n";
400 # alias with bad hashref
401 use charnames ":short", ":alias" => "e_ACUTE";
402 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
404 unicore/e_ACUTE_alias.pl cannot be used as alias file for charnames at
406 # alias with arrayref
407 use charnames ":short", ":alias" => [ e_ACUTE => "LATIN:e WITH ACUTE" ];
408 "Here: \N{e_ACUTE}!\n";
410 Only HASH reference supported as argument to :alias at
412 # alias with bad hashref
413 use charnames ":short", ":alias" => { e_ACUTE => "LATIN:e WITH ACUTE", "a_ACUTE" };
414 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
416 Use of uninitialized value
418 # alias with hashref two aliases
419 use charnames ":short", ":alias" => {
420 e_ACUTE => "LATIN:e WITH ACUTE",
423 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
425 Unknown charname '' at
427 # alias with hashref two aliases
428 use charnames ":short", ":alias" => {
429 e_ACUTE => "LATIN:e WITH ACUTE",
430 a_ACUTE => "LATIN:a WITH ACUTE",
432 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
436 # alias with hashref using mixed aliasses
437 use charnames ":short", ":alias" => {
438 e_ACUTE => "LATIN:e WITH ACUTE",
439 a_ACUTE => "LATIN SMALL LETTER A WITH ACUT",
441 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
443 Unknown charname 'LATIN SMALL LETTER A WITH ACUT' at
445 # alias with hashref using mixed aliasses
446 use charnames ":short", ":alias" => {
447 e_ACUTE => "LATIN:e WITH ACUTE",
448 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
450 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
452 Unknown charname 'LATIN SMALL LETTER A WITH ACUTE' at
454 # alias with hashref using mixed aliasses
455 use charnames ":full", ":alias" => {
456 e_ACUTE => "LATIN:e WITH ACUTE",
457 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
459 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
461 Unknown charname 'LATIN:e WITH ACUTE' at
463 # alias with nonexisting file
464 use charnames ":full", ":alias" => "xyzzy";
465 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
467 unicore/xyzzy_alias.pl cannot be used as alias file for charnames at
469 # alias with bad file name
470 use charnames ":full", ":alias" => "xy 7-";
471 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
473 Charnames alias files can only have identifier characters at
475 # alias with non_absolute (existing) file name (which it should /not/ use)
476 use charnames ":full", ":alias" => "perl";
477 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
479 unicore/perl_alias.pl cannot be used as alias file for charnames at
481 # alias with bad file
482 use charnames ":full", ":alias" => "xyzzy";
483 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
488 unicore/xyzzy_alias.pl did not return a \(valid\) list of alias pairs at
490 # alias with file with empty list
491 use charnames ":full", ":alias" => "xyzzy";
492 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
497 Unknown charname 'e_ACUTE' at
499 # alias with file OK but file has :short aliasses
500 use charnames ":full", ":alias" => "xyzzy";
501 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
504 ( e_ACUTE => "LATIN:e WITH ACUTE",
505 a_ACUTE => "LATIN:a WITH ACUTE",
508 Unknown charname 'LATIN:e WITH ACUTE' at
510 # alias with :short and file OK
511 use charnames ":short", ":alias" => "xyzzy";
512 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
515 ( e_ACUTE => "LATIN:e WITH ACUTE",
516 a_ACUTE => "LATIN:a WITH ACUTE",
521 # alias with :short and file OK has :long aliasses
522 use charnames ":short", ":alias" => "xyzzy";
523 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
526 ( e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE",
527 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",
530 Unknown charname 'LATIN SMALL LETTER E WITH ACUTE' at
532 # alias with file implicit :full but file has :short aliasses
533 use charnames ":alias" => ":xyzzy";
534 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
537 ( e_ACUTE => "LATIN:e WITH ACUTE",
538 a_ACUTE => "LATIN:a WITH ACUTE",
541 Unknown charname 'LATIN:e WITH ACUTE' at
543 # alias with file implicit :full and file has :long aliasses
544 use charnames ":alias" => ":xyzzy";
545 "Here: \N{e_ACUTE}\N{a_ACUTE}!\n";
548 ( e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE",
549 a_ACUTE => "LATIN SMALL LETTER A WITH ACUTE",