line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Compare::Set; |
2
|
100
|
|
|
100
|
|
1058
|
use strict; |
|
100
|
|
|
|
|
204
|
|
|
100
|
|
|
|
|
2729
|
|
3
|
100
|
|
|
100
|
|
590
|
use warnings; |
|
100
|
|
|
|
|
191
|
|
|
100
|
|
|
|
|
2532
|
|
4
|
|
|
|
|
|
|
|
5
|
100
|
|
|
100
|
|
583
|
use Test::Stream::Compare; |
|
100
|
|
|
|
|
196
|
|
|
100
|
|
|
|
|
726
|
|
6
|
|
|
|
|
|
|
use Test::Stream::HashBase( |
7
|
100
|
|
|
|
|
786
|
base => 'Test::Stream::Compare', |
8
|
|
|
|
|
|
|
accessors => [qw/checks _reduction/], |
9
|
100
|
|
|
100
|
|
536
|
); |
|
100
|
|
|
|
|
202
|
|
10
|
|
|
|
|
|
|
|
11
|
100
|
|
|
100
|
|
565
|
use Test::Stream::Delta; |
|
100
|
|
|
|
|
199
|
|
|
100
|
|
|
|
|
2497
|
|
12
|
|
|
|
|
|
|
|
13
|
100
|
|
|
100
|
|
493
|
use Carp qw/croak confess/; |
|
100
|
|
|
|
|
199
|
|
|
100
|
|
|
|
|
5200
|
|
14
|
100
|
|
|
100
|
|
534
|
use Scalar::Util qw/reftype/; |
|
100
|
|
|
|
|
212
|
|
|
100
|
|
|
|
|
65835
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
29
|
|
|
29
|
0
|
43
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
29
|
|
100
|
|
|
152
|
my $reduction = delete $self->{reduction} || 'any'; |
20
|
|
|
|
|
|
|
|
21
|
29
|
|
100
|
|
|
99
|
$self->{+CHECKS} ||= []; |
22
|
|
|
|
|
|
|
|
23
|
29
|
|
|
|
|
77
|
$self->set_reduction($reduction); |
24
|
|
|
|
|
|
|
|
25
|
28
|
|
|
|
|
95
|
$self->SUPER::init(); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
5
|
1
|
26
|
sub name { '' } |
29
|
5
|
|
|
5
|
1
|
19
|
sub operator { $_[0]->{+_REDUCTION} } |
30
|
4
|
|
|
4
|
0
|
29
|
sub reduction { $_[0]->{+_REDUCTION} } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my %VALID = (any => 1, all => 1, none => 1); |
33
|
|
|
|
|
|
|
sub set_reduction { |
34
|
51
|
|
|
51
|
0
|
69
|
my $self = shift; |
35
|
51
|
|
|
|
|
83
|
my ($redu) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
croak "'$redu' is not a valid set reduction" |
38
|
51
|
100
|
|
|
|
451
|
unless $VALID{$redu}; |
39
|
|
|
|
|
|
|
|
40
|
49
|
|
|
|
|
113
|
$self->{+_REDUCTION} = $redu; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub verify { |
44
|
26
|
|
|
26
|
1
|
47
|
my $self = shift; |
45
|
26
|
|
|
|
|
78
|
my %params = @_; |
46
|
26
|
100
|
|
|
|
119
|
return $params{exists} ? 1 : 0; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub add_check { |
50
|
23
|
|
|
23
|
0
|
32
|
my $self = shift; |
51
|
23
|
|
|
|
|
31
|
push @{$self->{+CHECKS}} => @_; |
|
23
|
|
|
|
|
83
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub deltas { |
55
|
39
|
|
|
39
|
1
|
76
|
my $self = shift; |
56
|
39
|
|
|
|
|
114
|
my %params = @_; |
57
|
|
|
|
|
|
|
|
58
|
39
|
|
|
|
|
65
|
my $checks = $self->{+CHECKS}; |
59
|
39
|
|
|
|
|
57
|
my $reduction = $self->{+_REDUCTION}; |
60
|
39
|
|
|
|
|
58
|
my $convert = $params{convert}; |
61
|
|
|
|
|
|
|
|
62
|
39
|
100
|
100
|
|
|
187
|
unless ($checks && @$checks) { |
63
|
8
|
|
|
|
|
28
|
my $file = $self->file; |
64
|
8
|
|
|
|
|
27
|
my $lines = $self->lines; |
65
|
|
|
|
|
|
|
|
66
|
8
|
|
|
|
|
9
|
my $extra = ""; |
67
|
8
|
100
|
66
|
|
|
46
|
if ($file and $lines and @$lines) { |
|
|
|
100
|
|
|
|
|
68
|
4
|
100
|
|
|
|
14
|
my $lns = (@$lines > 1 ? 'lines ' : 'line ' ) . join ', ', @$lines; |
69
|
4
|
|
|
|
|
13
|
$extra = " (Set defined in $file $lns)"; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
8
|
|
|
|
|
64
|
die "No checks defined for set$extra\n"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
31
|
|
|
|
|
39
|
my @deltas; |
76
|
31
|
|
|
|
|
36
|
my $i = 0; |
77
|
31
|
|
|
|
|
61
|
for my $check (@$checks) { |
78
|
69
|
|
|
|
|
167
|
my $c = $convert->($check); |
79
|
69
|
|
|
|
|
237
|
my $id = [META => "Check " . $i++]; |
80
|
69
|
|
|
|
|
266
|
my @d = $c->run(%params, id => $id); |
81
|
|
|
|
|
|
|
|
82
|
69
|
100
|
|
|
|
216
|
if ($reduction eq 'any') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
83
|
37
|
100
|
|
|
|
188
|
return () unless @d; |
84
|
21
|
|
|
|
|
56
|
push @deltas => @d; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
elsif ($reduction eq 'all') { |
87
|
22
|
|
|
|
|
62
|
push @deltas => @d; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
elsif ($reduction eq 'none') { |
90
|
|
|
|
|
|
|
push @deltas => Test::Stream::Delta->new( |
91
|
|
|
|
|
|
|
verified => 0, |
92
|
|
|
|
|
|
|
id => $id, |
93
|
|
|
|
|
|
|
got => $params{got}, |
94
|
10
|
100
|
|
|
|
60
|
check => $c, |
95
|
|
|
|
|
|
|
) unless @d; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
else { |
98
|
0
|
|
|
|
|
0
|
die "Invalid reduction: $reduction\n"; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
15
|
|
|
|
|
77
|
return @deltas; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |