line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::Set; |
2
|
169
|
|
|
169
|
|
1236
|
use strict; |
|
169
|
|
|
|
|
340
|
|
|
169
|
|
|
|
|
5306
|
|
3
|
169
|
|
|
169
|
|
892
|
use warnings; |
|
169
|
|
|
|
|
319
|
|
|
169
|
|
|
|
|
4418
|
|
4
|
|
|
|
|
|
|
|
5
|
169
|
|
|
169
|
|
832
|
use base 'Test2::Compare::Base'; |
|
169
|
|
|
|
|
354
|
|
|
169
|
|
|
|
|
23305
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000156'; |
8
|
|
|
|
|
|
|
|
9
|
169
|
|
|
169
|
|
1229
|
use Test2::Util::HashBase qw/checks _reduction/; |
|
169
|
|
|
|
|
354
|
|
|
169
|
|
|
|
|
1147
|
|
10
|
|
|
|
|
|
|
|
11
|
169
|
|
|
169
|
|
31584
|
use Test2::Compare::Delta(); |
|
169
|
|
|
|
|
374
|
|
|
169
|
|
|
|
|
4422
|
|
12
|
|
|
|
|
|
|
|
13
|
169
|
|
|
169
|
|
886
|
use Carp qw/croak confess/; |
|
169
|
|
|
|
|
347
|
|
|
169
|
|
|
|
|
9845
|
|
14
|
169
|
|
|
169
|
|
1136
|
use Scalar::Util qw/reftype/; |
|
169
|
|
|
|
|
404
|
|
|
169
|
|
|
|
|
118108
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
31
|
|
|
31
|
0
|
1869
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
31
|
|
100
|
|
|
198
|
my $reduction = delete $self->{reduction} || 'any'; |
20
|
|
|
|
|
|
|
|
21
|
31
|
|
100
|
|
|
129
|
$self->{+CHECKS} ||= []; |
22
|
|
|
|
|
|
|
|
23
|
31
|
|
|
|
|
106
|
$self->set_reduction($reduction); |
24
|
|
|
|
|
|
|
|
25
|
30
|
|
|
|
|
220
|
$self->SUPER::init(); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
5
|
1
|
50
|
sub name { '' } |
29
|
5
|
|
|
5
|
1
|
24
|
sub operator { $_[0]->{+_REDUCTION} } |
30
|
4
|
|
|
4
|
0
|
68
|
sub reduction { $_[0]->{+_REDUCTION} } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my %VALID = (any => 1, all => 1, none => 1); |
33
|
|
|
|
|
|
|
sub set_reduction { |
34
|
55
|
|
|
55
|
0
|
95
|
my $self = shift; |
35
|
55
|
|
|
|
|
104
|
my ($redu) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
croak "'$redu' is not a valid set reduction" |
38
|
55
|
100
|
|
|
|
562
|
unless $VALID{$redu}; |
39
|
|
|
|
|
|
|
|
40
|
53
|
|
|
|
|
116
|
$self->{+_REDUCTION} = $redu; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub verify { |
44
|
28
|
|
|
28
|
1
|
59
|
my $self = shift; |
45
|
28
|
|
|
|
|
75
|
my %params = @_; |
46
|
28
|
|
|
|
|
81
|
return 1; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub add_check { |
50
|
23
|
|
|
23
|
0
|
71
|
my $self = shift; |
51
|
23
|
|
|
|
|
33
|
push @{$self->{+CHECKS}} => @_; |
|
23
|
|
|
|
|
73
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub deltas { |
55
|
41
|
|
|
41
|
1
|
170
|
my $self = shift; |
56
|
41
|
|
|
|
|
132
|
my %params = @_; |
57
|
|
|
|
|
|
|
|
58
|
41
|
|
|
|
|
140
|
my $checks = $self->{+CHECKS}; |
59
|
41
|
|
|
|
|
82
|
my $reduction = $self->{+_REDUCTION}; |
60
|
41
|
|
|
|
|
86
|
my $convert = $params{convert}; |
61
|
|
|
|
|
|
|
|
62
|
41
|
100
|
100
|
|
|
227
|
unless ($checks && @$checks) { |
63
|
8
|
|
|
|
|
27
|
my $file = $self->file; |
64
|
8
|
|
|
|
|
21
|
my $lines = $self->lines; |
65
|
|
|
|
|
|
|
|
66
|
8
|
|
|
|
|
13
|
my $extra = ""; |
67
|
8
|
100
|
66
|
|
|
38
|
if ($file and $lines and @$lines) { |
|
|
|
100
|
|
|
|
|
68
|
4
|
100
|
|
|
|
16
|
my $lns = (@$lines > 1 ? 'lines ' : 'line ' ) . join ', ', @$lines; |
69
|
4
|
|
|
|
|
12
|
$extra = " (Set defined in $file $lns)"; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
8
|
|
|
|
|
52
|
die "No checks defined for set$extra\n"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
33
|
|
|
|
|
59
|
my @deltas; |
76
|
33
|
|
|
|
|
60
|
my $i = 0; |
77
|
33
|
|
|
|
|
77
|
for my $check (@$checks) { |
78
|
89
|
|
|
|
|
226
|
my $c = $convert->($check); |
79
|
89
|
|
|
|
|
509
|
my $id = [META => "Check " . $i++]; |
80
|
89
|
|
|
|
|
440
|
my @d = $c->run(%params, id => $id); |
81
|
|
|
|
|
|
|
|
82
|
89
|
100
|
|
|
|
432
|
if ($reduction eq 'any') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
83
|
31
|
100
|
|
|
|
216
|
return () unless @d; |
84
|
19
|
|
|
|
|
46
|
push @deltas => @d; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
elsif ($reduction eq 'all') { |
87
|
47
|
|
|
|
|
161
|
push @deltas => @d; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
elsif ($reduction eq 'none') { |
90
|
|
|
|
|
|
|
push @deltas => Test2::Compare::Delta->new( |
91
|
|
|
|
|
|
|
verified => 0, |
92
|
|
|
|
|
|
|
id => $id, |
93
|
|
|
|
|
|
|
got => $params{got}, |
94
|
11
|
100
|
|
|
|
57
|
check => $c, |
95
|
|
|
|
|
|
|
) unless @d; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
else { |
98
|
0
|
|
|
|
|
0
|
die "Invalid reduction: $reduction\n"; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
21
|
|
|
|
|
110
|
return @deltas; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |