line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::Base; |
2
|
168
|
|
|
168
|
|
1279
|
use strict; |
|
168
|
|
|
|
|
331
|
|
|
168
|
|
|
|
|
4707
|
|
3
|
168
|
|
|
168
|
|
843
|
use warnings; |
|
168
|
|
|
|
|
411
|
|
|
168
|
|
|
|
|
6744
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000153'; |
6
|
|
|
|
|
|
|
|
7
|
168
|
|
|
168
|
|
1256
|
use Carp qw/confess croak/; |
|
168
|
|
|
|
|
637
|
|
|
168
|
|
|
|
|
8759
|
|
8
|
168
|
|
|
168
|
|
1165
|
use Scalar::Util qw/blessed/; |
|
168
|
|
|
|
|
650
|
|
|
168
|
|
|
|
|
7825
|
|
9
|
|
|
|
|
|
|
|
10
|
168
|
|
|
168
|
|
67317
|
use Test2::Util::Sub qw/sub_info/; |
|
168
|
|
|
|
|
543
|
|
|
168
|
|
|
|
|
9104
|
|
11
|
168
|
|
|
168
|
|
72398
|
use Test2::Compare::Delta(); |
|
168
|
|
|
|
|
587
|
|
|
168
|
|
|
|
|
8078
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub MAX_CYCLES() { 75 } |
14
|
|
|
|
|
|
|
|
15
|
168
|
|
|
168
|
|
1134
|
use Test2::Util::HashBase qw{builder _file _lines _info called}; |
|
168
|
|
|
|
|
344
|
|
|
168
|
|
|
|
|
1711
|
|
16
|
168
|
|
|
168
|
|
46435
|
use Test2::Util::Ref qw/render_ref/; |
|
168
|
|
|
|
|
327
|
|
|
168
|
|
|
|
|
7713
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
{ |
19
|
168
|
|
|
168
|
|
1067
|
no warnings 'once'; |
|
168
|
|
|
|
|
280
|
|
|
168
|
|
|
|
|
100890
|
|
20
|
|
|
|
|
|
|
*set_lines = \&set__lines; |
21
|
|
|
|
|
|
|
*set_file = \&set__file; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub clone { |
25
|
244
|
|
|
244
|
0
|
410
|
my $self = shift; |
26
|
244
|
|
|
|
|
678
|
my $class = blessed($self); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Shallow copy is good enough for all the current compare types. |
29
|
244
|
|
|
|
|
1650
|
return bless({%$self}, $class); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub init { |
33
|
23428
|
|
|
23428
|
0
|
37748
|
my $self = shift; |
34
|
23428
|
100
|
|
|
|
48976
|
$self->{+_LINES} = delete $self->{lines} if exists $self->{lines}; |
35
|
23428
|
100
|
|
|
|
58687
|
$self->{+_FILE} = delete $self->{file} if exists $self->{file}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub file { |
39
|
81
|
|
|
81
|
0
|
130
|
my $self = shift; |
40
|
81
|
100
|
|
|
|
194
|
return $self->{+_FILE} if $self->{+_FILE}; |
41
|
|
|
|
|
|
|
|
42
|
69
|
100
|
|
|
|
174
|
if ($self->{+BUILDER}) { |
|
|
50
|
|
|
|
|
|
43
|
44
|
|
33
|
|
|
109
|
$self->{+_INFO} ||= sub_info($self->{+BUILDER}); |
44
|
44
|
|
|
|
|
149
|
return $self->{+_INFO}->{file}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
elsif ($self->{+CALLED}) { |
47
|
0
|
|
|
|
|
0
|
return $self->{+CALLED}->[1]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
25
|
|
|
|
|
72
|
return undef; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub lines { |
54
|
412
|
|
|
412
|
0
|
1051
|
my $self = shift; |
55
|
412
|
100
|
|
|
|
1231
|
return $self->{+_LINES} if $self->{+_LINES}; |
56
|
|
|
|
|
|
|
|
57
|
170
|
100
|
|
|
|
371
|
if ($self->{+BUILDER}) { |
58
|
104
|
|
66
|
|
|
360
|
$self->{+_INFO} ||= sub_info($self->{+BUILDER}); |
59
|
104
|
50
|
|
|
|
135
|
return $self->{+_INFO}->{lines} if @{$self->{+_INFO}->{lines}}; |
|
104
|
|
|
|
|
450
|
|
60
|
|
|
|
|
|
|
} |
61
|
66
|
100
|
|
|
|
154
|
if ($self->{+CALLED}) { |
62
|
1
|
|
|
|
|
7
|
return [$self->{+CALLED}->[2]]; |
63
|
|
|
|
|
|
|
} |
64
|
65
|
|
|
|
|
171
|
return []; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
2315
|
|
|
2315
|
1
|
7524
|
sub delta_class { 'Test2::Compare::Delta' } |
68
|
|
|
|
|
|
|
|
69
|
9951
|
|
|
9951
|
1
|
16522
|
sub deltas { () } |
70
|
282
|
|
|
282
|
1
|
527
|
sub got_lines { () } |
71
|
|
|
|
|
|
|
|
72
|
424
|
|
|
424
|
0
|
1226
|
sub stringify_got { 0 } |
73
|
|
|
|
|
|
|
|
74
|
66
|
|
|
66
|
1
|
153
|
sub operator { '' } |
75
|
1
|
|
|
1
|
1
|
234
|
sub verify { confess "unimplemented" } |
76
|
1
|
|
|
1
|
1
|
101
|
sub name { confess "unimplemented" } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub render { |
79
|
306
|
|
|
306
|
1
|
405
|
my $self = shift; |
80
|
306
|
|
|
|
|
741
|
return $self->name; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub run { |
84
|
16749
|
|
|
16749
|
1
|
26421
|
my $self = shift; |
85
|
16749
|
|
|
|
|
52228
|
my %params = @_; |
86
|
|
|
|
|
|
|
|
87
|
16749
|
|
|
|
|
26057
|
my $id = $params{id}; |
88
|
16749
|
50
|
|
|
|
32831
|
my $convert = $params{convert} or confess "no convert sub provided"; |
89
|
16749
|
|
50
|
|
|
31017
|
my $seen = $params{seen} ||= {}; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$params{exists} = exists $params{got} ? 1 : 0 |
92
|
16749
|
50
|
|
|
|
31798
|
unless exists $params{exists}; |
|
|
100
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
16749
|
|
|
|
|
22829
|
my $exists = $params{exists}; |
95
|
16749
|
100
|
|
|
|
30330
|
my $got = $exists ? $params{got} : undef; |
96
|
|
|
|
|
|
|
|
97
|
16749
|
|
|
|
|
36595
|
my $gotname = render_ref($got); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Prevent infinite cycles |
100
|
16749
|
100
|
100
|
|
|
52973
|
if (defined($got) && ref $got) { |
101
|
|
|
|
|
|
|
die "Cycle detected in comparison, aborting" |
102
|
4722
|
50
|
66
|
|
|
11635
|
if $seen->{$gotname} && $seen->{$gotname} >= MAX_CYCLES; |
103
|
4722
|
|
|
|
|
14084
|
$seen->{$gotname}++; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
16749
|
|
|
|
|
60318
|
my $ok = $self->verify(%params); |
107
|
16749
|
100
|
|
|
|
58192
|
my @deltas = $ok ? $self->deltas(%params) : (); |
108
|
|
|
|
|
|
|
|
109
|
16749
|
100
|
100
|
|
|
55714
|
$seen->{$gotname}-- if defined $got && ref $got; |
110
|
|
|
|
|
|
|
|
111
|
16749
|
100
|
100
|
|
|
87941
|
return if $ok && !@deltas; |
112
|
|
|
|
|
|
|
|
113
|
2281
|
100
|
|
|
|
4438
|
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__ |