assign/Struct.pm

filter: Statementstmt 96.0% 48 / 50 Branchbran 70.8% 17 / 24 Conditioncond 66.6% 8 / 12 MC/DCmcdc 28.5% 2 / 7 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 4 totaltotal 78.8% 82 / 104 CC 18 SCAR 18.1
CC
18
Cov
85%
parse
8.2
get_var
7.2
parse_comma
5.5
CRAP 6.1
« assign/Array.pm ↑ Summary assign/0.pm »
1 6 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package assign::Struct;
3  
4 6 ▶use XXX;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 26 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
7 26 my $class = shift;
8 26 bless {
9 elems => [],
10 @_,
11 }, $class;
12 }
13  
14 26 ▶sub parse {
Subroutine parse: called CC=8 SCAR=21.0
Pod undocumented
15 26 my ($self) = @_;
16  
17 26 my $node = $self->{node};
18 26 my $statement;
19 26 for my $child ($node->children) {
20 59 my $type = ref($child);
21 59 ▶ if ($type eq 'PPI::Token::Whitespace') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "PPI::Token::Whitespace") 33 26 59
22 33 next;
23 }
24 26 ▶ if ($type eq 'PPI::Statement') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "PPI::Statement") 26 0 26
25 26 ▶ XXX $node, "more than one statement"
Branch: 1 branch
BranchTrueFalseTotal
if $statement 0 26 26
26 if $statement;
27 26 $statement = $child;
28 26 next;
29 }
30 0 XXX $node, "unexpected node";
31 }
32  
33 26 ▶ XXX $node, "no statement in array"
Branch: 1 branch
BranchTrueFalseTotal
unless $statement 0 26 26
34 unless $statement;
35  
36 26 $self->{in} = [ $statement->children ];
37  
38 26 while (1) {
39 80 ▶ $self->parse_elem or last;
Branch: 1 branch
BranchTrueFalseTotal
$self->parse_elem or last 77 3 80
40 77 ▶ $self->parse_comma or last;
Branch: 1 branch
BranchTrueFalseTotal
$self->parse_comma or last 54 23 77
41 }
42  
43 26 return $self;
44 }
45  
46 77 ▶sub parse_comma {
Subroutine parse_comma: called CC=5 SCAR=17.0
Pod undocumented
47 77 my ($self) = @_;
48 77 my $in = $self->{in};
49 77 ▶ while (@$in) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$in) 54 23 77
50 54 my $tok = shift(@$in);
51 54 my $type = ref($tok);
52 54 ▶ next if $type eq 'PPI::Token::Whitespace';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "PPI::Token::Whitespace" 0 54 54
53  
54 54 ▶ if ($type eq 'PPI::Token::Operator' and
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'PPI::Token::Operator' and $tok->content eq ',') { } 54 0 54
Condition33%1/3
$type eq "PPI::Token::Operator" and $tok->content eq ","
!ll&&!rl&&r
0054
MC/DC0%0/2
$type eq "PPI::Token::Operator" and $tok->content eq ","
$type eq "PPI::Token::Operator" $tok->content eq ","
Truth table33%1/3
A and B
A= $type eq "PPI::Token::Operator"B= $tok->content eq ","
ABresult
0X0
100
111
55 $tok->content eq ','
56 ) {
57 54 return 1;
58 }
59 else {
60 0 XXX $tok, $in, "comma expected";
61 }
62 }
63 23 return 0;
64 }
65  
66 63 ▶sub get_var {
Subroutine get_var: called CC=7 SCAR=19.7
Pod undocumented
67 63 my ($self, $var) = @_;
68 63 my $def;
69 63 my $in = $self->{in};
70 63 ▶ if (@$in > 1 and
Branch: 1 branch
BranchTrueFalseTotal
if (@$in > 1 and ref $in->[0] eq "PPI::Token::Operator" and $in->[0]->content eq "=") 4 59 63
Condition83%5/6
@$in > 1 and ref $in->[0] eq "PPI::Token::Operator" and $in->[0]->content eq "="
!ll&&!rl&&r
22374
@$in > 1 and ref $in->[0] eq "PPI::Token::Operator"
!ll&&!rl&&r
22041
MC/DC66%2/3
@$in > 1 and ref $in->[0] eq "PPI::Token::Operator" and $in->[0]->content eq "="
@$in > 1 ref $in->[0] eq "PPI::Token::Operator" $in->[0]->content eq "="
Truth table75%3/4
A and B and C
A= @$in > 1B= ref $in->[0] eq "PPI::Token::Operator"C= $in->[0]->content eq "="
ABCresult
0XX0
10X0
1100
1111
71 ref($in->[0]) eq 'PPI::Token::Operator' and
72 $in->[0]->content eq '='
73 ) {
74 4 shift @$in;
75 4 my $d = shift @$in;
76 4 ▶ XXX $d, "Invalid token for variable default"
Branch: 1 branch
BranchTrueFalseTotal
unless ref($d) =~ /^PPI::Token::(Number|Symbol|Quote::(Single|Double))$/ 0 4 4
77 unless ref($d) =~
78 /^PPI::Token::(Number|Symbol|Quote::(Single|Double))$/;
79 4 $def = $d->content;
80 4 ▶ XXX $d, "Invalid token for variable default"
Branch: 1 branch
BranchTrueFalseTotal
if ref $d eq "PPI::Token::Symbol" and not $def =~ /^\$\w+$/ 0 4 4
Condition66%2/3
ref $d eq "PPI::Token::Symbol" and not $def =~ /^\$\w+$/
!ll&&!rl&&r
310
MC/DC0%0/2
ref $d eq "PPI::Token::Symbol" and not $def =~ /^\$\w+$/
ref $d eq "PPI::Token::Symbol" not $def =~ /^\$\w+$/
Truth table66%2/3
A and not(B)
A= ref $d eq "PPI::Token::Symbol"B= not $def =~ /^\$\w+$/
ABresult
0X0
100
111
81 if ref($d) eq 'PPI::Token::Symbol' and
82 $def !~ /^\$\w+$/;
83 }
84 63 assign::var->new($var, $def);
85 }
86  
87 6 1;
« assign/Array.pm ↑ Summary assign/0.pm »