line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Compare::Set; |
2
|
100
|
|
|
100
|
|
1092
|
use strict; |
|
100
|
|
|
|
|
196
|
|
|
100
|
|
|
|
|
2625
|
|
3
|
100
|
|
|
100
|
|
531
|
use warnings; |
|
100
|
|
|
|
|
191
|
|
|
100
|
|
|
|
|
2519
|
|
4
|
|
|
|
|
|
|
|
5
|
100
|
|
|
100
|
|
516
|
use Test::Stream::Compare; |
|
100
|
|
|
|
|
196
|
|
|
100
|
|
|
|
|
710
|
|
6
|
|
|
|
|
|
|
use Test::Stream::HashBase( |
7
|
100
|
|
|
|
|
770
|
base => 'Test::Stream::Compare', |
8
|
|
|
|
|
|
|
accessors => [qw/checks _reduction/], |
9
|
100
|
|
|
100
|
|
592
|
); |
|
100
|
|
|
|
|
200
|
|
10
|
|
|
|
|
|
|
|
11
|
100
|
|
|
100
|
|
578
|
use Test::Stream::Delta; |
|
100
|
|
|
|
|
206
|
|
|
100
|
|
|
|
|
2492
|
|
12
|
|
|
|
|
|
|
|
13
|
100
|
|
|
100
|
|
503
|
use Carp qw/croak confess/; |
|
100
|
|
|
|
|
208
|
|
|
100
|
|
|
|
|
5032
|
|
14
|
100
|
|
|
100
|
|
556
|
use Scalar::Util qw/reftype/; |
|
100
|
|
|
|
|
242
|
|
|
100
|
|
|
|
|
65467
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
29
|
|
|
29
|
0
|
44
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
29
|
|
100
|
|
|
125
|
my $reduction = delete $self->{reduction} || 'any'; |
20
|
|
|
|
|
|
|
|
21
|
29
|
|
100
|
|
|
109
|
$self->{+CHECKS} ||= []; |
22
|
|
|
|
|
|
|
|
23
|
29
|
|
|
|
|
75
|
$self->set_reduction($reduction); |
24
|
|
|
|
|
|
|
|
25
|
28
|
|
|
|
|
94
|
$self->SUPER::init(); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
5
|
1
|
26
|
sub name { '' } |
29
|
5
|
|
|
5
|
1
|
20
|
sub operator { $_[0]->{+_REDUCTION} } |
30
|
4
|
|
|
4
|
0
|
33
|
sub reduction { $_[0]->{+_REDUCTION} } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my %VALID = (any => 1, all => 1, none => 1); |
33
|
|
|
|
|
|
|
sub set_reduction { |
34
|
51
|
|
|
51
|
0
|
72
|
my $self = shift; |
35
|
51
|
|
|
|
|
80
|
my ($redu) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
croak "'$redu' is not a valid set reduction" |
38
|
51
|
100
|
|
|
|
460
|
unless $VALID{$redu}; |
39
|
|
|
|
|
|
|
|
40
|
49
|
|
|
|
|
121
|
$self->{+_REDUCTION} = $redu; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub verify { |
44
|
26
|
|
|
26
|
1
|
48
|
my $self = shift; |
45
|
26
|
|
|
|
|
74
|
my %params = @_; |
46
|
26
|
100
|
|
|
|
123
|
return $params{exists} ? 1 : 0; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub add_check { |
50
|
23
|
|
|
23
|
0
|
35
|
my $self = shift; |
51
|
23
|
|
|
|
|
34
|
push @{$self->{+CHECKS}} => @_; |
|
23
|
|
|
|
|
79
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub deltas { |
55
|
39
|
|
|
39
|
1
|
79
|
my $self = shift; |
56
|
39
|
|
|
|
|
101
|
my %params = @_; |
57
|
|
|
|
|
|
|
|
58
|
39
|
|
|
|
|
60
|
my $checks = $self->{+CHECKS}; |
59
|
39
|
|
|
|
|
62
|
my $reduction = $self->{+_REDUCTION}; |
60
|
39
|
|
|
|
|
79
|
my $convert = $params{convert}; |
61
|
|
|
|
|
|
|
|
62
|
39
|
100
|
100
|
|
|
176
|
unless ($checks && @$checks) { |
63
|
8
|
|
|
|
|
29
|
my $file = $self->file; |
64
|
8
|
|
|
|
|
27
|
my $lines = $self->lines; |
65
|
|
|
|
|
|
|
|
66
|
8
|
|
|
|
|
12
|
my $extra = ""; |
67
|
8
|
100
|
66
|
|
|
53
|
if ($file and $lines and @$lines) { |
|
|
|
100
|
|
|
|
|
68
|
4
|
100
|
|
|
|
17
|
my $lns = (@$lines > 1 ? 'lines ' : 'line ' ) . join ', ', @$lines; |
69
|
4
|
|
|
|
|
12
|
$extra = " (Set defined in $file $lns)"; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
8
|
|
|
|
|
68
|
die "No checks defined for set$extra\n"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
31
|
|
|
|
|
43
|
my @deltas; |
76
|
31
|
|
|
|
|
40
|
my $i = 0; |
77
|
31
|
|
|
|
|
61
|
for my $check (@$checks) { |
78
|
69
|
|
|
|
|
166
|
my $c = $convert->($check); |
79
|
69
|
|
|
|
|
242
|
my $id = [META => "Check " . $i++]; |
80
|
69
|
|
|
|
|
280
|
my @d = $c->run(%params, id => $id); |
81
|
|
|
|
|
|
|
|
82
|
69
|
100
|
|
|
|
218
|
if ($reduction eq 'any') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
83
|
37
|
100
|
|
|
|
195
|
return () unless @d; |
84
|
21
|
|
|
|
|
54
|
push @deltas => @d; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
elsif ($reduction eq 'all') { |
87
|
22
|
|
|
|
|
63
|
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
|
|
|
|
66
|
check => $c, |
95
|
|
|
|
|
|
|
) unless @d; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
else { |
98
|
0
|
|
|
|
|
0
|
die "Invalid reduction: $reduction\n"; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
15
|
|
|
|
|
110
|
return @deltas; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |