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