line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::Meta; |
2
|
169
|
|
|
169
|
|
1344
|
use strict; |
|
169
|
|
|
|
|
351
|
|
|
169
|
|
|
|
|
4811
|
|
3
|
169
|
|
|
169
|
|
841
|
use warnings; |
|
169
|
|
|
|
|
345
|
|
|
169
|
|
|
|
|
3830
|
|
4
|
|
|
|
|
|
|
|
5
|
169
|
|
|
169
|
|
1190
|
use Test2::Compare::Delta(); |
|
169
|
|
|
|
|
350
|
|
|
169
|
|
|
|
|
2321
|
|
6
|
169
|
|
|
169
|
|
66523
|
use Test2::Compare::Isa(); |
|
169
|
|
|
|
|
450
|
|
|
169
|
|
|
|
|
3823
|
|
7
|
|
|
|
|
|
|
|
8
|
169
|
|
|
169
|
|
1045
|
use base 'Test2::Compare::Base'; |
|
169
|
|
|
|
|
359
|
|
|
169
|
|
|
|
|
17977
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
11
|
|
|
|
|
|
|
|
12
|
169
|
|
|
169
|
|
1151
|
use Test2::Util::HashBase qw/items/; |
|
169
|
|
|
|
|
340
|
|
|
169
|
|
|
|
|
747
|
|
13
|
|
|
|
|
|
|
|
14
|
169
|
|
|
169
|
|
21170
|
use Carp qw/croak confess/; |
|
169
|
|
|
|
|
369
|
|
|
169
|
|
|
|
|
8292
|
|
15
|
169
|
|
|
169
|
|
1157
|
use Scalar::Util qw/reftype blessed/; |
|
169
|
|
|
|
|
341
|
|
|
169
|
|
|
|
|
106437
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
2218
|
|
|
2218
|
0
|
25805
|
my $self = shift; |
19
|
2218
|
|
100
|
|
|
12128
|
$self->{+ITEMS} ||= []; |
20
|
2218
|
|
|
|
|
6248
|
$self->SUPER::init(); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
1
|
20
|
sub name { '' } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub verify { |
26
|
8
|
|
|
8
|
1
|
26
|
my $self = shift; |
27
|
8
|
|
|
|
|
29
|
my %params = @_; |
28
|
8
|
100
|
|
|
|
40
|
return $params{exists} ? 1 : 0; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub add_prop { |
32
|
3032
|
|
|
3032
|
0
|
4929
|
my $self = shift; |
33
|
3032
|
|
|
|
|
6202
|
my ($name, $check) = @_; |
34
|
|
|
|
|
|
|
|
35
|
3032
|
100
|
|
|
|
6647
|
croak "prop name is required" |
36
|
|
|
|
|
|
|
unless defined $name; |
37
|
|
|
|
|
|
|
|
38
|
3031
|
100
|
|
|
|
5557
|
croak "check is required" |
39
|
|
|
|
|
|
|
unless defined $check; |
40
|
|
|
|
|
|
|
|
41
|
3030
|
|
|
|
|
6963
|
my $meth = "get_prop_$name"; |
42
|
3030
|
100
|
|
|
|
9966
|
croak "'$name' is not a known property" |
43
|
|
|
|
|
|
|
unless $self->can($meth); |
44
|
|
|
|
|
|
|
|
45
|
3029
|
100
|
|
|
|
6492
|
if ($name eq 'isa') { |
46
|
3
|
100
|
66
|
|
|
32
|
if (blessed($check) && $check->isa('Test2::Compare::Wildcard')) { |
47
|
|
|
|
|
|
|
# Carry forward file and lines that are set in Test2::Tools::Compare::prop. |
48
|
1
|
|
|
|
|
6
|
$check = Test2::Compare::Isa->new( |
49
|
|
|
|
|
|
|
input => $check->expect, |
50
|
|
|
|
|
|
|
file => $check->file, |
51
|
|
|
|
|
|
|
lines => $check->lines, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
} else { |
54
|
2
|
|
|
|
|
28
|
$check = Test2::Compare::Isa->new(input => $check); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
3029
|
|
|
|
|
4359
|
push @{$self->{+ITEMS}} => [$meth, $check, $name]; |
|
3029
|
|
|
|
|
12977
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub deltas { |
62
|
2222
|
|
|
2222
|
1
|
3855
|
my $self = shift; |
63
|
2222
|
|
|
|
|
5854
|
my %params = @_; |
64
|
2222
|
|
|
|
|
4384
|
my ($got, $convert, $seen) = @params{qw/got convert seen/}; |
65
|
|
|
|
|
|
|
|
66
|
2222
|
|
|
|
|
3319
|
my @deltas; |
67
|
2222
|
|
|
|
|
4175
|
my $items = $self->{+ITEMS}; |
68
|
|
|
|
|
|
|
|
69
|
2222
|
|
|
|
|
5055
|
for my $set (@$items) { |
70
|
3053
|
|
|
|
|
7060
|
my ($meth, $check, $name) = @$set; |
71
|
|
|
|
|
|
|
|
72
|
3053
|
|
|
|
|
6612
|
$check = $convert->($check); |
73
|
|
|
|
|
|
|
|
74
|
3053
|
|
|
|
|
16238
|
my $val = $self->$meth($got); |
75
|
|
|
|
|
|
|
|
76
|
3053
|
|
|
|
|
16068
|
push @deltas => $check->run( |
77
|
|
|
|
|
|
|
id => [META => $name], |
78
|
|
|
|
|
|
|
got => $val, |
79
|
|
|
|
|
|
|
convert => $convert, |
80
|
|
|
|
|
|
|
seen => $seen, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
2222
|
|
|
|
|
7012
|
return @deltas; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
2216
|
|
|
2216
|
0
|
8947
|
sub get_prop_blessed { blessed($_[1]) } |
88
|
|
|
|
|
|
|
|
89
|
12
|
|
|
12
|
0
|
60
|
sub get_prop_reftype { reftype($_[1]) } |
90
|
|
|
|
|
|
|
|
91
|
9
|
|
|
9
|
0
|
24
|
sub get_prop_isa { $_[1] } |
92
|
|
|
|
|
|
|
|
93
|
5
|
|
|
5
|
0
|
10
|
sub get_prop_this { $_[1] } |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub get_prop_size { |
96
|
9
|
|
|
9
|
0
|
21
|
my $self = shift; |
97
|
9
|
|
|
|
|
21
|
my ($it) = @_; |
98
|
|
|
|
|
|
|
|
99
|
9
|
|
100
|
|
|
38
|
my $type = reftype($it) || ''; |
100
|
|
|
|
|
|
|
|
101
|
9
|
100
|
|
|
|
34
|
return scalar @$it if $type eq 'ARRAY'; |
102
|
4
|
100
|
|
|
|
24
|
return scalar keys %$it if $type eq 'HASH'; |
103
|
1
|
|
|
|
|
2
|
return undef; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |