DBus/Signature.pm

filter: Statementstmt 100% 30 / 30 Branchbran 92.8% 13 / 14 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 94.5% 52 / 55 SCAR 22.0
CC
9
Cov
98%
get_sct_length
8.0
split
2.0
BEGIN
1.0
CRAP 9.0
« DBus/Peer.pm ↑ Summary DBus/Message/Header.pm »
1 package Protocol::DBus::Signature;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # Returns a list of single complete types (SCTs).
7  
8 sub split {
9 164 ▶ my ($sig) = @_;
Subroutine split: called CC=2 SCAR=6.9
Pod undocumented
10  
11 164 my @scts;
12  
13 164 ▶ while (length($sig)) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $sig) 211 164 375
14 211 my $next_sct_len = Protocol::DBus::Signature::get_sct_length($sig, 0);
15 211 push @scts, substr( $sig, 0, $next_sct_len, q<> );
16 }
17  
18 164 return @scts;
19 }
20  
21 # Returns the length of the single complete type at $sct_offset.
22  
23 sub get_sct_length {
24 740 ▶ my ($sig, $sct_offset) = @_;
Subroutine get_sct_length: called CC=8 SCAR=20.8
Pod undocumented
25  
26 740 my $start = $sct_offset;
27  
28 740 my $next = substr($sig, $sct_offset, 1);
29  
30 740 ▶ if ($next eq 'a') {
Branch: 1 branch
BranchTrueFalseTotal
if ($next eq "a") 114 626 740
31  
32 # “{ }” only happens after “a”
33 114 my $next_2nd = substr($sig, 1 + $sct_offset, 1);
34 114 ▶ if ($next_2nd eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($next_2nd eq "{") 36 78 114
35  
36 # 4 for the “a”, “{”, key type, and “}”.
37 # We assume that the signature is well-formed.
38 36 return 4 + get_sct_length($sig, 3 + $sct_offset);
39 }
40  
41 78 return 1 + get_sct_length($sig, 1 + $sct_offset);
42 }
43  
44 626 ▶ if ($next eq '(') {
Branch: 1 branch
BranchTrueFalseTotal
if ($next eq "(") 52 574 626
45 52 while (1) {
46 160 $sct_offset++;
47  
48 160 ▶ last if $sct_offset >= length($sig);
Branch: 1 branch
BranchTrueFalseTotal
if $sct_offset >= length $sig 0 160 160
49  
50 160 my $next_in_struct = substr($sig, $sct_offset, 1);
51  
52 160 ▶ if ($next_in_struct eq '(' || $next_in_struct eq 'a') {
Branch: 2 branches
BranchTrueFalseTotal
if ($next_in_struct eq '(' or $next_in_struct eq 'a') { } 18 142 160
elsif ($next_in_struct eq ')') { } 52 90 142
Condition100%3/3
$next_in_struct eq "(" or $next_in_struct eq "a"
l!l&&r!l&&!r
108142
MC/DC100%2/2
$next_in_struct eq "(" or $next_in_struct eq "a"
$next_in_struct eq "(" $next_in_struct eq "a"
Truth table100%3/3
A or B
A= $next_in_struct eq "("B= $next_in_struct eq "a"
ABresult
1X1
011
000
53 18 $sct_offset += get_sct_length($sig, $sct_offset) - 1;
54 }
55 elsif ($next_in_struct eq ')') {
56 52 last;
57 }
58 }
59 }
60  
61 626 return 1 + ($sct_offset - $start);
62 }
63  
64 8 1;
« DBus/Peer.pm ↑ Summary DBus/Message/Header.pm »