blib/lib/Unicode/Collate/CJK/Korean.pm

filter: Statementstmt 100% 30 / 30 Branchbran 80.0% 8 / 10 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 94.0% 47 / 50 CC 2 SCAR 3.4
CC
2
Cov
95%
weightKorean
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« blib/lib/Unicode/Collate/CJK/Zhuyin.pm ↑ Summary Collate.xs »
1 package Unicode::Collate::CJK::Korean;
2  
3 3 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 our $VERSION = '1.31';
8  
9 3 my %jamo2prim = (
10 '1100', 0x4175, '1101', 0x4176, '1102', 0x4177, '1103', 0x4178,
11 '1105', 0x417A, '1106', 0x417B, '1107', 0x417C, '1109', 0x417E,
12 '110A', 0x417F, '110B', 0x4180, '110C', 0x4181, '110E', 0x4183,
13 '110F', 0x4184, '1110', 0x4185, '1111', 0x4186, '1112', 0x4187,
14 '1161', 0x41F3, '1162', 0x41F4, '1163', 0x41F5, '1165', 0x41F7,
15 '1166', 0x41F8, '1167', 0x41F9, '1168', 0x41FA, '1169', 0x41FB,
16 '116A', 0x41FC, '116B', 0x41FD, '116C', 0x41FE, '116D', 0x41FF,
17 '116E', 0x4200, '116F', 0x4201, '1170', 0x4202, '1171', 0x4203,
18 '1172', 0x4204, '1173', 0x4205, '1174', 0x4206, '1175', 0x4207,
19 '11A8', 0x4251, '11AB', 0x4254, '11AF', 0x4258, '11B7', 0x4260,
20 '11B8', 0x4261, '11BC', 0x4265, '11BD', 0x4266,
21 ); # for DUCET v13.0.0
22  
23 3 my(%u2e, $prim, $wt);
24 3 ▶while (<DATA>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline DATA)) 4392 0 4392
25 4392 ▶ last if /^__END__/;
Branch: 1 branch
BranchTrueFalseTotal
if /^__END__/ 3 4389 4392
26 4389 my @c = split;
27 4389 ▶ if (@c == 1 && $c[0] =~ /^[A-D]/) { # hangul
Branch: 1 branch
BranchTrueFalseTotal
if (@c == 1 and $c[0] =~ /^[A-D]/) { } 1431 2958 4389
Condition100%3/3
@c == 1 and $c[0] =~ /^[A-D]/
!ll&&!rl&&r
27362221431
MC/DC100%2/2
@c == 1 and $c[0] =~ /^[A-D]/
@c == 1 $c[0] =~ /^[A-D]/
Truth table100%3/3
A and B
A= @c == 1B= $c[0] =~ /^[A-D]/
ABresult
0X0
100
111
28 1431 $c[0] =~ s/^.*://;
29 1431 $prim = [ map $jamo2prim{$_}, split /-/, $c[0] ];
30 1431 $wt = 0x20;
31 } else { # ideographs
32 2958 for my $c (@c) {
33 22428 ▶ next if !$c;
Branch: 1 branch
BranchTrueFalseTotal
unless $c 0 22428 22428
34 22428 $wt++;
35 22428 $u2e{hex($c)} = [ $wt, @$prim ];
36 }
37 }
38 }
39  
40 1184 ▶sub weightKorean {
Subroutine weightKorean: called CC=2 SCAR=6.9
Pod undocumented
41 1184 my $u = shift;
42 1184 ▶ return undef if !exists $u2e{$u};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $u2e{$u} 402 782 1184
43 782 my @a = @{ $u2e{$u} };
44 782 my $s = shift @a;
45 782 my $p = shift @a;
46 782 return([ $p, $s, 0x2, $u ], @a);
47 }
48  
49 3 1;
50  
51 # DATA format
52 # hangul syllable:jamo-jamo(-jamo)
53 # equiv. ideographs
54  
55 __DATA__
« blib/lib/Unicode/Collate/CJK/Zhuyin.pm ↑ Summary Collate.xs »