Subs/Text.pm

filter: Statementstmt 100% 41 / 41 Branchbran 75.0% 15 / 20 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 91.2% 73 / 80 CC 13 SCAR 22.1
CC
13
Cov
91%
text
13.5
BEGIN
1.0
BEGIN
1.0
CRAP 9.1
« Subs/HTML.pm ↑ Summary Subs.pm »
1 package Devel::Trace::Subs::Text;
2 4 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 our $VERSION = '0.24';
11 4 our @ISA = qw(Exporter);
12 4 our @EXPORT_OK = qw(text);
13  
14 4 my ($stack_tpl, $flow_tpl, $all_tpl);
15  
16 13 ▶sub text {
Subroutine text: called CC=13 SCAR=26.0
Pod documented
17  
18 13 my %p = @_;
19  
20 13 my $file = $p{file};
21 13 my $want = $p{want};
22 13 my $data = $p{data};
23  
24 13 ▶ if ($want && $want eq 'stack') {
Branch: 2 branches
BranchTrueFalseTotal
if ($want and $want eq 'stack') { } 4 9 13
elsif ($want and $want eq 'flow') { } 4 5 9
Condition100%3/3
$want and $want eq "stack"
!ll&&!rl&&r
544
MC/DC100%2/2
$want and $want eq "stack"
$want $want eq "stack"
Truth table100%3/3
A and B
A= $wantB= $want eq "stack"
ABresult
0X0
100
111
25  
26 4 my $template = Template->new;
27  
28 4 ▶ if ($file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file) { } 3 1 4
29  
30 3 ▶ $template->process(
Branch: 1 branch
BranchTrueFalseTotal
$template->process(\$stack_tpl, {"stack", $data}, $file) or die $template->error 3 0 3
31 \$stack_tpl,
32 {stack => $data},
33 $file
34 ) || die $template->error;
35 }
36 else {
37 1 ▶ $template->process(
Branch: 1 branch
BranchTrueFalseTotal
$template->process(\$stack_tpl, {"stack", $data}) or die $template->error 1 0 1
38 \$stack_tpl,
39 {stack => $data},
40 ) || die $template->error;
41 }
42 }
43 ▶ elsif ($want && $want eq 'flow') {
Condition66%2/3
$want and $want eq "flow"
!ll&&!rl&&r
504
MC/DC50%1/2
$want and $want eq "flow"
$want $want eq "flow"
Truth table66%2/3
A and B
A= $wantB= $want eq "flow"
ABresult
0X0
100
111
44  
45 4 my $template = Template->new;
46  
47 4 ▶ if ($file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file) { } 3 1 4
48  
49 3 ▶ $template->process(
Branch: 1 branch
BranchTrueFalseTotal
$template->process(\$flow_tpl, {"flow", $data}, $file) or die $template->error 3 0 3
50 \$flow_tpl,
51 {flow => $data},
52 $file
53 ) || die $template->error;
54 }
55 else {
56 1 ▶ $template->process(
Branch: 1 branch
BranchTrueFalseTotal
$template->process(\$flow_tpl, {"flow", $data}) or die $template->error 1 0 1
57 \$flow_tpl,
58 {flow => $data}
59 ) || die $template->error;
60 }
61 }
62 else {
63 5 my $template = Template->new;
64  
65 5 ▶ if ($file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file) { } 4 1 5
66  
67 4 ▶ $template->process(
Branch: 1 branch
BranchTrueFalseTotal
$template->process(\$all_tpl, $data, $file) or die $template->error 4 0 4
68 \$all_tpl,
69 $data,
70 $file,
71 ) || die $template->error;
72 }
73 else {
74 $template->process(\$all_tpl, {
75 flow => $data->{flow},
76 stack => $data->{stack},
77 1 });
78 }
79 }
80 }
81  
82 4 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
83  
84 4 $flow_tpl = <<EOF;
85  
86 Code flow:
87  
88 [% FOREACH entry IN flow -%]
89 [% entry.name %]: [% entry.value %]
90 [% END %]
91 EOF
92  
93 4 $stack_tpl = <<EOF;
94  
95 Stack trace:
96  
97 [%- FOREACH entry IN stack %]
98 in: [% entry.in %]
99 sub: [% entry.sub %]
100 file: [% entry.filename %]
101 line: [% entry.line %]
102 package: [% entry.package %]
103 [% END %]
104 EOF
105  
106 4 $all_tpl = <<EOF;
107  
108 Code flow:
109  
110 [% FOREACH entry IN flow -%]
111 [% entry.name %]: [% entry.value %]
112 [% END %]
113 Stack trace:
114  
115 [%- FOREACH entry IN stack %]
116 in: [% entry.in %]
117 sub: [% entry.sub %]
118 file: [% entry.filename %]
119 line: [% entry.line %]
120 package: [% entry.package %]
121 [% END %]
122 EOF
123 }
124 __END__
« Subs/HTML.pm ↑ Summary Subs.pm »