Smart/Renderer/Test2.pm

filter: Statementstmt 100% 20 / 20 Branchbran 100% 8 / 8 Conditioncond 75.0% 6 / 8 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 88.6% 39 / 44 CC 10 SCAR 21.4
CC
10
Cov
94%
render
10.0
BEGIN
1.0
BEGIN
1.0
CRAP 8.5
« Smart/Engine.pm ↑ Summary Smart/Renderer/Text.pm »
1 package Data::Hash::Diff::Smart::Renderer::Test2;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 47 ▶sub render {
Subroutine render: called CC=10 SCAR=23.1
Pod undocumented
7 47 my ($changes) = @_;
8  
9 47 ▶ return '' unless @$changes;
Branch: 1 branch
BranchTrueFalseTotal
unless @$changes 9 38 47
10  
11 38 my @out;
12  
13 38 for my $c (@$changes) {
14 47 my $op = $c->{op};
15 47 my $path = $c->{path};
16  
17 47 ▶ if ($op eq 'change') {
Branch: 3 branches
BranchTrueFalseTotal
if ($op eq 'change') { } 27 20 47
elsif ($op eq 'add') { } 10 10 20
elsif ($op eq 'remove') { } 8 2 10
18 push @out,
19 "Difference at $path",
20 ' - ' . ($c->{from} // ''),
21 27 ▶ ' + ' . ($c->{to} // ''),
Condition75%3/4
$c->{"from"} // ""
l!l
261
$c->{"to"} // ""
l!l
270
MC/DC100%1/1
$c->{"from"} // ""
$c->{"from"}
MC/DC0%0/1
$c->{"to"} // ""
$c->{"to"}
Truth table100%2/2
A
A= $c->{"from"}
Aresult
11
00
Truth table50%1/2
A
A= $c->{"to"}
Aresult
11
00
22 '';
23 } elsif ($op eq 'add') {
24 push @out,
25 "Added at $path",
26 10 ▶ ' + ' . ($c->{value} // ''),
Condition50%1/2
$c->{"value"} // ""
l!l
100
MC/DC0%0/1
$c->{"value"} // ""
$c->{"value"}
Truth table50%1/2
A
A= $c->{"value"}
Aresult
11
00
27 '';
28 } elsif ($op eq 'remove') {
29 push @out,
30 "Removed at $path",
31 8 ▶ ' - ' . ($c->{from} // ''),
Condition100%2/2
$c->{"from"} // ""
l!l
71
MC/DC100%1/1
$c->{"from"} // ""
$c->{"from"}
Truth table100%2/2
A
A= $c->{"from"}
Aresult
11
00
32 '';
33 } else {
34 2 push @out, "Unknown op '$op' at $path";
35 }
36 }
37  
38 # Prefix each line with '# ' so Test2::Diag displays it cleanly
39 38 return join("\n", map { "# $_" } @out) . "\n";
40 }
41  
42 6 1;
« Smart/Engine.pm ↑ Summary Smart/Renderer/Text.pm »