| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
3
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
24
|
|
|
2
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
35
|
|
|
3
|
|
|
|
|
|
|
package Data::Rx::CoreType::arr; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: the Rx //arr type |
|
5
|
|
|
|
|
|
|
$Data::Rx::CoreType::arr::VERSION = '0.200007'; |
|
6
|
1
|
|
|
1
|
|
3
|
use parent 'Data::Rx::CoreType'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
33
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
38
|
use Scalar::Util (); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
280
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
54
|
|
|
54
|
0
|
123
|
sub subname { 'arr' } |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub guts_from_arg { |
|
13
|
10
|
|
|
10
|
0
|
16
|
my ($class, $arg, $rx, $type) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
10
|
100
|
|
|
|
53
|
Carp::croak("unknown arguments to new") |
|
16
|
|
|
|
|
|
|
unless Data::Rx::Util->_x_subset_keys_y($arg, {length=>1, contents=>1, |
|
17
|
|
|
|
|
|
|
skip=>1}); |
|
18
|
|
|
|
|
|
|
|
|
19
|
9
|
100
|
100
|
|
|
335
|
Carp::croak("no contents schema given") |
|
|
|
|
66
|
|
|
|
|
|
20
|
|
|
|
|
|
|
unless $arg->{contents} and (ref $arg->{contents} || 'HASH' eq 'HASH'); |
|
21
|
|
|
|
|
|
|
|
|
22
|
8
|
|
|
|
|
21
|
my $guts = { |
|
23
|
|
|
|
|
|
|
content_check => $rx->make_schema($arg->{contents}), |
|
24
|
|
|
|
|
|
|
}; |
|
25
|
|
|
|
|
|
|
|
|
26
|
6
|
100
|
|
|
|
34
|
$guts->{length_check} = Data::Rx::Util->_make_range_check($arg->{length}) |
|
27
|
|
|
|
|
|
|
if $arg->{length}; |
|
28
|
|
|
|
|
|
|
|
|
29
|
6
|
|
100
|
|
|
28
|
$guts->{skip} = $arg->{skip} || 0; |
|
30
|
|
|
|
|
|
|
|
|
31
|
6
|
|
|
|
|
19
|
return $guts; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub assert_valid { |
|
35
|
114
|
|
|
114
|
0
|
7094
|
my ($self, $value) = @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
114
|
100
|
100
|
|
|
485
|
unless (! Scalar::Util::blessed($value) and ref $value eq 'ARRAY') { |
|
38
|
78
|
|
|
|
|
303
|
$self->fail({ |
|
39
|
|
|
|
|
|
|
error => [ qw(type) ], |
|
40
|
|
|
|
|
|
|
message => "found value is not an arrayref", |
|
41
|
|
|
|
|
|
|
value => $value, |
|
42
|
|
|
|
|
|
|
}); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
36
|
|
|
|
|
24
|
my @subchecks; |
|
46
|
|
|
|
|
|
|
|
|
47
|
36
|
100
|
100
|
|
|
124
|
if ($self->{length_check} and |
|
48
|
|
|
|
|
|
|
! $self->{length_check}->(@$value - $self->{skip})) { |
|
49
|
5
|
|
|
|
|
107
|
push @subchecks, |
|
50
|
|
|
|
|
|
|
$self->new_fail({ |
|
51
|
|
|
|
|
|
|
error => [ qw(size) ], |
|
52
|
|
|
|
|
|
|
size => 0 + @$value, # note: actual size, not size - skip |
|
53
|
|
|
|
|
|
|
message => "number of entries is outside permitted range", |
|
54
|
|
|
|
|
|
|
value => $value, |
|
55
|
|
|
|
|
|
|
}); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
36
|
|
|
|
|
308
|
for my $i ($self->{skip} .. $#$value) { |
|
59
|
88
|
|
|
|
|
322
|
push @subchecks, [ |
|
60
|
|
|
|
|
|
|
$value->[$i], |
|
61
|
|
|
|
|
|
|
$self->{content_check}, |
|
62
|
|
|
|
|
|
|
{ |
|
63
|
|
|
|
|
|
|
data_path => [ [ $i, 'index' ] ], |
|
64
|
|
|
|
|
|
|
check_path => [ [ 'contents', 'key'] ], |
|
65
|
|
|
|
|
|
|
}, |
|
66
|
|
|
|
|
|
|
]; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
36
|
|
|
|
|
95
|
$self->perform_subchecks(\@subchecks); |
|
70
|
|
|
|
|
|
|
|
|
71
|
24
|
|
|
|
|
84
|
return 1; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |