| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | package Data::Rx::CoreType::arr; | ||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: the Rx //arr type | ||||||||||||||||||||||||||||||||
| 5 | 1 | $Data::Rx::CoreType::arr::VERSION = '0.200007'; | |||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use parent 'Data::Rx::CoreType'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 54 | ▶ | sub subname { 'arr' } | ||||||||||||||||||||||||||||||
|
Subroutine
subname: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | sub guts_from_arg { | ||||||||||||||||||||||||||||||||
| 13 | 10 | ▶ | my ($class, $arg, $rx, $type) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
guts_from_arg: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 10 | ▶ | Carp::croak("unknown arguments to new") | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 16 | unless Data::Rx::Util->_x_subset_keys_y($arg, {length=>1, contents=>1, | ||||||||||||||||||||||||||||||||
| 17 | skip=>1}); | ||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | Carp::croak("no contents schema given") | ||||||||||||||||||||||||||||||||
| 20 | 9 | ▶ | unless $arg->{contents} and (ref $arg->{contents} || 'HASH' eq 'HASH'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
$arg->{"contents"} and
ref $arg->{"contents"} or
MC/DC0%0/2
$arg->{"contents"} and
$arg->{"contents"}
ref $arg->{"contents"}
Truth table66%2/3
A and B
A= $arg->{"contents"}B= ref $arg->{"contents"}
| |||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | my $guts = { | ||||||||||||||||||||||||||||||||
| 23 | 8 | content_check => $rx->make_schema($arg->{contents}), | |||||||||||||||||||||||||||||||
| 24 | }; | ||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | $guts->{length_check} = Data::Rx::Util->_make_range_check($arg->{length}) | ||||||||||||||||||||||||||||||||
| 27 | 6 | ▶ | if $arg->{length}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 6 | ▶ | $guts->{skip} = $arg->{skip} || 0; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$arg->{'skip'} || 0
MC/DC100%1/1
$arg->{'skip'} || 0
$arg->{'skip'}
Truth table100%2/2
A
A= $arg->{'skip'}
| |||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 6 | return $guts; | |||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | sub assert_valid { | ||||||||||||||||||||||||||||||||
| 35 | 114 | ▶ | my ($self, $value) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
assert_valid: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | 114 | ▶ | unless (! Scalar::Util::blessed($value) and ref $value eq 'ARRAY') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not builtin::blessed($value) and ref $value eq "ARRAY"
MC/DC100%2/2
not builtin::blessed($value) and ref $value eq "ARRAY"
not builtin::blessed($value)
ref $value eq "ARRAY"
Truth table100%3/3
not(A) and B
A= not builtin::blessed($value)B= ref $value eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 38 | 78 | $self->fail({ | |||||||||||||||||||||||||||||||
| 39 | error => [ qw(type) ], | ||||||||||||||||||||||||||||||||
| 40 | message => "found value is not an arrayref", | ||||||||||||||||||||||||||||||||
| 41 | value => $value, | ||||||||||||||||||||||||||||||||
| 42 | }); | ||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | 36 | my @subchecks; | |||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 36 | ▶ | if ($self->{length_check} and | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"length_check"} and not $self->{"length_check"}->(@$value - $self->{"skip"})
MC/DC100%2/2
$self->{"length_check"} and not $self->{"length_check"}->(@$value - $self->{"skip"})
$self->{"length_check"}
not $self->{"length_check"}->(@$value - $self->{"skip"})
Truth table100%3/3
A and not(B)
A= $self->{"length_check"}B= not $self->{"length_check"}->(@$value - $self->{"skip"})
| |||||||||||||||||||||||||||||||||
| 48 | ! $self->{length_check}->(@$value - $self->{skip})) { | ||||||||||||||||||||||||||||||||
| 49 | 5 | 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 | for my $i ($self->{skip} .. $#$value) { | |||||||||||||||||||||||||||||||
| 59 | push @subchecks, [ | ||||||||||||||||||||||||||||||||
| 60 | $value->[$i], | ||||||||||||||||||||||||||||||||
| 61 | $self->{content_check}, | ||||||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||||||
| 63 | 88 | data_path => [ [ $i, 'index' ] ], | |||||||||||||||||||||||||||||||
| 64 | check_path => [ [ 'contents', 'key'] ], | ||||||||||||||||||||||||||||||||
| 65 | }, | ||||||||||||||||||||||||||||||||
| 66 | ]; | ||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 36 | $self->perform_subchecks(\@subchecks); | |||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | 24 | return 1; | |||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | 1 | 1; | |||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | __END__ | ||||||||||||||||||||||||||||||||