| 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::seq; | ||||||||||||||||||||||||||||
| 4 | # ABSTRACT: the Rx //seq type | ||||||||||||||||||||||||||||
| 5 | 1 | $Data::Rx::CoreType::seq::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 { 'seq' } | ||||||||||||||||||||||||||
|
Subroutine
subname: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | sub guts_from_arg { | ||||||||||||||||||||||||||||
| 13 | 8 | ▶ | my ($class, $arg, $rx, $type) = @_; | ||||||||||||||||||||||||||
|
Subroutine
guts_from_arg: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 8 | ▶ | Carp::croak("unknown arguments to new") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | unless Data::Rx::Util->_x_subset_keys_y($arg, {contents=>1,tail=>1}); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | Carp::croak("no contents array given") | ||||||||||||||||||||||||||||
| 19 | 7 | ▶ | unless $arg->{contents} and (ref $arg->{contents} eq 'ARRAY'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$arg->{"contents"} and ref $arg->{"contents"} eq "ARRAY"
MC/DC100%2/2
$arg->{"contents"} and ref $arg->{"contents"} eq "ARRAY"
$arg->{"contents"}
ref $arg->{"contents"} eq "ARRAY"
Truth table100%3/3
A and B
A= $arg->{"contents"}B= ref $arg->{"contents"} eq "ARRAY"
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 5 | my $guts = {}; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 12 | my @content_schemata = map { $rx->make_schema($_) } | |||||||||||||||||||||||||||
| 24 | 5 | @{ $arg->{contents} }; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 5 | $guts->{content_schemata} = \@content_schemata; | |||||||||||||||||||||||||||
| 27 | $guts->{tail_check} = $arg->{tail} | ||||||||||||||||||||||||||||
| 28 | 3 | ? $rx->make_schema({ %{$arg->{tail}}, | |||||||||||||||||||||||||||
| 29 | 5 | ▶ | skip => 0+@{$arg->{contents}}}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | : undef; | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 5 | return $guts; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | sub assert_valid { | ||||||||||||||||||||||||||||
| 36 | 141 | ▶ | my ($self, $value) = @_; | ||||||||||||||||||||||||||
|
Subroutine
assert_valid: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 141 | ▶ | 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"
| |||||||||||||||||||||||||||||
| 39 | 117 | $self->fail({ | |||||||||||||||||||||||||||
| 40 | error => [ qw(type) ], | ||||||||||||||||||||||||||||
| 41 | message => "found value is not an arrayref", | ||||||||||||||||||||||||||||
| 42 | value => $value, | ||||||||||||||||||||||||||||
| 43 | }); | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 24 | my @subchecks; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 24 | my $content_schemata = $self->{content_schemata}; | |||||||||||||||||||||||||||
| 49 | 24 | ▶ | if (@$value < @$content_schemata) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 2 | 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 | for my $i (0 .. $#$content_schemata) { | |||||||||||||||||||||||||||
| 64 | 60 | ▶ | last if $i > $#$value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 58 | 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 | ▶ | if (@$value > @$content_schemata) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 19 | ▶ | if ($self->{tail_check}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | push @subchecks, [ | ||||||||||||||||||||||||||||
| 80 | $value, | ||||||||||||||||||||||||||||
| 81 | $self->{tail_check}, | ||||||||||||||||||||||||||||
| 82 | 11 | { check_path => [ ['tail', 'key' ] ] }, | |||||||||||||||||||||||||||
| 83 | ]; | ||||||||||||||||||||||||||||
| 84 | } else { | ||||||||||||||||||||||||||||
| 85 | 8 | 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 | $self->perform_subchecks(\@subchecks); | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 7 | return 1; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 1 | 1; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | __END__ | ||||||||||||||||||||||||||||