| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test2::Compare::Base; |
|
2
|
169
|
|
|
169
|
|
1502
|
use strict; |
|
|
169
|
|
|
|
|
344
|
|
|
|
169
|
|
|
|
|
5166
|
|
|
3
|
169
|
|
|
169
|
|
865
|
use warnings; |
|
|
169
|
|
|
|
|
320
|
|
|
|
169
|
|
|
|
|
6994
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000156'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
169
|
|
|
169
|
|
1015
|
use Carp qw/confess croak/; |
|
|
169
|
|
|
|
|
324
|
|
|
|
169
|
|
|
|
|
9082
|
|
|
8
|
169
|
|
|
169
|
|
1078
|
use Scalar::Util qw/blessed/; |
|
|
169
|
|
|
|
|
360
|
|
|
|
169
|
|
|
|
|
8631
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
169
|
|
|
169
|
|
76937
|
use Test2::Util::Sub qw/sub_info/; |
|
|
169
|
|
|
|
|
581
|
|
|
|
169
|
|
|
|
|
9612
|
|
|
11
|
169
|
|
|
169
|
|
79023
|
use Test2::Compare::Delta(); |
|
|
169
|
|
|
|
|
577
|
|
|
|
169
|
|
|
|
|
8901
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub MAX_CYCLES() { 75 } |
|
14
|
|
|
|
|
|
|
|
|
15
|
169
|
|
|
169
|
|
1243
|
use Test2::Util::HashBase qw{builder _file _lines _info called}; |
|
|
169
|
|
|
|
|
392
|
|
|
|
169
|
|
|
|
|
2013
|
|
|
16
|
169
|
|
|
169
|
|
47827
|
use Test2::Util::Ref qw/render_ref/; |
|
|
169
|
|
|
|
|
345
|
|
|
|
169
|
|
|
|
|
7894
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
{ |
|
19
|
169
|
|
|
169
|
|
961
|
no warnings 'once'; |
|
|
169
|
|
|
|
|
348
|
|
|
|
169
|
|
|
|
|
105362
|
|
|
20
|
|
|
|
|
|
|
*set_lines = \&set__lines; |
|
21
|
|
|
|
|
|
|
*set_file = \&set__file; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub clone { |
|
25
|
248
|
|
|
248
|
0
|
443
|
my $self = shift; |
|
26
|
248
|
|
|
|
|
720
|
my $class = blessed($self); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Shallow copy is good enough for all the current compare types. |
|
29
|
248
|
|
|
|
|
1678
|
return bless({%$self}, $class); |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub init { |
|
33
|
23793
|
|
|
23793
|
0
|
40707
|
my $self = shift; |
|
34
|
23793
|
100
|
|
|
|
51819
|
$self->{+_LINES} = delete $self->{lines} if exists $self->{lines}; |
|
35
|
23793
|
100
|
|
|
|
61626
|
$self->{+_FILE} = delete $self->{file} if exists $self->{file}; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub file { |
|
39
|
83
|
|
|
83
|
0
|
155
|
my $self = shift; |
|
40
|
83
|
100
|
|
|
|
251
|
return $self->{+_FILE} if $self->{+_FILE}; |
|
41
|
|
|
|
|
|
|
|
|
42
|
71
|
100
|
|
|
|
197
|
if ($self->{+BUILDER}) { |
|
|
|
50
|
|
|
|
|
|
|
43
|
46
|
|
33
|
|
|
121
|
$self->{+_INFO} ||= sub_info($self->{+BUILDER}); |
|
44
|
46
|
|
|
|
|
152
|
return $self->{+_INFO}->{file}; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
elsif ($self->{+CALLED}) { |
|
47
|
0
|
|
|
|
|
0
|
return $self->{+CALLED}->[1]; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
25
|
|
|
|
|
89
|
return undef; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub lines { |
|
54
|
430
|
|
|
430
|
0
|
1720
|
my $self = shift; |
|
55
|
430
|
100
|
|
|
|
1589
|
return $self->{+_LINES} if $self->{+_LINES}; |
|
56
|
|
|
|
|
|
|
|
|
57
|
174
|
100
|
|
|
|
408
|
if ($self->{+BUILDER}) { |
|
58
|
108
|
|
66
|
|
|
449
|
$self->{+_INFO} ||= sub_info($self->{+BUILDER}); |
|
59
|
108
|
50
|
|
|
|
161
|
return $self->{+_INFO}->{lines} if @{$self->{+_INFO}->{lines}}; |
|
|
108
|
|
|
|
|
581
|
|
|
60
|
|
|
|
|
|
|
} |
|
61
|
66
|
100
|
|
|
|
175
|
if ($self->{+CALLED}) { |
|
62
|
1
|
|
|
|
|
6
|
return [$self->{+CALLED}->[2]]; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
65
|
|
|
|
|
206
|
return []; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
2447
|
|
|
2447
|
1
|
9667
|
sub delta_class { 'Test2::Compare::Delta' } |
|
68
|
|
|
|
|
|
|
|
|
69
|
10061
|
|
|
10061
|
1
|
17902
|
sub deltas { () } |
|
70
|
294
|
|
|
294
|
1
|
585
|
sub got_lines { () } |
|
71
|
|
|
|
|
|
|
|
|
72
|
440
|
|
|
440
|
0
|
1581
|
sub stringify_got { 0 } |
|
73
|
|
|
|
|
|
|
|
|
74
|
68
|
|
|
68
|
1
|
182
|
sub operator { '' } |
|
75
|
1
|
|
|
1
|
1
|
262
|
sub verify { confess "unimplemented" } |
|
76
|
1
|
|
|
1
|
1
|
125
|
sub name { confess "unimplemented" } |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub render { |
|
79
|
318
|
|
|
318
|
1
|
517
|
my $self = shift; |
|
80
|
318
|
|
|
|
|
909
|
return $self->name; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub run { |
|
84
|
17078
|
|
|
17078
|
1
|
28933
|
my $self = shift; |
|
85
|
17078
|
|
|
|
|
55588
|
my %params = @_; |
|
86
|
|
|
|
|
|
|
|
|
87
|
17078
|
|
|
|
|
28915
|
my $id = $params{id}; |
|
88
|
17078
|
50
|
|
|
|
38316
|
my $convert = $params{convert} or confess "no convert sub provided"; |
|
89
|
17078
|
|
50
|
|
|
33940
|
my $seen = $params{seen} ||= {}; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$params{exists} = exists $params{got} ? 1 : 0 |
|
92
|
17078
|
50
|
|
|
|
34735
|
unless exists $params{exists}; |
|
|
|
100
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
17078
|
|
|
|
|
25625
|
my $exists = $params{exists}; |
|
95
|
17078
|
100
|
|
|
|
31459
|
my $got = $exists ? $params{got} : undef; |
|
96
|
|
|
|
|
|
|
|
|
97
|
17078
|
|
|
|
|
39796
|
my $gotname = render_ref($got); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Prevent infinite cycles |
|
100
|
17078
|
100
|
100
|
|
|
59163
|
if (defined($got) && ref $got) { |
|
101
|
|
|
|
|
|
|
die "Cycle detected in comparison, aborting" |
|
102
|
4815
|
50
|
66
|
|
|
12883
|
if $seen->{$gotname} && $seen->{$gotname} >= MAX_CYCLES; |
|
103
|
4815
|
|
|
|
|
16846
|
$seen->{$gotname}++; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
17078
|
|
|
|
|
68120
|
my $ok = $self->verify(%params); |
|
107
|
17078
|
100
|
|
|
|
64040
|
my @deltas = $ok ? $self->deltas(%params) : (); |
|
108
|
|
|
|
|
|
|
|
|
109
|
17078
|
100
|
100
|
|
|
61422
|
$seen->{$gotname}-- if defined $got && ref $got; |
|
110
|
|
|
|
|
|
|
|
|
111
|
17078
|
100
|
100
|
|
|
94711
|
return if $ok && !@deltas; |
|
112
|
|
|
|
|
|
|
|
|
113
|
2413
|
100
|
|
|
|
5350
|
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__ |