| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test2::Compare::Set; |
|
2
|
168
|
|
|
168
|
|
1387
|
use strict; |
|
|
168
|
|
|
|
|
331
|
|
|
|
168
|
|
|
|
|
4763
|
|
|
3
|
168
|
|
|
168
|
|
37991
|
use warnings; |
|
|
168
|
|
|
|
|
363
|
|
|
|
168
|
|
|
|
|
4360
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
168
|
|
|
168
|
|
842
|
use base 'Test2::Compare::Base'; |
|
|
168
|
|
|
|
|
300
|
|
|
|
168
|
|
|
|
|
22199
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000153'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
168
|
|
|
168
|
|
1191
|
use Test2::Util::HashBase qw/checks _reduction/; |
|
|
168
|
|
|
|
|
338
|
|
|
|
168
|
|
|
|
|
1077
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
168
|
|
|
168
|
|
28834
|
use Test2::Compare::Delta(); |
|
|
168
|
|
|
|
|
342
|
|
|
|
168
|
|
|
|
|
5030
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
168
|
|
|
168
|
|
875
|
use Carp qw/croak confess/; |
|
|
168
|
|
|
|
|
328
|
|
|
|
168
|
|
|
|
|
9469
|
|
|
14
|
168
|
|
|
168
|
|
1057
|
use Scalar::Util qw/reftype/; |
|
|
168
|
|
|
|
|
339
|
|
|
|
168
|
|
|
|
|
101262
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
|
17
|
31
|
|
|
31
|
0
|
1806
|
my $self = shift; |
|
18
|
|
|
|
|
|
|
|
|
19
|
31
|
|
100
|
|
|
222
|
my $reduction = delete $self->{reduction} || 'any'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
31
|
|
100
|
|
|
196
|
$self->{+CHECKS} ||= []; |
|
22
|
|
|
|
|
|
|
|
|
23
|
31
|
|
|
|
|
141
|
$self->set_reduction($reduction); |
|
24
|
|
|
|
|
|
|
|
|
25
|
30
|
|
|
|
|
167
|
$self->SUPER::init(); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
5
|
|
|
5
|
1
|
40
|
sub name { '' } |
|
29
|
5
|
|
|
5
|
1
|
17
|
sub operator { $_[0]->{+_REDUCTION} } |
|
30
|
4
|
|
|
4
|
0
|
70
|
sub reduction { $_[0]->{+_REDUCTION} } |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my %VALID = (any => 1, all => 1, none => 1); |
|
33
|
|
|
|
|
|
|
sub set_reduction { |
|
34
|
55
|
|
|
55
|
0
|
86
|
my $self = shift; |
|
35
|
55
|
|
|
|
|
95
|
my ($redu) = @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
croak "'$redu' is not a valid set reduction" |
|
38
|
55
|
100
|
|
|
|
483
|
unless $VALID{$redu}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
53
|
|
|
|
|
120
|
$self->{+_REDUCTION} = $redu; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub verify { |
|
44
|
28
|
|
|
28
|
1
|
56
|
my $self = shift; |
|
45
|
28
|
|
|
|
|
85
|
my %params = @_; |
|
46
|
28
|
|
|
|
|
85
|
return 1; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub add_check { |
|
50
|
23
|
|
|
23
|
0
|
64
|
my $self = shift; |
|
51
|
23
|
|
|
|
|
29
|
push @{$self->{+CHECKS}} => @_; |
|
|
23
|
|
|
|
|
86
|
|
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub deltas { |
|
55
|
41
|
|
|
41
|
1
|
168
|
my $self = shift; |
|
56
|
41
|
|
|
|
|
119
|
my %params = @_; |
|
57
|
|
|
|
|
|
|
|
|
58
|
41
|
|
|
|
|
97
|
my $checks = $self->{+CHECKS}; |
|
59
|
41
|
|
|
|
|
78
|
my $reduction = $self->{+_REDUCTION}; |
|
60
|
41
|
|
|
|
|
71
|
my $convert = $params{convert}; |
|
61
|
|
|
|
|
|
|
|
|
62
|
41
|
100
|
100
|
|
|
209
|
unless ($checks && @$checks) { |
|
63
|
8
|
|
|
|
|
25
|
my $file = $self->file; |
|
64
|
8
|
|
|
|
|
22
|
my $lines = $self->lines; |
|
65
|
|
|
|
|
|
|
|
|
66
|
8
|
|
|
|
|
12
|
my $extra = ""; |
|
67
|
8
|
100
|
66
|
|
|
34
|
if ($file and $lines and @$lines) { |
|
|
|
|
100
|
|
|
|
|
|
68
|
4
|
100
|
|
|
|
16
|
my $lns = (@$lines > 1 ? 'lines ' : 'line ' ) . join ', ', @$lines; |
|
69
|
4
|
|
|
|
|
14
|
$extra = " (Set defined in $file $lns)"; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
8
|
|
|
|
|
44
|
die "No checks defined for set$extra\n"; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
33
|
|
|
|
|
71
|
my @deltas; |
|
76
|
33
|
|
|
|
|
73
|
my $i = 0; |
|
77
|
33
|
|
|
|
|
73
|
for my $check (@$checks) { |
|
78
|
89
|
|
|
|
|
196
|
my $c = $convert->($check); |
|
79
|
89
|
|
|
|
|
472
|
my $id = [META => "Check " . $i++]; |
|
80
|
89
|
|
|
|
|
415
|
my @d = $c->run(%params, id => $id); |
|
81
|
|
|
|
|
|
|
|
|
82
|
89
|
100
|
|
|
|
437
|
if ($reduction eq 'any') { |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
83
|
31
|
100
|
|
|
|
203
|
return () unless @d; |
|
84
|
19
|
|
|
|
|
47
|
push @deltas => @d; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
elsif ($reduction eq 'all') { |
|
87
|
47
|
|
|
|
|
152
|
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
|
|
|
|
48
|
check => $c, |
|
95
|
|
|
|
|
|
|
) unless @d; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
else { |
|
98
|
0
|
|
|
|
|
0
|
die "Invalid reduction: $reduction\n"; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
21
|
|
|
|
|
102
|
return @deltas; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |