line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::Meta; |
2
|
168
|
|
|
168
|
|
1235
|
use strict; |
|
168
|
|
|
|
|
320
|
|
|
168
|
|
|
|
|
4547
|
|
3
|
168
|
|
|
168
|
|
778
|
use warnings; |
|
168
|
|
|
|
|
315
|
|
|
168
|
|
|
|
|
3601
|
|
4
|
|
|
|
|
|
|
|
5
|
168
|
|
|
168
|
|
847
|
use Test2::Compare::Delta(); |
|
168
|
|
|
|
|
355
|
|
|
168
|
|
|
|
|
2061
|
|
6
|
168
|
|
|
168
|
|
59928
|
use Test2::Compare::Isa(); |
|
168
|
|
|
|
|
416
|
|
|
168
|
|
|
|
|
3652
|
|
7
|
|
|
|
|
|
|
|
8
|
168
|
|
|
168
|
|
953
|
use base 'Test2::Compare::Base'; |
|
168
|
|
|
|
|
324
|
|
|
168
|
|
|
|
|
16494
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.000153'; |
11
|
|
|
|
|
|
|
|
12
|
168
|
|
|
168
|
|
1094
|
use Test2::Util::HashBase qw/items/; |
|
168
|
|
|
|
|
337
|
|
|
168
|
|
|
|
|
663
|
|
13
|
|
|
|
|
|
|
|
14
|
168
|
|
|
168
|
|
19888
|
use Carp qw/croak confess/; |
|
168
|
|
|
|
|
343
|
|
|
168
|
|
|
|
|
8022
|
|
15
|
168
|
|
|
168
|
|
954
|
use Scalar::Util qw/reftype blessed/; |
|
168
|
|
|
|
|
318
|
|
|
168
|
|
|
|
|
104042
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
2218
|
|
|
2218
|
0
|
24512
|
my $self = shift; |
19
|
2218
|
|
100
|
|
|
11120
|
$self->{+ITEMS} ||= []; |
20
|
2218
|
|
|
|
|
6300
|
$self->SUPER::init(); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
1
|
19
|
sub name { '' } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub verify { |
26
|
8
|
|
|
8
|
1
|
20
|
my $self = shift; |
27
|
8
|
|
|
|
|
30
|
my %params = @_; |
28
|
8
|
100
|
|
|
|
54
|
return $params{exists} ? 1 : 0; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub add_prop { |
32
|
3032
|
|
|
3032
|
0
|
4951
|
my $self = shift; |
33
|
3032
|
|
|
|
|
6207
|
my ($name, $check) = @_; |
34
|
|
|
|
|
|
|
|
35
|
3032
|
100
|
|
|
|
6409
|
croak "prop name is required" |
36
|
|
|
|
|
|
|
unless defined $name; |
37
|
|
|
|
|
|
|
|
38
|
3031
|
100
|
|
|
|
5594
|
croak "check is required" |
39
|
|
|
|
|
|
|
unless defined $check; |
40
|
|
|
|
|
|
|
|
41
|
3030
|
|
|
|
|
6611
|
my $meth = "get_prop_$name"; |
42
|
3030
|
100
|
|
|
|
11758
|
croak "'$name' is not a known property" |
43
|
|
|
|
|
|
|
unless $self->can($meth); |
44
|
|
|
|
|
|
|
|
45
|
3029
|
100
|
|
|
|
6234
|
if ($name eq 'isa') { |
46
|
3
|
100
|
66
|
|
|
61
|
if (blessed($check) && $check->isa('Test2::Compare::Wildcard')) { |
47
|
|
|
|
|
|
|
# Carry forward file and lines that are set in Test2::Tools::Compare::prop. |
48
|
1
|
|
|
|
|
5
|
$check = Test2::Compare::Isa->new( |
49
|
|
|
|
|
|
|
input => $check->expect, |
50
|
|
|
|
|
|
|
file => $check->file, |
51
|
|
|
|
|
|
|
lines => $check->lines, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
} else { |
54
|
2
|
|
|
|
|
24
|
$check = Test2::Compare::Isa->new(input => $check); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
3029
|
|
|
|
|
4069
|
push @{$self->{+ITEMS}} => [$meth, $check, $name]; |
|
3029
|
|
|
|
|
11765
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub deltas { |
62
|
2222
|
|
|
2222
|
1
|
3603
|
my $self = shift; |
63
|
2222
|
|
|
|
|
5631
|
my %params = @_; |
64
|
2222
|
|
|
|
|
4453
|
my ($got, $convert, $seen) = @params{qw/got convert seen/}; |
65
|
|
|
|
|
|
|
|
66
|
2222
|
|
|
|
|
2859
|
my @deltas; |
67
|
2222
|
|
|
|
|
4462
|
my $items = $self->{+ITEMS}; |
68
|
|
|
|
|
|
|
|
69
|
2222
|
|
|
|
|
5000
|
for my $set (@$items) { |
70
|
3053
|
|
|
|
|
7959
|
my ($meth, $check, $name) = @$set; |
71
|
|
|
|
|
|
|
|
72
|
3053
|
|
|
|
|
6391
|
$check = $convert->($check); |
73
|
|
|
|
|
|
|
|
74
|
3053
|
|
|
|
|
16842
|
my $val = $self->$meth($got); |
75
|
|
|
|
|
|
|
|
76
|
3053
|
|
|
|
|
16288
|
push @deltas => $check->run( |
77
|
|
|
|
|
|
|
id => [META => $name], |
78
|
|
|
|
|
|
|
got => $val, |
79
|
|
|
|
|
|
|
convert => $convert, |
80
|
|
|
|
|
|
|
seen => $seen, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
2222
|
|
|
|
|
6873
|
return @deltas; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
2216
|
|
|
2216
|
0
|
7934
|
sub get_prop_blessed { blessed($_[1]) } |
88
|
|
|
|
|
|
|
|
89
|
12
|
|
|
12
|
0
|
41
|
sub get_prop_reftype { reftype($_[1]) } |
90
|
|
|
|
|
|
|
|
91
|
9
|
|
|
9
|
0
|
20
|
sub get_prop_isa { $_[1] } |
92
|
|
|
|
|
|
|
|
93
|
5
|
|
|
5
|
0
|
14
|
sub get_prop_this { $_[1] } |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub get_prop_size { |
96
|
9
|
|
|
9
|
0
|
55
|
my $self = shift; |
97
|
9
|
|
|
|
|
22
|
my ($it) = @_; |
98
|
|
|
|
|
|
|
|
99
|
9
|
|
100
|
|
|
34
|
my $type = reftype($it) || ''; |
100
|
|
|
|
|
|
|
|
101
|
9
|
100
|
|
|
|
29
|
return scalar @$it if $type eq 'ARRAY'; |
102
|
4
|
100
|
|
|
|
16
|
return scalar keys %$it if $type eq 'HASH'; |
103
|
1
|
|
|
|
|
2
|
return undef; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |