line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
11
|
use v5.12.0; |
|
1
|
|
|
|
|
3
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
3
|
|
|
|
|
|
|
package Data::Rx::CoreType::seq 0.200008; |
4
|
|
|
|
|
|
|
# ABSTRACT: the Rx //seq type |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use parent 'Data::Rx::CoreType'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
76
|
use Scalar::Util (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
521
|
|
9
|
|
|
|
|
|
|
|
10
|
70
|
|
|
70
|
0
|
192
|
sub subname { 'seq' } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub guts_from_arg { |
13
|
8
|
|
|
8
|
0
|
26
|
my ($class, $arg, $rx, $type) = @_; |
14
|
|
|
|
|
|
|
|
15
|
8
|
100
|
|
|
|
62
|
Carp::croak("unknown arguments to new") |
16
|
|
|
|
|
|
|
unless Data::Rx::Util->_x_subset_keys_y($arg, {contents=>1,tail=>1}); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Carp::croak("no contents array given") |
19
|
7
|
100
|
100
|
|
|
330
|
unless $arg->{contents} and (ref $arg->{contents} eq 'ARRAY'); |
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
|
|
10
|
my $guts = {}; |
22
|
|
|
|
|
|
|
|
23
|
12
|
|
|
|
|
33
|
my @content_schemata = map { $rx->make_schema($_) } |
24
|
5
|
|
|
|
|
15
|
@{ $arg->{contents} }; |
|
5
|
|
|
|
|
13
|
|
25
|
|
|
|
|
|
|
|
26
|
5
|
|
|
|
|
17
|
$guts->{content_schemata} = \@content_schemata; |
27
|
|
|
|
|
|
|
$guts->{tail_check} = $arg->{tail} |
28
|
3
|
|
|
|
|
14
|
? $rx->make_schema({ %{$arg->{tail}}, |
29
|
5
|
100
|
|
|
|
22
|
skip => 0+@{$arg->{contents}}}) |
|
3
|
|
|
|
|
16
|
|
30
|
|
|
|
|
|
|
: undef; |
31
|
|
|
|
|
|
|
|
32
|
5
|
|
|
|
|
17
|
return $guts; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub assert_valid { |
36
|
141
|
|
|
141
|
0
|
9226
|
my ($self, $value) = @_; |
37
|
|
|
|
|
|
|
|
38
|
141
|
100
|
100
|
|
|
772
|
unless (! Scalar::Util::blessed($value) and ref $value eq 'ARRAY') { |
39
|
117
|
|
|
|
|
609
|
$self->fail({ |
40
|
|
|
|
|
|
|
error => [ qw(type) ], |
41
|
|
|
|
|
|
|
message => "found value is not an arrayref", |
42
|
|
|
|
|
|
|
value => $value, |
43
|
|
|
|
|
|
|
}); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
24
|
|
|
|
|
41
|
my @subchecks; |
47
|
|
|
|
|
|
|
|
48
|
24
|
|
|
|
|
46
|
my $content_schemata = $self->{content_schemata}; |
49
|
24
|
100
|
|
|
|
55
|
if (@$value < @$content_schemata) { |
50
|
2
|
|
|
|
|
23
|
push @subchecks, |
51
|
|
|
|
|
|
|
$self->new_fail({ |
52
|
|
|
|
|
|
|
error => [ qw(size) ], |
53
|
|
|
|
|
|
|
size => 0 + @$value, |
54
|
|
|
|
|
|
|
value => $value, |
55
|
|
|
|
|
|
|
message => sprintf( |
56
|
|
|
|
|
|
|
"too few entries found; found %s, need at least %s", |
57
|
|
|
|
|
|
|
0 + @$value, |
58
|
|
|
|
|
|
|
0 + @$content_schemata, |
59
|
|
|
|
|
|
|
), |
60
|
|
|
|
|
|
|
}); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
24
|
|
|
|
|
76
|
for my $i (0 .. $#$content_schemata) { |
64
|
60
|
100
|
|
|
|
118
|
last if $i > $#$value; |
65
|
58
|
|
|
|
|
270
|
push @subchecks, [ |
66
|
|
|
|
|
|
|
$value->[ $i ], |
67
|
|
|
|
|
|
|
$content_schemata->[ $i ], |
68
|
|
|
|
|
|
|
{ data_path => [ [$i, 'index' ] ], |
69
|
|
|
|
|
|
|
check_path => [ |
70
|
|
|
|
|
|
|
[ 'contents', 'key' ], |
71
|
|
|
|
|
|
|
[ $i, 'index' ] |
72
|
|
|
|
|
|
|
], |
73
|
|
|
|
|
|
|
}, |
74
|
|
|
|
|
|
|
]; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
24
|
100
|
|
|
|
60
|
if (@$value > @$content_schemata) { |
78
|
19
|
100
|
|
|
|
52
|
if ($self->{tail_check}) { |
79
|
|
|
|
|
|
|
push @subchecks, [ |
80
|
|
|
|
|
|
|
$value, |
81
|
|
|
|
|
|
|
$self->{tail_check}, |
82
|
11
|
|
|
|
|
43
|
{ check_path => [ ['tail', 'key' ] ] }, |
83
|
|
|
|
|
|
|
]; |
84
|
|
|
|
|
|
|
} else { |
85
|
8
|
|
|
|
|
71
|
push @subchecks, |
86
|
|
|
|
|
|
|
$self->new_fail({ |
87
|
|
|
|
|
|
|
error => [ qw(size) ], |
88
|
|
|
|
|
|
|
size => 0 + @$value, |
89
|
|
|
|
|
|
|
value => $value, |
90
|
|
|
|
|
|
|
message => sprintf( |
91
|
|
|
|
|
|
|
"too many entries found; found %s, need no more than %s", |
92
|
|
|
|
|
|
|
0 + @$value, |
93
|
|
|
|
|
|
|
0 + @$content_schemata, |
94
|
|
|
|
|
|
|
), |
95
|
|
|
|
|
|
|
}); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
24
|
|
|
|
|
104
|
$self->perform_subchecks(\@subchecks); |
100
|
|
|
|
|
|
|
|
101
|
7
|
|
|
|
|
41
|
return 1; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |