Rx/CoreType/arr.pm

filter: Statementstmt 100% 32 / 32 Branchbran 100% 10 / 10 Conditioncond 92.3% 12 / 13 MC/DCmcdc 71.4% 5 / 7 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 91.6% 66 / 72 CC 12 SCAR 16.1
CC
12
Cov
98%
guts_from_arg
7.0
assert_valid
6.0
BEGIN
1.0
CRAP 5.0
« Rx/CoreType/seq.pm ↑ Summary Rx/CommonType.pm »
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
BranchTrueFalseTotal
unless "Data::Rx::Util"->_x_subset_keys_y($arg, {"length", 1, "contents", 1, "skip", 1}) 1 9 10
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
BranchTrueFalseTotal
unless 1 8 9
Condition80%4/5
$arg->{"contents"} and
!ll&&!rl&&r
108
ref $arg->{"contents"} or
l!l
71
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"}
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if $arg->{"length"} 5 1 6
28  
29 6 ▶ $guts->{skip} = $arg->{skip} || 0;
Condition100%2/2
$arg->{'skip'} || 0
l!l
33
MC/DC100%1/1
$arg->{'skip'} || 0
$arg->{'skip'}
Truth table100%2/2
A
A= $arg->{'skip'}
Aresult
11
00
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
BranchTrueFalseTotal
unless (not builtin::blessed($value) and ref $value eq "ARRAY") 78 36 114
Condition100%3/3
not builtin::blessed($value) and ref $value eq "ARRAY"
!ll&&!rl&&r
47436
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"
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if ($self->{"length_check"} and not $self->{"length_check"}->(@$value - $self->{"skip"})) 5 31 36
Condition100%3/3
$self->{"length_check"} and not $self->{"length_check"}->(@$value - $self->{"skip"})
!ll&&!rl&&r
15165
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"})
ABresult
0X0
100
111
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__
« Rx/CoreType/seq.pm ↑ Summary Rx/CommonType.pm »