line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::Meta; |
2
|
169
|
|
|
169
|
|
1362
|
use strict; |
|
169
|
|
|
|
|
390
|
|
|
169
|
|
|
|
|
4844
|
|
3
|
169
|
|
|
169
|
|
865
|
use warnings; |
|
169
|
|
|
|
|
351
|
|
|
169
|
|
|
|
|
3706
|
|
4
|
|
|
|
|
|
|
|
5
|
169
|
|
|
169
|
|
955
|
use Test2::Compare::Delta(); |
|
169
|
|
|
|
|
375
|
|
|
169
|
|
|
|
|
2125
|
|
6
|
169
|
|
|
169
|
|
68319
|
use Test2::Compare::Isa(); |
|
169
|
|
|
|
|
432
|
|
|
169
|
|
|
|
|
3965
|
|
7
|
|
|
|
|
|
|
|
8
|
169
|
|
|
169
|
|
1058
|
use base 'Test2::Compare::Base'; |
|
169
|
|
|
|
|
350
|
|
|
169
|
|
|
|
|
17784
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.000156'; |
11
|
|
|
|
|
|
|
|
12
|
169
|
|
|
169
|
|
1136
|
use Test2::Util::HashBase qw/items/; |
|
169
|
|
|
|
|
348
|
|
|
169
|
|
|
|
|
695
|
|
13
|
|
|
|
|
|
|
|
14
|
169
|
|
|
169
|
|
21993
|
use Carp qw/croak confess/; |
|
169
|
|
|
|
|
361
|
|
|
169
|
|
|
|
|
9139
|
|
15
|
169
|
|
|
169
|
|
1025
|
use Scalar::Util qw/reftype blessed/; |
|
169
|
|
|
|
|
342
|
|
|
169
|
|
|
|
|
111244
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
2230
|
|
|
2230
|
0
|
25212
|
my $self = shift; |
19
|
2230
|
|
100
|
|
|
11897
|
$self->{+ITEMS} ||= []; |
20
|
2230
|
|
|
|
|
6824
|
$self->SUPER::init(); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
1
|
21
|
sub name { '' } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub verify { |
26
|
8
|
|
|
8
|
1
|
21
|
my $self = shift; |
27
|
8
|
|
|
|
|
41
|
my %params = @_; |
28
|
8
|
100
|
|
|
|
39
|
return $params{exists} ? 1 : 0; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub add_prop { |
32
|
3044
|
|
|
3044
|
0
|
4720
|
my $self = shift; |
33
|
3044
|
|
|
|
|
5571
|
my ($name, $check) = @_; |
34
|
|
|
|
|
|
|
|
35
|
3044
|
100
|
|
|
|
6371
|
croak "prop name is required" |
36
|
|
|
|
|
|
|
unless defined $name; |
37
|
|
|
|
|
|
|
|
38
|
3043
|
100
|
|
|
|
5524
|
croak "check is required" |
39
|
|
|
|
|
|
|
unless defined $check; |
40
|
|
|
|
|
|
|
|
41
|
3042
|
|
|
|
|
6400
|
my $meth = "get_prop_$name"; |
42
|
3042
|
100
|
|
|
|
9715
|
croak "'$name' is not a known property" |
43
|
|
|
|
|
|
|
unless $self->can($meth); |
44
|
|
|
|
|
|
|
|
45
|
3041
|
100
|
|
|
|
6487
|
if ($name eq 'isa') { |
46
|
3
|
100
|
66
|
|
|
50
|
if (blessed($check) && $check->isa('Test2::Compare::Wildcard')) { |
47
|
|
|
|
|
|
|
# Carry forward file and lines that are set in Test2::Tools::Compare::prop. |
48
|
1
|
|
|
|
|
10
|
$check = Test2::Compare::Isa->new( |
49
|
|
|
|
|
|
|
input => $check->expect, |
50
|
|
|
|
|
|
|
file => $check->file, |
51
|
|
|
|
|
|
|
lines => $check->lines, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
} else { |
54
|
2
|
|
|
|
|
36
|
$check = Test2::Compare::Isa->new(input => $check); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
3041
|
|
|
|
|
3947
|
push @{$self->{+ITEMS}} => [$meth, $check, $name]; |
|
3041
|
|
|
|
|
11737
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub deltas { |
62
|
2234
|
|
|
2234
|
1
|
3611
|
my $self = shift; |
63
|
2234
|
|
|
|
|
5719
|
my %params = @_; |
64
|
2234
|
|
|
|
|
4549
|
my ($got, $convert, $seen) = @params{qw/got convert seen/}; |
65
|
|
|
|
|
|
|
|
66
|
2234
|
|
|
|
|
3025
|
my @deltas; |
67
|
2234
|
|
|
|
|
4107
|
my $items = $self->{+ITEMS}; |
68
|
|
|
|
|
|
|
|
69
|
2234
|
|
|
|
|
5424
|
for my $set (@$items) { |
70
|
3065
|
|
|
|
|
7785
|
my ($meth, $check, $name) = @$set; |
71
|
|
|
|
|
|
|
|
72
|
3065
|
|
|
|
|
6707
|
$check = $convert->($check); |
73
|
|
|
|
|
|
|
|
74
|
3065
|
|
|
|
|
16349
|
my $val = $self->$meth($got); |
75
|
|
|
|
|
|
|
|
76
|
3065
|
|
|
|
|
16398
|
push @deltas => $check->run( |
77
|
|
|
|
|
|
|
id => [META => $name], |
78
|
|
|
|
|
|
|
got => $val, |
79
|
|
|
|
|
|
|
convert => $convert, |
80
|
|
|
|
|
|
|
seen => $seen, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
2234
|
|
|
|
|
6955
|
return @deltas; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
2228
|
|
|
2228
|
0
|
8574
|
sub get_prop_blessed { blessed($_[1]) } |
88
|
|
|
|
|
|
|
|
89
|
12
|
|
|
12
|
0
|
63
|
sub get_prop_reftype { reftype($_[1]) } |
90
|
|
|
|
|
|
|
|
91
|
9
|
|
|
9
|
0
|
26
|
sub get_prop_isa { $_[1] } |
92
|
|
|
|
|
|
|
|
93
|
5
|
|
|
5
|
0
|
15
|
sub get_prop_this { $_[1] } |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub get_prop_size { |
96
|
9
|
|
|
9
|
0
|
17
|
my $self = shift; |
97
|
9
|
|
|
|
|
32
|
my ($it) = @_; |
98
|
|
|
|
|
|
|
|
99
|
9
|
|
100
|
|
|
36
|
my $type = reftype($it) || ''; |
100
|
|
|
|
|
|
|
|
101
|
9
|
100
|
|
|
|
33
|
return scalar @$it if $type eq 'ARRAY'; |
102
|
4
|
100
|
|
|
|
34
|
return scalar keys %$it if $type eq 'HASH'; |
103
|
1
|
|
|
|
|
2
|
return undef; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |