| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test2::Compare::OrderedSubset; |
|
2
|
169
|
|
|
169
|
|
1187
|
use strict; |
|
|
169
|
|
|
|
|
388
|
|
|
|
169
|
|
|
|
|
4921
|
|
|
3
|
169
|
|
|
169
|
|
911
|
use warnings; |
|
|
169
|
|
|
|
|
366
|
|
|
|
169
|
|
|
|
|
4452
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
169
|
|
|
169
|
|
858
|
use base 'Test2::Compare::Base'; |
|
|
169
|
|
|
|
|
371
|
|
|
|
169
|
|
|
|
|
19363
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
169
|
|
|
169
|
|
1262
|
use Test2::Util::HashBase qw/inref items/; |
|
|
169
|
|
|
|
|
421
|
|
|
|
169
|
|
|
|
|
1207
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
169
|
|
|
169
|
|
30494
|
use Carp qw/croak/; |
|
|
169
|
|
|
|
|
398
|
|
|
|
169
|
|
|
|
|
8396
|
|
|
12
|
169
|
|
|
169
|
|
1031
|
use Scalar::Util qw/reftype/; |
|
|
169
|
|
|
|
|
464
|
|
|
|
169
|
|
|
|
|
85273
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub init { |
|
15
|
38
|
|
|
38
|
0
|
1441
|
my $self = shift; |
|
16
|
|
|
|
|
|
|
|
|
17
|
38
|
100
|
|
|
|
124
|
if(my $ref = $self->{+INREF}) { |
|
18
|
3
|
50
|
|
|
|
9
|
croak "Cannot specify both 'inref' and 'items'" if $self->{+ITEMS}; |
|
19
|
3
|
100
|
|
|
|
249
|
croak "'inref' must be an array reference, got '$ref'" unless reftype($ref) eq 'ARRAY'; |
|
20
|
2
|
|
|
|
|
6
|
$self->{+ITEMS} = [@{$self->{+INREF}}]; |
|
|
2
|
|
|
|
|
7
|
|
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
37
|
|
100
|
|
|
198
|
$self->{+ITEMS} ||= []; |
|
24
|
|
|
|
|
|
|
|
|
25
|
37
|
|
|
|
|
134
|
$self->SUPER::init(); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
1
|
23
|
sub name { '' } |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub verify { |
|
31
|
38
|
|
|
38
|
1
|
86
|
my $self = shift; |
|
32
|
38
|
|
|
|
|
145
|
my %params = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
38
|
100
|
|
|
|
123
|
return 0 unless $params{exists}; |
|
35
|
37
|
100
|
|
|
|
126
|
defined( my $got = $params{got} ) || return 0; |
|
36
|
36
|
100
|
|
|
|
105
|
return 0 unless ref($got); |
|
37
|
33
|
100
|
|
|
|
111
|
return 0 unless reftype($got) eq 'ARRAY'; |
|
38
|
32
|
|
|
|
|
100
|
return 1; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub add_item { |
|
42
|
53
|
|
|
53
|
1
|
100
|
my $self = shift; |
|
43
|
53
|
|
|
|
|
90
|
my $check = pop; |
|
44
|
|
|
|
|
|
|
|
|
45
|
53
|
|
|
|
|
73
|
push @{$self->{+ITEMS}} => $check; |
|
|
53
|
|
|
|
|
309
|
|
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub deltas { |
|
49
|
35
|
|
|
35
|
1
|
72
|
my $self = shift; |
|
50
|
35
|
|
|
|
|
95
|
my %params = @_; |
|
51
|
35
|
|
|
|
|
92
|
my ($got, $convert, $seen) = @params{qw/got convert seen/}; |
|
52
|
|
|
|
|
|
|
|
|
53
|
35
|
|
|
|
|
53
|
my @deltas; |
|
54
|
35
|
|
|
|
|
57
|
my $state = 0; |
|
55
|
35
|
|
|
|
|
60
|
my $items = $self->{+ITEMS}; |
|
56
|
|
|
|
|
|
|
|
|
57
|
35
|
|
|
|
|
58
|
my $idx = 0; |
|
58
|
|
|
|
|
|
|
|
|
59
|
35
|
|
|
|
|
87
|
for my $item (@$items) { |
|
60
|
56
|
|
|
|
|
148
|
my $check = $convert->($item); |
|
61
|
|
|
|
|
|
|
|
|
62
|
56
|
|
|
|
|
159
|
my $i = $idx; |
|
63
|
56
|
|
|
|
|
80
|
my $found; |
|
64
|
56
|
|
|
|
|
211
|
while($i < @$got) { |
|
65
|
57
|
|
|
|
|
140
|
my $val = $got->[$i++]; |
|
66
|
57
|
100
|
|
|
|
257
|
next if $check->run( |
|
67
|
|
|
|
|
|
|
id => [ARRAY => $i], |
|
68
|
|
|
|
|
|
|
convert => $convert, |
|
69
|
|
|
|
|
|
|
seen => $seen, |
|
70
|
|
|
|
|
|
|
exists => 1, |
|
71
|
|
|
|
|
|
|
got => $val, |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
|
|
74
|
54
|
|
|
|
|
126
|
$idx = $i; |
|
75
|
54
|
|
|
|
|
91
|
$found++; |
|
76
|
54
|
|
|
|
|
119
|
last; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
56
|
100
|
|
|
|
168
|
next if $found; |
|
80
|
|
|
|
|
|
|
|
|
81
|
2
|
|
|
|
|
22
|
push @deltas => Test2::Compare::Delta->new( |
|
82
|
|
|
|
|
|
|
verified => 0, |
|
83
|
|
|
|
|
|
|
id => ['ARRAY', '?'], |
|
84
|
|
|
|
|
|
|
check => $check, |
|
85
|
|
|
|
|
|
|
dne => 'got', |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
35
|
|
|
|
|
132
|
return @deltas; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |