blib/lib/CBOR/Free/AddOne.pm

filter: Statementstmt 100% 18 / 18 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 90.3% 28 / 31 CC 5 SCAR 13.5
CC
5
Cov
96%
to_nonnegative_integer
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.9
↑ Summary blib/lib/CBOR/Free/X/CannotDecode64Bit.pm »
1 package CBOR::Free::AddOne;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # Hard to believe there’s not some simple module out there
7 # that already does this.
8  
9 sub to_nonnegative_integer {
10 103 ▶ my @digits = unpack '(a)*', shift();
Subroutine to_nonnegative_integer: called CC=5 SCAR=16.1
Pod undocumented
11  
12 103 my $done;
13  
14 103 my $carry = 1;
15  
16 103 for my $d ( reverse( 0 .. $#digits ) ) {
17 107 $digits[$d] += $carry;
18 107 $carry = 0;
19  
20 107 ▶ if ($digits[$d] > 9) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digits[$d] > 9) 5 102 107
21 5 $carry = $digits[$d] - 9;
22 5 $digits[$d] = 0;
23 }
24  
25 107 ▶ last if !$carry;
Branch: 1 branch
BranchTrueFalseTotal
unless $carry 102 5 107
26 }
27  
28 103 ▶ return join( q<>, $carry || (), @digits );
Condition66%2/3
$carry || ()
l!l&&r!l&&!r
10102
MC/DC50%1/2
$carry || ()
$carry ()
Truth table66%2/3
A || B
A= $carryB= ()
ABresult
1X1
011
000
29 }
30  
31 2 1;
↑ Summary blib/lib/CBOR/Free/X/CannotDecode64Bit.pm »