line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Compare::Object; |
2
|
100
|
|
|
100
|
|
1115
|
use strict; |
|
100
|
|
|
|
|
189
|
|
|
100
|
|
|
|
|
2518
|
|
3
|
100
|
|
|
100
|
|
493
|
use warnings; |
|
100
|
|
|
|
|
194
|
|
|
100
|
|
|
|
|
2642
|
|
4
|
|
|
|
|
|
|
|
5
|
100
|
|
|
100
|
|
512
|
use Test::Stream::Util qw/try/; |
|
100
|
|
|
|
|
194
|
|
|
100
|
|
|
|
|
704
|
|
6
|
|
|
|
|
|
|
|
7
|
100
|
|
|
100
|
|
528
|
use Test::Stream::Compare; |
|
100
|
|
|
|
|
350
|
|
|
100
|
|
|
|
|
641
|
|
8
|
100
|
|
|
100
|
|
54983
|
use Test::Stream::Compare::Meta; |
|
100
|
|
|
|
|
258
|
|
|
100
|
|
|
|
|
697
|
|
9
|
|
|
|
|
|
|
use Test::Stream::HashBase( |
10
|
100
|
|
|
|
|
572
|
base => 'Test::Stream::Compare', |
11
|
|
|
|
|
|
|
accessors => [qw/calls meta refcheck ending/], |
12
|
100
|
|
|
100
|
|
586
|
); |
|
100
|
|
|
|
|
195
|
|
13
|
|
|
|
|
|
|
|
14
|
100
|
|
|
100
|
|
551
|
use Carp qw/croak confess/; |
|
100
|
|
|
|
|
191
|
|
|
100
|
|
|
|
|
5216
|
|
15
|
100
|
|
|
100
|
|
519
|
use Scalar::Util qw/reftype blessed/; |
|
100
|
|
|
|
|
207
|
|
|
100
|
|
|
|
|
81891
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
425
|
|
|
425
|
0
|
605
|
my $self = shift; |
19
|
425
|
|
100
|
|
|
2106
|
$self->{+CALLS} ||= []; |
20
|
425
|
|
|
|
|
1341
|
$self->SUPER::init(); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
18
|
|
|
18
|
1
|
59
|
sub name { ' |
24
|
|
|
|
|
|
|
|
25
|
112
|
|
|
112
|
1
|
407
|
sub meta_class { 'Test::Stream::Compare::Meta' } |
26
|
145
|
|
|
145
|
1
|
533
|
sub object_base { 'UNIVERSAL' } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub verify { |
29
|
442
|
|
|
442
|
1
|
706
|
my $self = shift; |
30
|
442
|
|
|
|
|
1396
|
my %params = @_; |
31
|
442
|
|
|
|
|
901
|
my ($got, $exists) = @params{qw/got exists/}; |
32
|
|
|
|
|
|
|
|
33
|
442
|
100
|
|
|
|
1009
|
return 0 unless $exists; |
34
|
441
|
100
|
|
|
|
980
|
return 0 unless $got; |
35
|
440
|
100
|
|
|
|
1053
|
return 0 unless ref($got); |
36
|
437
|
100
|
|
|
|
1502
|
return 0 unless blessed($got); |
37
|
435
|
100
|
|
|
|
1364
|
return 0 unless $got->isa($self->object_base); |
38
|
434
|
|
|
|
|
1522
|
return 1; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub add_prop { |
42
|
502
|
|
|
502
|
1
|
729
|
my $self = shift; |
43
|
502
|
|
66
|
|
|
2118
|
$self->{+META} ||= $self->meta_class->new; |
44
|
502
|
|
|
|
|
1786
|
$self->{+META}->add_prop(@_); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub add_field { |
48
|
76
|
|
|
76
|
1
|
121
|
my $self = shift; |
49
|
76
|
|
66
|
|
|
297
|
$self->{+REFCHECK} ||= Test::Stream::Compare::Hash->new; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
croak "Underlying reference does not have fields" |
52
|
76
|
100
|
|
|
|
481
|
unless $self->{+REFCHECK}->can('add_field'); |
53
|
|
|
|
|
|
|
|
54
|
75
|
|
|
|
|
247
|
$self->{+REFCHECK}->add_field(@_); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub add_item { |
58
|
8
|
|
|
8
|
1
|
32
|
my $self = shift; |
59
|
8
|
|
66
|
|
|
48
|
$self->{+REFCHECK} ||= Test::Stream::Compare::Array->new; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
croak "Underlying reference does not have items" |
62
|
8
|
100
|
|
|
|
176
|
unless $self->{+REFCHECK}->can('add_item'); |
63
|
|
|
|
|
|
|
|
64
|
7
|
|
|
|
|
28
|
$self->{+REFCHECK}->add_item(@_); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub add_call { |
68
|
1060
|
|
|
1060
|
1
|
1504
|
my $self = shift; |
69
|
1060
|
|
|
|
|
1602
|
my ($meth, $check, $name) = @_; |
70
|
1060
|
100
|
66
|
|
|
4182
|
$name ||= ref $meth ? '\&CODE' : $meth; |
71
|
1060
|
|
|
|
|
1214
|
push @{$self->{+CALLS}} => [$meth, $check, $name]; |
|
1060
|
|
|
|
|
4625
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub deltas { |
75
|
435
|
|
|
435
|
1
|
652
|
my $self = shift; |
76
|
435
|
|
|
|
|
1329
|
my %params = @_; |
77
|
435
|
|
|
|
|
905
|
my ($got, $convert, $seen) = @params{qw/got convert seen/}; |
78
|
|
|
|
|
|
|
|
79
|
435
|
|
|
|
|
526
|
my @deltas; |
80
|
435
|
|
|
|
|
742
|
my $meta = $self->{+META}; |
81
|
435
|
|
|
|
|
684
|
my $refcheck = $self->{+REFCHECK}; |
82
|
|
|
|
|
|
|
|
83
|
435
|
100
|
|
|
|
2246
|
push @deltas => $meta->deltas(%params) if $meta; |
84
|
|
|
|
|
|
|
|
85
|
435
|
|
|
|
|
745
|
for my $call (@{$self->{+CALLS}}) { |
|
435
|
|
|
|
|
1146
|
|
86
|
1098
|
|
|
|
|
2600
|
my ($meth, $check, $name)= @$call; |
87
|
|
|
|
|
|
|
|
88
|
1098
|
|
|
|
|
2984
|
$check = $convert->($check); |
89
|
|
|
|
|
|
|
|
90
|
1098
|
|
100
|
|
|
5750
|
my $exists = ref($meth) || $got->can($meth); |
91
|
1098
|
|
|
|
|
1459
|
my $val; |
92
|
1098
|
100
|
|
1098
|
|
5513
|
my ($ok, $err) = try { $val = $exists ? $got->$meth : undef }; |
|
1098
|
|
|
|
|
4218
|
|
93
|
|
|
|
|
|
|
|
94
|
1098
|
100
|
|
|
|
4412
|
if (!$ok) { |
95
|
2
|
|
|
|
|
11
|
push @deltas => $self->delta_class->new( |
96
|
|
|
|
|
|
|
verified => undef, |
97
|
|
|
|
|
|
|
id => [METHOD => $name], |
98
|
|
|
|
|
|
|
got => undef, |
99
|
|
|
|
|
|
|
check => $check, |
100
|
|
|
|
|
|
|
exception => $err, |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
else { |
104
|
1096
|
100
|
|
|
|
5356
|
push @deltas => $check->run( |
105
|
|
|
|
|
|
|
id => [METHOD => $name], |
106
|
|
|
|
|
|
|
convert => $convert, |
107
|
|
|
|
|
|
|
seen => $seen, |
108
|
|
|
|
|
|
|
exists => $exists, |
109
|
|
|
|
|
|
|
$exists ? (got => $val) : (), |
110
|
|
|
|
|
|
|
); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
435
|
100
|
|
|
|
1661
|
return @deltas unless $refcheck; |
115
|
|
|
|
|
|
|
|
116
|
228
|
|
|
|
|
1039
|
$refcheck->set_ending($self->{+ENDING}); |
117
|
|
|
|
|
|
|
|
118
|
228
|
100
|
|
|
|
1701
|
if ($refcheck->verify(%params)) { |
119
|
225
|
|
|
|
|
936
|
push @deltas => $refcheck->deltas(%params); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
else { |
122
|
3
|
|
|
|
|
11
|
push @deltas => $self->delta_class->new( |
123
|
|
|
|
|
|
|
verified => undef, |
124
|
|
|
|
|
|
|
id => [META => 'Object Ref'], |
125
|
|
|
|
|
|
|
got => $got, |
126
|
|
|
|
|
|
|
check => $refcheck, |
127
|
|
|
|
|
|
|
); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
228
|
|
|
|
|
946
|
return @deltas; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
__END__ |