| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test2::Compare::Base; |
|
2
|
169
|
|
|
169
|
|
1345
|
use strict; |
|
|
169
|
|
|
|
|
324
|
|
|
|
169
|
|
|
|
|
4747
|
|
|
3
|
169
|
|
|
169
|
|
891
|
use warnings; |
|
|
169
|
|
|
|
|
396
|
|
|
|
169
|
|
|
|
|
6820
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
169
|
|
|
169
|
|
1063
|
use Carp qw/confess croak/; |
|
|
169
|
|
|
|
|
546
|
|
|
|
169
|
|
|
|
|
9064
|
|
|
8
|
169
|
|
|
169
|
|
1127
|
use Scalar::Util qw/blessed/; |
|
|
169
|
|
|
|
|
524
|
|
|
|
169
|
|
|
|
|
8641
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
169
|
|
|
169
|
|
74270
|
use Test2::Util::Sub qw/sub_info/; |
|
|
169
|
|
|
|
|
483
|
|
|
|
169
|
|
|
|
|
9409
|
|
|
11
|
169
|
|
|
169
|
|
78451
|
use Test2::Compare::Delta(); |
|
|
169
|
|
|
|
|
630
|
|
|
|
169
|
|
|
|
|
9027
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub MAX_CYCLES() { 75 } |
|
14
|
|
|
|
|
|
|
|
|
15
|
169
|
|
|
169
|
|
1305
|
use Test2::Util::HashBase qw{builder _file _lines _info called}; |
|
|
169
|
|
|
|
|
327
|
|
|
|
169
|
|
|
|
|
2157
|
|
|
16
|
169
|
|
|
169
|
|
48719
|
use Test2::Util::Ref qw/render_ref/; |
|
|
169
|
|
|
|
|
341
|
|
|
|
169
|
|
|
|
|
8376
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
{ |
|
19
|
169
|
|
|
169
|
|
1054
|
no warnings 'once'; |
|
|
169
|
|
|
|
|
311
|
|
|
|
169
|
|
|
|
|
105246
|
|
|
20
|
|
|
|
|
|
|
*set_lines = \&set__lines; |
|
21
|
|
|
|
|
|
|
*set_file = \&set__file; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub clone { |
|
25
|
244
|
|
|
244
|
0
|
420
|
my $self = shift; |
|
26
|
244
|
|
|
|
|
673
|
my $class = blessed($self); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Shallow copy is good enough for all the current compare types. |
|
29
|
244
|
|
|
|
|
1579
|
return bless({%$self}, $class); |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub init { |
|
33
|
23441
|
|
|
23441
|
0
|
41576
|
my $self = shift; |
|
34
|
23441
|
100
|
|
|
|
52223
|
$self->{+_LINES} = delete $self->{lines} if exists $self->{lines}; |
|
35
|
23441
|
100
|
|
|
|
61845
|
$self->{+_FILE} = delete $self->{file} if exists $self->{file}; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub file { |
|
39
|
83
|
|
|
83
|
0
|
178
|
my $self = shift; |
|
40
|
83
|
100
|
|
|
|
234
|
return $self->{+_FILE} if $self->{+_FILE}; |
|
41
|
|
|
|
|
|
|
|
|
42
|
71
|
100
|
|
|
|
192
|
if ($self->{+BUILDER}) { |
|
|
|
50
|
|
|
|
|
|
|
43
|
46
|
|
33
|
|
|
133
|
$self->{+_INFO} ||= sub_info($self->{+BUILDER}); |
|
44
|
46
|
|
|
|
|
181
|
return $self->{+_INFO}->{file}; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
elsif ($self->{+CALLED}) { |
|
47
|
0
|
|
|
|
|
0
|
return $self->{+CALLED}->[1]; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
25
|
|
|
|
|
95
|
return undef; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub lines { |
|
54
|
418
|
|
|
418
|
0
|
1238
|
my $self = shift; |
|
55
|
418
|
100
|
|
|
|
1393
|
return $self->{+_LINES} if $self->{+_LINES}; |
|
56
|
|
|
|
|
|
|
|
|
57
|
174
|
100
|
|
|
|
454
|
if ($self->{+BUILDER}) { |
|
58
|
108
|
|
66
|
|
|
440
|
$self->{+_INFO} ||= sub_info($self->{+BUILDER}); |
|
59
|
108
|
50
|
|
|
|
175
|
return $self->{+_INFO}->{lines} if @{$self->{+_INFO}->{lines}}; |
|
|
108
|
|
|
|
|
543
|
|
|
60
|
|
|
|
|
|
|
} |
|
61
|
66
|
100
|
|
|
|
173
|
if ($self->{+CALLED}) { |
|
62
|
1
|
|
|
|
|
12
|
return [$self->{+CALLED}->[2]]; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
65
|
|
|
|
|
197
|
return []; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
2319
|
|
|
2319
|
1
|
9335
|
sub delta_class { 'Test2::Compare::Delta' } |
|
68
|
|
|
|
|
|
|
|
|
69
|
9953
|
|
|
9953
|
1
|
17663
|
sub deltas { () } |
|
70
|
286
|
|
|
286
|
1
|
557
|
sub got_lines { () } |
|
71
|
|
|
|
|
|
|
|
|
72
|
432
|
|
|
432
|
0
|
1418
|
sub stringify_got { 0 } |
|
73
|
|
|
|
|
|
|
|
|
74
|
68
|
|
|
68
|
1
|
168
|
sub operator { '' } |
|
75
|
1
|
|
|
1
|
1
|
210
|
sub verify { confess "unimplemented" } |
|
76
|
1
|
|
|
1
|
1
|
115
|
sub name { confess "unimplemented" } |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub render { |
|
79
|
310
|
|
|
310
|
1
|
478
|
my $self = shift; |
|
80
|
310
|
|
|
|
|
889
|
return $self->name; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub run { |
|
84
|
16758
|
|
|
16758
|
1
|
28772
|
my $self = shift; |
|
85
|
16758
|
|
|
|
|
56369
|
my %params = @_; |
|
86
|
|
|
|
|
|
|
|
|
87
|
16758
|
|
|
|
|
27970
|
my $id = $params{id}; |
|
88
|
16758
|
50
|
|
|
|
35554
|
my $convert = $params{convert} or confess "no convert sub provided"; |
|
89
|
16758
|
|
50
|
|
|
34765
|
my $seen = $params{seen} ||= {}; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$params{exists} = exists $params{got} ? 1 : 0 |
|
92
|
16758
|
50
|
|
|
|
35147
|
unless exists $params{exists}; |
|
|
|
100
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
16758
|
|
|
|
|
24723
|
my $exists = $params{exists}; |
|
95
|
16758
|
100
|
|
|
|
31275
|
my $got = $exists ? $params{got} : undef; |
|
96
|
|
|
|
|
|
|
|
|
97
|
16758
|
|
|
|
|
39466
|
my $gotname = render_ref($got); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Prevent infinite cycles |
|
100
|
16758
|
100
|
100
|
|
|
57965
|
if (defined($got) && ref $got) { |
|
101
|
|
|
|
|
|
|
die "Cycle detected in comparison, aborting" |
|
102
|
4731
|
50
|
66
|
|
|
12893
|
if $seen->{$gotname} && $seen->{$gotname} >= MAX_CYCLES; |
|
103
|
4731
|
|
|
|
|
16988
|
$seen->{$gotname}++; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
16758
|
|
|
|
|
63865
|
my $ok = $self->verify(%params); |
|
107
|
16758
|
100
|
|
|
|
62465
|
my @deltas = $ok ? $self->deltas(%params) : (); |
|
108
|
|
|
|
|
|
|
|
|
109
|
16758
|
100
|
100
|
|
|
58719
|
$seen->{$gotname}-- if defined $got && ref $got; |
|
110
|
|
|
|
|
|
|
|
|
111
|
16758
|
100
|
100
|
|
|
92787
|
return if $ok && !@deltas; |
|
112
|
|
|
|
|
|
|
|
|
113
|
2285
|
100
|
|
|
|
5382
|
return $self->delta_class->new( |
|
114
|
|
|
|
|
|
|
verified => $ok, |
|
115
|
|
|
|
|
|
|
id => $id, |
|
116
|
|
|
|
|
|
|
got => $got, |
|
117
|
|
|
|
|
|
|
check => $self, |
|
118
|
|
|
|
|
|
|
children => \@deltas, |
|
119
|
|
|
|
|
|
|
$exists ? () : (dne => 'got'), |
|
120
|
|
|
|
|
|
|
); |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
__END__ |