ROP/Imp.pm

filter: Statementstmt 81.6% 40 / 49 Branchbran 80.0% 16 / 20 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 2 totaltotal 80.4% 66 / 82 SCAR 25.5
CC
12
Cov
82%
_wrap_call_with_dollar
12.0
_then_hash
6.0
_then_list
4.0
CRAP 12.8
↑ Summary ROP.pm »
1 package Error::ROP::Imp;
2 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 5 has value => (is => 'ro', required => 0, default => undef);
5 5 has failure => (is => 'ro', required => 0, default => '');
6  
7 sub is_valid {
8 46 ▶ return shift->failure eq '';
Subroutine is_valid: called CC=1 SCAR=0.0
Pod undocumented
9 }
10  
11 sub _then_hash {
12 13 ▶ my ($self, @then_clauses) = @_;
Subroutine _then_hash: called CC=6 SCAR=17.9
13 13 my $either = $self;
14  
15 13 my $length = @then_clauses / 2;
16 13 ▶ for(my $i = 0; $i < $length; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $length) 15 10 25
17 15 my $err = $then_clauses[2 * $i];
18 15 my $fn = $then_clauses[2 * $i + 1];
19 15 ▶ if ($either->is_valid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($either->is_valid) 12 3 15
20 12 local $_ = $either->value;
21 12 my $res = eval {
22 12 $fn->($_);
23 };
24 12 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 3 9 12
25 3 ▶ my $msg = length $err > 0 && $err ne 'undef' ? $err : $@;
Branch: 1 branch
BranchTrueFalseTotal
length $err > 0 && $err ne 'undef' ? : 1 2 3
Condition100%3/3
length $err > 0 and $err ne "undef"
!ll&&!rl&&r
111
MC/DC100%2/2
length $err > 0 and $err ne "undef"
length $err > 0 $err ne "undef"
Truth table100%3/3
A and B
A= length $err > 0B= $err ne "undef"
ABresult
0X0
100
111
26 3 return Error::ROP::Imp->new(failure => $msg);
27 }
28 9 $either = Error::ROP::Imp->new(value => $res);
29 }
30 }
31  
32 10 return $either;
33 }
34  
35 sub _then_list {
36 7 ▶ my ($self, @then_clauses) = @_;
Subroutine _then_list: called CC=4 SCAR=13.9
37 7 my $either = $self;
38  
39 7 my $length = @then_clauses;
40 7 ▶ for(my $i = 0; $i < $length; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $length) 7 5 12
41 7 my $fn = $then_clauses[$i];
42 7 ▶ if ($either->is_valid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($either->is_valid) 3 4 7
43 3 local $_ = $either->value;
44 3 my $res = eval {
45 3 $fn->($_);
46 };
47 3 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 2 1 3
48 2 return Error::ROP::Imp->new(failure => $@);
49 }
50 1 $either = Error::ROP::Imp->new(value => $res);
51 }
52 }
53  
54 5 return $either;
55 }
56  
57 sub _wrap_call_with_dollar {
58 0 ▶ my $either = shift;
Subroutine _wrap_call_with_dollar: not called CC=3 SCAR=24.8
59 0 my $fn = shift;
60 0 ▶ if ($either->is_valid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($either->is_valid) 0 0 0
61 0 local $_ = $either->value;
62 0 my $res = eval {
63 0 $fn->($_);
64 };
65 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
66 0 return Error::ROP::Imp->new(failure => $@);
67 }
68 0 $either = Error::ROP::Imp->new(value => $res);
69 }
70 }
71  
72 sub then {
73 20 ▶ my ($self, @then_clauses) = @_;
Subroutine then: called CC=2 SCAR=6.9
Pod undocumented
74  
75 20 ▶ if((scalar @then_clauses) % 2 == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar(@then_clauses) % 2 == 0) { } 13 7 20
76 13 $self->_then_hash(@then_clauses);
77 }
78 else {
79 7 $self->_then_list(@then_clauses);
80 }
81 }
82  
83 5 __PACKAGE__->meta->make_immutable;
84 5 1;
↑ Summary ROP.pm »