blib/lib/Lingua/SWE/Num2Word.pm

filter: Statementstmt 79.0% 34 / 43 Branchbran 45.8% 11 / 24 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 68.2% 56 / 82 CC 15 SCAR 32.1
CC
15
Cov
67%
num2sv_cardinal
32.7
BEGIN
1.0
BEGIN
1.0
CRAP 24.8
↑ Summary
1 # For Emacs: -*- mode:cperl; eval: (folding-mode 1); -*-
2  
3 package Lingua::SWE::Num2Word;
4 # ABSTRACT: Number to word conversion in Swedish
5  
6 1 ▶use 5.16.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # {{{ use block
11  
12 1 ▶use Export::Attrs;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # }}}
15 # {{{ variables declaration
16 1 our $VERSION = '0.2603260';
17  
18 # }}}
19 # {{{ num2sv_cardinal convert number to text
20  
21 sub num2sv_cardinal :Export {
22 8 ▶ my $positive = shift // return 'noll';
Subroutine num2sv_cardinal: called CC=15 SCAR=34.9
Pod documented
Condition100%2/2
shift() // (return "noll")
l!l
71
MC/DC100%1/1
shift() // (return "noll")
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
23  
24 7 ▶ return if ($positive < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $positive < 0 0 7 7
25  
26 7 my $out;
27 7 my @tokens1 = qw(noll ett två tre fyra fem sex sju åtta nio tio elva
28 tolv tretton fjorton femton sexton sjutton arton nitton); # 0-19 Cardinals
29 7 my @tokens2 = qw(tjugo trettio fyrtio femtio sextio sjutio åttio nittio); # 20-90 Cardinals (end with zero)
30  
31 7 ▶ return $tokens1[$positive] if($positive < 20); # interval 0 - 19
Branch: 1 branch
BranchTrueFalseTotal
if $positive < 20 2 5 7
32  
33 5 ▶ if($positive < 100) { # interval 20 - 99
Branch: 4 branches
BranchTrueFalseTotal
if ($positive < 100) { } 0 5 5
elsif ($positive < 1000) { } 3 2 5
elsif ($positive < 1000000) { } 2 0 2
elsif ($positive < 1000000000) { } 0 0 0
34 0 my @num = split '',$positive;
35  
36 0 $out = $tokens2[$num[0]-2];
37 0 ▶ $out .= $tokens1[$num[1]] if ($num[1]);
Branch: 1 branch
BranchTrueFalseTotal
if $num[1] 0 0 0
38 } elsif($positive < 1000) { # interval 100 - 999
39 3 my @num = split '',$positive;
40  
41 3 $out = $tokens1[$num[0]].'hundra';
42  
43 3 ▶ if ((int $num[1].$num[2]) < 20 && (int $num[1].$num[2])>0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (int $num[1] . $num[2] < 20 and int $num[1] . $num[2] > 0) { } 0 3 3
Condition33%1/3
int $num[1] . $num[2] < 20 and int $num[1] . $num[2] > 0
!ll&&!rl&&r
300
MC/DC0%0/2
int $num[1] . $num[2] < 20 and int $num[1] . $num[2] > 0
int $num[1] . $num[2] < 20 int $num[1] . $num[2] > 0
Truth table33%1/3
A and B
A= int $num[1] . $num[2] < 20B= int $num[1] . $num[2] > 0
ABresult
0X0
100
111
44 0 $out .= &num2sv_cardinal(int $num[1].$num[2]);
45 } else {
46 3 ▶ $out .= $tokens2[$num[1]-2] if($num[1]);
Branch: 1 branch
BranchTrueFalseTotal
if $num[1] 3 0 3
47 3 ▶ $out .= $tokens1[$num[2]] if($num[2]);
Branch: 1 branch
BranchTrueFalseTotal
if $num[2] 3 0 3
48 }
49 } elsif($positive < 1000_000) { # interval 1000 - 999_999
50 2 my @num = split '',$positive;
51 2 my @sub = splice @num,-3;
52  
53 2 $out = &num2sv_cardinal(int join '',@num);
54 2 $out .= 'tusen';
55 2 ▶ $out .= &num2sv_cardinal(int join '',@sub) if (int(join "",@sub) >0);
Branch: 1 branch
BranchTrueFalseTotal
if int join("", @sub) > 0 2 0 2
56 } elsif($positive < 1_000_000_000) { # interval 1_000_000 - 999_999_999
57 0 my @num = split '',$positive;
58 0 my @sub = splice @num,-6;
59  
60 0 $out = &num2sv_cardinal(int join '',@num);
61 0 $out .= ' miljoner ';
62 0 ▶ $out .= &num2sv_cardinal(int join '',@sub) if (int(join "",@sub) >0);
Branch: 1 branch
BranchTrueFalseTotal
if int join("", @sub) > 0 0 0 0
63 }
64  
65 5 return $out;
66 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
67  
68 # }}}
69  
70 1 1;
71  
72 __END__
↑ Summary