line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::Set; |
2
|
169
|
|
|
169
|
|
1450
|
use strict; |
|
169
|
|
|
|
|
360
|
|
|
169
|
|
|
|
|
5108
|
|
3
|
169
|
|
|
169
|
|
868
|
use warnings; |
|
169
|
|
|
|
|
391
|
|
|
169
|
|
|
|
|
4357
|
|
4
|
|
|
|
|
|
|
|
5
|
169
|
|
|
169
|
|
824
|
use base 'Test2::Compare::Base'; |
|
169
|
|
|
|
|
351
|
|
|
169
|
|
|
|
|
23145
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
8
|
|
|
|
|
|
|
|
9
|
169
|
|
|
169
|
|
1229
|
use Test2::Util::HashBase qw/checks _reduction/; |
|
169
|
|
|
|
|
407
|
|
|
169
|
|
|
|
|
1077
|
|
10
|
|
|
|
|
|
|
|
11
|
169
|
|
|
169
|
|
30988
|
use Test2::Compare::Delta(); |
|
169
|
|
|
|
|
359
|
|
|
169
|
|
|
|
|
5568
|
|
12
|
|
|
|
|
|
|
|
13
|
169
|
|
|
169
|
|
943
|
use Carp qw/croak confess/; |
|
169
|
|
|
|
|
381
|
|
|
169
|
|
|
|
|
9622
|
|
14
|
169
|
|
|
169
|
|
1301
|
use Scalar::Util qw/reftype/; |
|
169
|
|
|
|
|
433
|
|
|
169
|
|
|
|
|
109002
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
31
|
|
|
31
|
0
|
2009
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
31
|
|
100
|
|
|
205
|
my $reduction = delete $self->{reduction} || 'any'; |
20
|
|
|
|
|
|
|
|
21
|
31
|
|
100
|
|
|
142
|
$self->{+CHECKS} ||= []; |
22
|
|
|
|
|
|
|
|
23
|
31
|
|
|
|
|
170
|
$self->set_reduction($reduction); |
24
|
|
|
|
|
|
|
|
25
|
30
|
|
|
|
|
189
|
$self->SUPER::init(); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
5
|
1
|
57
|
sub name { '' } |
29
|
5
|
|
|
5
|
1
|
36
|
sub operator { $_[0]->{+_REDUCTION} } |
30
|
4
|
|
|
4
|
0
|
73
|
sub reduction { $_[0]->{+_REDUCTION} } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my %VALID = (any => 1, all => 1, none => 1); |
33
|
|
|
|
|
|
|
sub set_reduction { |
34
|
55
|
|
|
55
|
0
|
113
|
my $self = shift; |
35
|
55
|
|
|
|
|
112
|
my ($redu) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
croak "'$redu' is not a valid set reduction" |
38
|
55
|
100
|
|
|
|
551
|
unless $VALID{$redu}; |
39
|
|
|
|
|
|
|
|
40
|
53
|
|
|
|
|
130
|
$self->{+_REDUCTION} = $redu; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub verify { |
44
|
28
|
|
|
28
|
1
|
70
|
my $self = shift; |
45
|
28
|
|
|
|
|
91
|
my %params = @_; |
46
|
28
|
|
|
|
|
93
|
return 1; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub add_check { |
50
|
23
|
|
|
23
|
0
|
59
|
my $self = shift; |
51
|
23
|
|
|
|
|
35
|
push @{$self->{+CHECKS}} => @_; |
|
23
|
|
|
|
|
89
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub deltas { |
55
|
41
|
|
|
41
|
1
|
220
|
my $self = shift; |
56
|
41
|
|
|
|
|
114
|
my %params = @_; |
57
|
|
|
|
|
|
|
|
58
|
41
|
|
|
|
|
126
|
my $checks = $self->{+CHECKS}; |
59
|
41
|
|
|
|
|
97
|
my $reduction = $self->{+_REDUCTION}; |
60
|
41
|
|
|
|
|
83
|
my $convert = $params{convert}; |
61
|
|
|
|
|
|
|
|
62
|
41
|
100
|
100
|
|
|
221
|
unless ($checks && @$checks) { |
63
|
8
|
|
|
|
|
27
|
my $file = $self->file; |
64
|
8
|
|
|
|
|
22
|
my $lines = $self->lines; |
65
|
|
|
|
|
|
|
|
66
|
8
|
|
|
|
|
16
|
my $extra = ""; |
67
|
8
|
100
|
66
|
|
|
38
|
if ($file and $lines and @$lines) { |
|
|
|
100
|
|
|
|
|
68
|
4
|
100
|
|
|
|
18
|
my $lns = (@$lines > 1 ? 'lines ' : 'line ' ) . join ', ', @$lines; |
69
|
4
|
|
|
|
|
13
|
$extra = " (Set defined in $file $lns)"; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
8
|
|
|
|
|
45
|
die "No checks defined for set$extra\n"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
33
|
|
|
|
|
70
|
my @deltas; |
76
|
33
|
|
|
|
|
65
|
my $i = 0; |
77
|
33
|
|
|
|
|
86
|
for my $check (@$checks) { |
78
|
89
|
|
|
|
|
587
|
my $c = $convert->($check); |
79
|
89
|
|
|
|
|
533
|
my $id = [META => "Check " . $i++]; |
80
|
89
|
|
|
|
|
465
|
my @d = $c->run(%params, id => $id); |
81
|
|
|
|
|
|
|
|
82
|
89
|
100
|
|
|
|
527
|
if ($reduction eq 'any') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
83
|
31
|
100
|
|
|
|
238
|
return () unless @d; |
84
|
19
|
|
|
|
|
50
|
push @deltas => @d; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
elsif ($reduction eq 'all') { |
87
|
47
|
|
|
|
|
172
|
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
|
|
|
|
90
|
check => $c, |
95
|
|
|
|
|
|
|
) unless @d; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
else { |
98
|
0
|
|
|
|
|
0
|
die "Invalid reduction: $reduction\n"; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
21
|
|
|
|
|
111
|
return @deltas; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |