line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mockify::Parameter; |
2
|
19
|
|
|
19
|
|
72746
|
use Test::Mockify::ReturnValue; |
|
19
|
|
|
|
|
53
|
|
|
19
|
|
|
|
|
532
|
|
3
|
19
|
|
|
19
|
|
8139
|
use Data::Compare; |
|
19
|
|
|
|
|
191260
|
|
|
19
|
|
|
|
|
129
|
|
4
|
19
|
|
|
19
|
|
69399
|
use Test::Mockify::TypeTests qw ( IsString ); |
|
19
|
|
|
|
|
46
|
|
|
19
|
|
|
|
|
937
|
|
5
|
19
|
|
|
19
|
|
154
|
use Scalar::Util qw(blessed ); |
|
19
|
|
|
|
|
39
|
|
|
19
|
|
|
|
|
847
|
|
6
|
19
|
|
|
19
|
|
117
|
use Test::Mockify::Tools qw (Error); |
|
19
|
|
|
|
|
35
|
|
|
19
|
|
|
|
|
736
|
|
7
|
19
|
|
|
19
|
|
108
|
use strict; |
|
19
|
|
|
|
|
38
|
|
|
19
|
|
|
|
|
429
|
|
8
|
19
|
|
|
19
|
|
99
|
use warnings; |
|
19
|
|
|
|
|
39
|
|
|
19
|
|
|
|
|
8141
|
|
9
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
sub new { |
11
|
168
|
|
|
168
|
0
|
4916
|
my $class = shift; |
12
|
168
|
|
|
|
|
286
|
my ($ExpectedParams) = @_; |
13
|
168
|
|
100
|
|
|
397
|
$ExpectedParams //= []; |
14
|
168
|
|
|
|
|
422
|
my $self = bless { |
15
|
|
|
|
|
|
|
'ExpectedParams' => $ExpectedParams, |
16
|
|
|
|
|
|
|
}, $class; |
17
|
168
|
|
|
|
|
371
|
return $self; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
20
|
|
|
|
|
|
|
sub call { |
21
|
157
|
|
|
157
|
0
|
336
|
my $self = shift; |
22
|
157
|
100
|
|
|
|
341
|
Error ('NoReturnValueDefined') unless ($self->{'ReturnValue'}); |
23
|
156
|
|
|
|
|
459
|
return $self->{'ReturnValue'}->call(@_); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
26
|
|
|
|
|
|
|
sub buildReturn { |
27
|
152
|
|
|
152
|
0
|
223
|
my $self = shift; |
28
|
152
|
|
|
|
|
469
|
$self->{'ReturnValue'} = Test::Mockify::ReturnValue->new(); |
29
|
152
|
|
|
|
|
741
|
return $self->{'ReturnValue'}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
32
|
|
|
|
|
|
|
sub compareExpectedParameters { |
33
|
18
|
|
|
18
|
0
|
972
|
my $self = shift; |
34
|
18
|
|
|
|
|
36
|
my ($Parameters) = @_; |
35
|
18
|
|
100
|
|
|
47
|
$Parameters //= []; |
36
|
18
|
100
|
|
|
|
31
|
return 0 unless (scalar @{$Parameters} == scalar @{$self->{'ExpectedParams'}}); |
|
18
|
|
|
|
|
35
|
|
|
18
|
|
|
|
|
63
|
|
37
|
15
|
|
|
|
|
93
|
return Data::Compare->new()->Cmp($Parameters, $self->{'ExpectedParams'}); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
40
|
|
|
|
|
|
|
sub matchWithExpectedParameters { |
41
|
169
|
|
|
169
|
0
|
278
|
my $self = shift; |
42
|
169
|
|
|
|
|
291
|
my @Params = @_; |
43
|
169
|
100
|
|
|
|
224
|
return 0 unless (scalar @Params == scalar @{$self->{'ExpectedParams'}}); |
|
169
|
|
|
|
|
511
|
|
44
|
|
|
|
|
|
|
|
45
|
164
|
|
|
|
|
457
|
for(my $i=0; $i < scalar @Params; $i++){## no critic (ProhibitCStyleForLoops) i need the counter |
46
|
190
|
|
|
|
|
302
|
my $StoredValue = $self->{'ExpectedParams'}->[$i]->{'Value'}; |
47
|
190
|
100
|
100
|
|
|
1113
|
if(not $StoredValue || (defined $StoredValue && "$StoredValue" eq '0')){ ## no critic (ProhibitMixedBooleanOperators ) |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
48
|
63
|
|
|
|
|
138
|
next; |
49
|
|
|
|
|
|
|
}elsif(blessed($Params[$i]) && $Params[$i]->isa($StoredValue)){# map package name |
50
|
10
|
|
|
|
|
47
|
next; |
51
|
|
|
|
|
|
|
}elsif(Data::Compare->new()->Cmp($Params[$i], $StoredValue)){ |
52
|
101
|
|
|
|
|
6868
|
next; |
53
|
|
|
|
|
|
|
} else{ |
54
|
16
|
|
|
|
|
921
|
return 0; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
148
|
|
|
|
|
407
|
return 1; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |