blib/lib/CBOR/Free/AddOne.pm

filter: Statementstmt 100% 18 / 18 Branchbran 100% 4 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 83.8% 26 / 31 CC 5 SCAR 13.6
CC
5
Cov
92%
to_nonnegative_integer
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.9
« blib/lib/CBOR/Free/Decoder/Base.pm ↑ 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 103 ▶sub to_nonnegative_integer {
Subroutine to_nonnegative_integer: called CC=5 SCAR=16.2
Pod undocumented
10 103 my @digits = unpack '(a)*', shift();
11  
12 103 my $done;
13  
14 103 my $carry = 1;
15  
16 103 for my $d ( reverse( 0 .. $#digits ) ) {
17 113 $digits[$d] += $carry;
18 113 $carry = 0;
19  
20 113 ▶ if ($digits[$d] > 9) {
Branch: 1 branch
BranchTrueFalseTotal
if ($digits[$d] > 9) 10 103 113
21 10 $carry = $digits[$d] - 9;
22 10 $digits[$d] = 0;
23 }
24  
25 113 ▶ last if !$carry;
Branch: 1 branch
BranchTrueFalseTotal
unless $carry 103 10 113
26 }
27  
28 103 ▶ return join( q<>, $carry || (), @digits );
Condition33%1/3
$carry || ()
l!l&&r!l&&!r
00103
MC/DC0%0/2
$carry || ()
$carry ()
Truth table33%1/3
A || B
A= $carryB= ()
ABresult
1X1
011
000
29 }
30  
31 2 1;
« blib/lib/CBOR/Free/Decoder/Base.pm ↑ Summary blib/lib/CBOR/Free/X/CannotDecode64Bit.pm »