Mockify/Parameter.pm

filter: Statementstmt 100% 52 / 52 Branchbran 100% 14 / 14 Conditioncond 100% 13 / 13 MC/DCmcdc 100% 7 / 7 Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 5 totaltotal 95.1% 98 / 103 CC 13 SCAR 14.9
CC
13
Cov
100%
matchWithExpectedParameters
9.0
compareExpectedParameters
3.0
new
2.0
CRAP 4.4
« Mockify/Method.pm ↑ Summary Mockify/Tools.pm »
1 package Test::Mockify::Parameter;
2 19 ▶use Test::Mockify::ReturnValue;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 19 ▶use Data::Compare;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use Test::Mockify::TypeTests qw ( IsString );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 ▶use Scalar::Util qw(blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 19 ▶use Test::Mockify::Tools qw (Error);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 #---------------------------------------------------------------------
10 168 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
11 168 my $class = shift;
12 168 my ($ExpectedParams) = @_;
13 168 ▶ $ExpectedParams //= [];
Condition100%2/2
$ExpectedParams //= []
l!l
15216
MC/DC100%1/1
$ExpectedParams //= []
$ExpectedParams
Truth table100%2/2
A
A= $ExpectedParams
Aresult
11
00
14 168 my $self = bless {
15 'ExpectedParams' => $ExpectedParams,
16 }, $class;
17 168 return $self;
18 }
19 #---------------------------------------------------------------------
20 157 ▶sub call {
Subroutine call: called CC=2 SCAR=6.9
Pod undocumented
21 157 my $self = shift;
22 157 ▶ Error ('NoReturnValueDefined') unless ($self->{'ReturnValue'});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"ReturnValue"} 1 156 157
23 156 return $self->{'ReturnValue'}->call(@_);
24 }
25 #---------------------------------------------------------------------
26 152 ▶sub buildReturn {
Subroutine buildReturn: called CC=1 SCAR=0.0
Pod undocumented
27 152 my $self = shift;
28 152 $self->{'ReturnValue'} = Test::Mockify::ReturnValue->new();
29 152 return $self->{'ReturnValue'};
30 }
31 #---------------------------------------------------------------------
32 18 ▶sub compareExpectedParameters {
Subroutine compareExpectedParameters: called CC=3 SCAR=11.0
Pod undocumented
33 18 my $self = shift;
34 18 my ($Parameters) = @_;
35 18 ▶ $Parameters //= [];
Condition100%2/2
$Parameters //= []
l!l
171
MC/DC100%1/1
$Parameters //= []
$Parameters
Truth table100%2/2
A
A= $Parameters
Aresult
11
00
36 18 ▶ return 0 unless (scalar @{$Parameters} == scalar @{$self->{'ExpectedParams'}});
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$Parameters;} == scalar @{$self->{"ExpectedParams"};} 3 15 18
37 15 return Data::Compare->new()->Cmp($Parameters, $self->{'ExpectedParams'});
38 }
39 #---------------------------------------------------------------------
40 169 ▶sub matchWithExpectedParameters {
Subroutine matchWithExpectedParameters: called CC=9 SCAR=22.0
Pod undocumented
41 169 my $self = shift;
42 169 my @Params = @_;
43 169 ▶ return 0 unless (scalar @Params == scalar @{$self->{'ExpectedParams'}});
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @Params == scalar @{$self->{"ExpectedParams"};} 5 164 169
44  
45 164 ▶ for(my $i=0; $i < scalar @Params; $i++){## no critic (ProhibitCStyleForLoops) i need the counter
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @Params) 190 148 338
46 190 my $StoredValue = $self->{'ExpectedParams'}->[$i]->{'Value'};
47 190 ▶ if(not $StoredValue || (defined $StoredValue && "$StoredValue" eq '0')){ ## no critic (ProhibitMixedBooleanOperators )
Branch: 3 branches
BranchTrueFalseTotal
if (not $StoredValue || defined $StoredValue && "$StoredValue" eq '0') { } 63 127 190
elsif (builtin::blessed($Params[$i]) and $Params[$i]->isa($StoredValue)) { } 10 117 127
elsif ('Data::Compare'->new->Cmp($Params[$i], $StoredValue)) { } 101 16 117
Condition100%6/6
$StoredValue || defined $StoredValue && "$StoredValue" eq '0'
l!l&&r!l&&!r
124363
defined $StoredValue and "$StoredValue" eq 0
!ll&&!rl&&r
6213
MC/DC100%3/3
$StoredValue || defined $StoredValue && "$StoredValue" eq '0'
$StoredValue defined $StoredValue "$StoredValue" eq 0
Truth table100%4/4
A || B and C
A= $StoredValueB= defined $StoredValueC= "$StoredValue" eq 0
ABCresult
1XX1
0111
00X0
0100
48 63 next;
49 ▶ }elsif(blessed($Params[$i]) && $Params[$i]->isa($StoredValue)){# map package name
Condition100%3/3
builtin::blessed($Params[$i]) and $Params[$i]->isa($StoredValue)
!ll&&!rl&&r
116110
MC/DC100%2/2
builtin::blessed($Params[$i]) and $Params[$i]->isa($StoredValue)
builtin::blessed($Params[$i]) $Params[$i]->isa($StoredValue)
Truth table100%3/3
A and B
A= builtin::blessed($Params[$i])B= $Params[$i]->isa($StoredValue)
ABresult
0X0
100
111
50 10 next;
51 }elsif(Data::Compare->new()->Cmp($Params[$i], $StoredValue)){
52 101 next;
53 } else{
54 16 return 0;
55 }
56 }
57 148 return 1;
58 }
59  
60 19 1;
« Mockify/Method.pm ↑ Summary Mockify/Tools.pm »