File Coverage

blib/lib/Acme/MetaSyntactic/unicode.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package Acme::MetaSyntactic::unicode;
2 1     1   102021 use strict;
  1         4  
  1         52  
3 1     1   18 use Acme::MetaSyntactic::List;
  1         10  
  1         395  
4             our @ISA = qw( Acme::MetaSyntactic::List );
5             our $VERSION = '1.001';
6              
7             {
8             # a very basic list
9             my $data = join "\n",
10             map { ( "\t\tLATIN CAPITAL LETTER $_", "\t\tLATIN SMALL LETTER $_" ) }
11             'A' .. 'Z';
12              
13             # try to find better
14             if ( $] >= 5.006 && $] < 5.007003 ) {
15             eval { $data = require 'unicode/Name.pl'; };
16             }
17             elsif ( $] >= 5.007003 ) {
18             eval { $data = require 'unicore/Name.pl'; };
19              
20             # since v5.11.3, unicore/Name.pl creates subroutines
21             # they end up in our namespace, so get rid of them
22             undef *code_point_to_name_special;
23             undef *name_to_code_point_special;
24             }
25              
26             # clean up the list
27             my %seen;
28             $data = join ' ',
29             grep !$seen{$_}++, # we might have aliases/duplicates
30             map { s/ \(.*\)//; y/- /_/; $_ }
31             grep { $_ ne '' } # what's this for a character name?
32             map { my @F = split /\t+/; @F > 2 ? () : $F[1] } # remove blocks
33             split /\n/, $data;
34              
35             __PACKAGE__->init( { names => $data } );
36             }
37              
38             1;
39              
40             __END__