This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make hv_notallowed a static as suggested by Nicholas Clark;
[perl5.git] / lib / charnames.t
index 124dad0..3123127 100644 (file)
@@ -1,18 +1,22 @@
 #!./perl
 
+my @WARN;
+
 BEGIN {
     unless(grep /blib/, @INC) {
        chdir 't' if -d 't';
        @INC = '../lib';
     }
+    $SIG{__WARN__} = sub { push @WARN, @_ };
 }
 
 $| = 1;
-print "1..16\n";
+
+print "1..39\n";
 
 use charnames ':full';
 
-print "not " unless "Here\N{EXCLAMATION MARK}?" eq "Here\041?";
+print "not " unless "Here\N{EXCLAMATION MARK}?" eq "Here!?";
 print "ok 1\n";
 
 {
@@ -117,7 +121,7 @@ sub to_bytes {
 {
   # 20001114.001       
 
-  no utf8; # so that the naked 8-bit character won't gripe under use utf8
+  no utf8; # naked Latin-1
 
   if (ord("Ä") == 0xc4) { # Try to do this only on Latin-1.
       use charnames ':full';
@@ -129,3 +133,96 @@ sub to_bytes {
   }
 }
 
+{
+    print "not " unless charnames::viacode(0x1234) eq "ETHIOPIC SYLLABLE SEE";
+    print "ok 17\n";
+
+    # Unused Hebrew.
+    print "not " unless charnames::viacode(0x0590) eq chr(0xFFFD);
+    print "ok 18\n";
+}
+
+{
+    print "not " unless
+       sprintf "%04X\n", charnames::vianame("GOTHIC LETTER AHSA") eq "10330";
+    print "ok 19\n";
+
+    print "not " if
+       defined charnames::vianame("NONE SUCH");
+    print "ok 20\n";
+}
+
+{
+    # check that caching at least hasn't broken anything
+
+    print "not " unless charnames::viacode(0x1234) eq "ETHIOPIC SYLLABLE SEE";
+    print "ok 21\n";
+
+    print "not " unless
+       sprintf "%04X\n", charnames::vianame("GOTHIC LETTER AHSA") eq "10330";
+    print "ok 22\n";
+
+}
+
+print "not " unless "\N{CHARACTER TABULATION}" eq "\t";
+print "ok 23\n";
+
+print "not " unless "\N{ESCAPE}" eq "\e";
+print "ok 24\n";
+
+print "not " unless "\N{NULL}" eq "\c@";
+print "ok 25\n";
+
+print "not " unless "\N{LINE FEED (LF)}" eq "\n";
+print "ok 26\n";
+
+print "not " unless "\N{LINE FEED}" eq "\n";
+print "ok 27\n";
+
+print "not " unless "\N{LF}" eq "\n";
+print "ok 28\n";
+
+my $nel = ord("A") == 193 ? qr/^(?:\x15|\x25)$/ : qr/^\x85$/;
+
+print "not " unless "\N{NEXT LINE (NEL)}" =~ $nel;
+print "ok 29\n";
+
+print "not " unless "\N{NEXT LINE}" =~ $nel;
+print "ok 30\n";
+
+print "not " unless "\N{NEL}" =~ $nel;
+print "ok 31\n";
+
+print "not " unless "\N{BYTE ORDER MARK}" eq chr(0xFEFF);
+print "ok 32\n";
+
+print "not " unless "\N{BOM}" eq chr(0xFEFF);
+print "ok 33\n";
+
+{
+    use warnings 'deprecated';
+
+    print "not " unless "\N{HORIZONTAL TABULATION}" eq "\t";
+    print "ok 34\n";
+
+    print "not " unless grep { /"HORIZONTAL TABULATION" is deprecated/ } @WARN;
+    print "ok 35\n";
+
+    no warnings 'deprecated';
+
+    print "not " unless "\N{VERTICAL TABULATION}" eq "\013";
+    print "ok 36\n";
+
+    print "not " if grep { /"VERTICAL TABULATION" is deprecated/ } @WARN;
+    print "ok 37\n";
+}
+
+print "not " unless charnames::viacode(0xFEFF) eq "ZERO WIDTH NO-BREAK SPACE";
+print "ok 38\n";
+
+{
+    use warnings;
+    print "not " unless ord("\N{BOM}") == 0xFEFF;
+    print "ok 39\n";
+}
+