Expr/EvaluatorRole.pm

filter: Statementstmt 96.9% 94 / 97 Branchbran 86.9% 40 / 46 Conditioncond 70.8% 17 / 24 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 85.6% 161 / 188 CC 34 SCAR 31.6
CC
34
Cov
90%
parse_dquotestr
32.0
parse_squotestr
6.0
BEGIN
1.0
CRAP 23.7
« Expr/JS.pm ↑ Summary Expr/Compiler/perl.pm »
1 package Language::Expr::EvaluatorRole;
2  
3 13 our $DATE = '2016-07-03'; # DATE
4 13 our $VERSION = '0.29'; # VERSION
5  
6 13 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 13 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 13 requires 'rule_pair_simple';
13 13 requires 'rule_pair_string';
14 13 requires 'rule_or_xor';
15 13 requires 'rule_ternary';
16 13 requires 'rule_and';
17 13 requires 'rule_bit_or_xor';
18 13 requires 'rule_bit_and';
19 13 requires 'rule_comparison3';
20 13 requires 'rule_comparison';
21 13 requires 'rule_bit_shift';
22 13 requires 'rule_add';
23 13 requires 'rule_mult';
24 13 requires 'rule_unary';
25 13 requires 'rule_power';
26 13 requires 'rule_subscripting_var';
27 13 requires 'rule_subscripting_expr';
28 13 requires 'rule_array';
29 13 requires 'rule_hash';
30 13 requires 'rule_undef';
31 13 requires 'rule_squotestr';
32 13 requires 'rule_dquotestr';
33 13 requires 'rule_var';
34 13 requires 'rule_func';
35 13 requires 'rule_func_map';
36 13 requires 'rule_func_grep';
37 13 requires 'rule_func_usort';
38 13 requires 'rule_bool';
39 13 requires 'rule_num';
40 13 requires 'rule_parenthesis';
41 13 requires 'expr_preprocess';
42 13 requires 'expr_postprocess';
43  
44 114 ▶sub parse_dquotestr {
Subroutine parse_dquotestr: called CC=29 SCAR=34.7
Pod documented
45 114 my ($self, @parts) = @_;
46 114 ▶ if (ref($parts[0]) eq 'ARRAY') { splice @parts, 0, 1, @{ $parts[0] } }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $parts[0] eq "ARRAY") 110 4 114
47 114 my @res;
48 my @sbuf;
49  
50 #say "D:parse_dquotestr:parts = ", join(", ", @parts);
51 #for (grep {defined} @parts) {
52 114 for (@parts) {
53 13 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 114 my $s01 = substr($_, 0, 1);
55 114 my $s02 = substr($_, 0, 2);
56 114 my $l = length();
57 114 ▶ if ($_ eq "\\'" ) { push @sbuf, "'" }
Branch: 15 branches
BranchTrueFalseTotal
if ($_ eq q[\\']) { } 2 112 114
elsif ($_ eq '\\"') { } 2 110 112
elsif ($_ eq '\\\\') { } 2 108 110
elsif ($_ eq '\\$') { } 2 106 108
elsif ($_ eq '\\t') { } 2 104 106
elsif ($_ eq '\\n') { } 2 102 104
elsif ($_ eq '\\f') { } 2 100 102
elsif ($_ eq '\\b') { } 2 98 100
elsif ($_ eq '\\a') { } 2 96 98
elsif ($_ eq '\\e') { } 2 94 96
elsif ($l >= 2 and $l <= 4 and $s01 eq '\\' and substr($_, 1, 1) >= '0' and substr($_, 1, 1) <= '7') { } 0 94 94
elsif ($l >= 3 and $l <= 4 and $s02 eq '\\x') { } 0 94 94
elsif ($l >= 5 and $l <= 8 and substr($_, 0, 3) eq '\\x{') { } 0 94 94
elsif ($s02 eq '${') { } 2 92 94
elsif ($s01 eq '$') { } 2 90 92
58 2 elsif ($_ eq "\\\"") { push @sbuf, '"' }
59 2 elsif ($_ eq "\\\\") { push @sbuf, "\\" }
60 2 elsif ($_ eq "\\\$") { push @sbuf, '$' }
61 2 elsif ($_ eq "\\t" ) { push @sbuf, "\t" }
62 2 elsif ($_ eq "\\n" ) { push @sbuf, "\n" }
63 2 elsif ($_ eq "\\f" ) { push @sbuf, "\f" }
64 2 elsif ($_ eq "\\b" ) { push @sbuf, "\b" }
65 2 elsif ($_ eq "\\a" ) { push @sbuf, "\a" }
66 2 elsif ($_ eq "\\e" ) { push @sbuf, "\e" }
67 ▶ elsif ($l >= 2 && $l <= 4 && $s01 eq "\\" &&
Condition58%7/12
$l >= 2 and $l <= 4 and $s01 eq "\\" and substr($_, 1, 1) >= 0 and substr($_, 1, 1) <= 7
!ll&&!rl&&r
9400
$l >= 2 and $l <= 4 and $s01 eq "\\" and substr($_, 1, 1) >= 0
!ll&&!rl&&r
9400
$l >= 2 and $l <= 4 and $s01 eq "\\"
!ll&&!rl&&r
56380
$l >= 2 and $l <= 4
!ll&&!rl&&r
48838
MC/DC0%0/5
$l >= 2 and $l <= 4 and $s01 eq "\\" and substr($_, 1, 1) >= 0 and substr($_, 1, 1) <= 7
$l >= 2 $l <= 4 $s01 eq "\\" substr($_, 1, 1) >= 0 substr($_, 1, 1) <= 7
Truth table50%3/6
A and B and C and D and E
A= $l >= 2B= $l <= 4C= $s01 eq "\\"D= substr($_, 1, 1) >= 0E= substr($_, 1, 1) <= 7
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
68 substr($_, 1, 1) >= "0" && substr($_, 1, 1) <= "7") {
69 # \000 octal escape
70 0 push @sbuf, chr(oct(substr($_, 1))) }
71 ▶ elsif ($l >= 3 && $l <= 4 && $s02 eq "\\x") {
Condition83%5/6
$l >= 3 and $l <= 4 and $s02 eq "\\x"
!ll&&!rl&&r
68260
$l >= 3 and $l <= 4
!ll&&!rl&&r
60826
MC/DC0%0/3
$l >= 3 and $l <= 4 and $s02 eq "\\x"
$l >= 3 $l <= 4 $s02 eq "\\x"
Truth table75%3/4
A and B and C
A= $l >= 3B= $l <= 4C= $s02 eq "\\x"
ABCresult
0XX0
10X0
1100
1111
72 # \xFF hex escape
73 0 push @sbuf, chr(hex(substr($_, 1))) }
74 ▶ elsif ($l >= 5 && $l <= 8 && substr($_, 0, 3) eq "\\x{") {
Condition83%5/6
$l >= 5 and $l <= 8 and substr($_, 0, 3) eq "\\x{"
!ll&&!rl&&r
8860
$l >= 5 and $l <= 8
!ll&&!rl&&r
8626
MC/DC0%0/3
$l >= 5 and $l <= 8 and substr($_, 0, 3) eq "\\x{"
$l >= 5 $l <= 8 substr($_, 0, 3) eq "\\x{"
Truth table75%3/4
A and B and C
A= $l >= 5B= $l <= 8C= substr($_, 0, 3) eq "\\x{"
ABCresult
0XX0
10X0
1100
1111
75 # \x{1234} wide hex escape
76 0 push @sbuf, chr(hex(substr($_, 3, length()-4))) }
77 elsif ($s02 eq '${') {
78 # ${var}
79 2 ▶ push @res, {type=>"STR", value=>join("", @sbuf)} if @sbuf; @sbuf=();
Branch: 1 branch
BranchTrueFalseTotal
if @sbuf 0 2 2
80 2 push @res, {type=>"VAR", value=>substr($_, 2, length()-3)} }
81 elsif ($s01 eq '$') {
82 # $var
83 2 ▶ push @res, {type=>"STR", value=>join("", @sbuf)} if @sbuf; @sbuf=();
Branch: 1 branch
BranchTrueFalseTotal
if @sbuf 0 2 2
84 2 push @res, {type=>"VAR", value=>substr($_, 1, length()-1)} }
85 else {
86 90 push @sbuf, $_;
87 }
88 }
89 114 ▶ push @res, {type=>"STR", value=>join("", grep {defined} @sbuf)} if @sbuf;
Branch: 1 branch
BranchTrueFalseTotal
if @sbuf 110 4 114
90 114 \@res;
91 }
92  
93 20 ▶sub parse_squotestr {
Subroutine parse_squotestr: called CC=6 SCAR=17.9
Pod documented
94 20 my ($self, @parts) = @_;
95 20 ▶ if (ref($parts[0]) eq 'ARRAY') { splice @parts, 0, 1, @{ $parts[0] } }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $parts[0] eq "ARRAY") 18 2 20
96 20 my @res;
97 my @sbuf;
98  
99 #say "D:parse_dquotestr:parts = ", join(", ", @parts);
100 #for (grep {defined} @parts) {
101 20 for (@parts) {
102 13 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
103 24 ▶ if ($_ eq "\\'" ) { push @sbuf, "'" }
Branch: 2 branches
BranchTrueFalseTotal
if ($_ eq q[\\']) { } 2 22 24
elsif ($_ eq '\\\\') { } 2 20 22
104 2 elsif ($_ eq "\\\\") { push @sbuf, "\\" }
105 20 else { push @sbuf, $_ }
106 }
107 20 ▶ push @res, {type=>"STR", value=>join("", grep {defined} @sbuf)} if @sbuf;
Branch: 1 branch
BranchTrueFalseTotal
if @sbuf 20 0 20
108 20 \@res;
109 }
110  
111 13 1;
112 # ABSTRACT: Specification for Language::Expr interpreter/compiler
113  
114 __END__
« Expr/JS.pm ↑ Summary Expr/Compiler/perl.pm »