line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
3
|
|
|
|
|
|
|
package Data::Rx::CoreType::arr; |
4
|
|
|
|
|
|
|
# ABSTRACT: the Rx //arr type |
5
|
|
|
|
|
|
|
$Data::Rx::CoreType::arr::VERSION = '0.200006'; |
6
|
1
|
|
|
1
|
|
5
|
use parent 'Data::Rx::CoreType'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
55
|
use Scalar::Util (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
602
|
|
9
|
|
|
|
|
|
|
|
10
|
54
|
|
|
54
|
0
|
217
|
sub subname { 'arr' } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub guts_from_arg { |
13
|
10
|
|
|
10
|
0
|
22
|
my ($class, $arg, $rx, $type) = @_; |
14
|
|
|
|
|
|
|
|
15
|
10
|
100
|
|
|
|
76
|
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
|
|
|
255
|
Carp::croak("no contents schema given") |
|
|
|
66
|
|
|
|
|
20
|
|
|
|
|
|
|
unless $arg->{contents} and (ref $arg->{contents} || 'HASH' eq 'HASH'); |
21
|
|
|
|
|
|
|
|
22
|
8
|
|
|
|
|
36
|
my $guts = { |
23
|
|
|
|
|
|
|
content_check => $rx->make_schema($arg->{contents}), |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
|
26
|
6
|
100
|
|
|
|
46
|
$guts->{length_check} = Data::Rx::Util->_make_range_check($arg->{length}) |
27
|
|
|
|
|
|
|
if $arg->{length}; |
28
|
|
|
|
|
|
|
|
29
|
6
|
|
100
|
|
|
36
|
$guts->{skip} = $arg->{skip} || 0; |
30
|
|
|
|
|
|
|
|
31
|
6
|
|
|
|
|
22
|
return $guts; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub assert_valid { |
35
|
114
|
|
|
114
|
0
|
19018
|
my ($self, $value) = @_; |
36
|
|
|
|
|
|
|
|
37
|
114
|
100
|
100
|
|
|
872
|
unless (! Scalar::Util::blessed($value) and ref $value eq 'ARRAY') { |
38
|
78
|
|
|
|
|
11695
|
$self->fail({ |
39
|
|
|
|
|
|
|
error => [ qw(type) ], |
40
|
|
|
|
|
|
|
message => "found value is not an arrayref", |
41
|
|
|
|
|
|
|
value => $value, |
42
|
|
|
|
|
|
|
}); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
36
|
|
|
|
|
54
|
my @subchecks; |
46
|
|
|
|
|
|
|
|
47
|
36
|
100
|
100
|
|
|
182
|
if ($self->{length_check} and |
48
|
|
|
|
|
|
|
! $self->{length_check}->(@$value - $self->{skip})) { |
49
|
5
|
|
|
|
|
675
|
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
|
|
|
|
|
479
|
for my $i ($self->{skip} .. $#$value) { |
59
|
88
|
|
|
|
|
594
|
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
|
|
|
|
|
164
|
$self->perform_subchecks(\@subchecks); |
70
|
|
|
|
|
|
|
|
71
|
24
|
|
|
|
|
341
|
return 1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |