line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Deep::Matcher::DataUtil; |
2
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
62655
|
use strict; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
360
|
|
4
|
12
|
|
|
12
|
|
55
|
use warnings; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
392
|
|
5
|
12
|
|
|
12
|
|
10398
|
use Test::Deep::Cmp; |
|
12
|
|
|
|
|
9760
|
|
|
12
|
|
|
|
|
53
|
|
6
|
12
|
|
|
12
|
|
11435
|
use Data::Util (); |
|
12
|
|
|
|
|
11610846
|
|
|
12
|
|
|
|
|
4428
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub init { |
9
|
67
|
|
|
67
|
0
|
640
|
my $self = shift; |
10
|
67
|
|
|
|
|
138
|
my ($name, @args) = @_; |
11
|
|
|
|
|
|
|
|
12
|
67
|
|
|
|
|
924
|
$self->{name} = $name; |
13
|
67
|
|
|
|
|
488
|
$self->{matcher} = Data::Util->can($name); |
14
|
67
|
|
|
|
|
229
|
$self->{val} = \@args; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub descend { |
18
|
67
|
|
|
67
|
0
|
40026
|
my ($self, $got) = @_; |
19
|
67
|
|
|
|
|
409
|
return $self->{matcher}->($got); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
45
|
|
|
45
|
|
396
|
sub _expectation { join ' ' => split /_/ => shift->{name} } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub diag_message { |
25
|
35
|
|
|
35
|
0
|
7324
|
my ($self, $got) = @_; |
26
|
35
|
|
|
|
|
117
|
return sprintf 'Checking %s %s' => $got, $self->_expectation; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub renderGot { |
30
|
35
|
|
|
35
|
0
|
458
|
my ($self, $val) = @_; |
31
|
|
|
|
|
|
|
|
32
|
35
|
100
|
|
|
|
196
|
if ($self->{name} =~ /_ref/) { |
33
|
25
|
|
100
|
|
|
152
|
return ref($val) || '(NONREF)'; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else { |
36
|
10
|
100
|
|
|
|
47
|
return defined($val) ? $val : '(undef)'; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub renderExp { |
41
|
35
|
|
|
35
|
0
|
195
|
my ($self, $val) = @_; |
42
|
|
|
|
|
|
|
|
43
|
35
|
100
|
|
|
|
268
|
if ($self->{name} =~ /is_(.+)_ref/) { |
44
|
25
|
|
|
|
|
154
|
return uc($1); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
10
|
|
|
|
|
26
|
return sprintf '(%s)' => $self->_expectation; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |