Data/Sah/Compiler/human/TH/HasElems.pm

filter: Statementstmt 85.3% 35 / 41 Branchbran 40.9% 9 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 3 totaltotal 70.6% 53 / 75 CC 12 SCAR 29.6
CC
12
Cov
70%
superclause_has_elems
31.5
BEGIN
1.0
BEGIN
1.0
CRAP 19.3
« Data/Sah/Compiler/human.pm ↑ Summary Test/Data/Sah/Perl.pm »
1 package Data::Sah::Compiler::human::TH::HasElems;
2  
3 17 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 #use Log::Any '$log';
7  
8 17 ▶use Mo qw(build default);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 17 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 17 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 17 with 'Data::Sah::Type::HasElems';
13  
14 17 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
15 17 our $DATE = '2024-02-16'; # DATE
16 17 our $DIST = 'Data-Sah'; # DIST
17 17 our $VERSION = '0.917'; # VERSION
18  
19 3051 ▶sub before_clause {
Subroutine before_clause: called CC=1 SCAR=0.0
Pod undocumented
20 3051 my ($self_th, $which, $cd) = @_;
21 }
22  
23 30 ▶sub before_clause_len_between {
Subroutine before_clause_len_between: called CC=1 SCAR=0.0
Pod undocumented
24 30 my ($self, $cd) = @_;
25 30 $cd->{CLAUSE_DO_MULTI} = 0;
26 }
27  
28 324 ▶sub superclause_has_elems {
Subroutine superclause_has_elems: called CC=12 SCAR=34.5
Pod undocumented
29 324 my ($self_th, $which, $cd) = @_;
30 324 my $c = $self_th->compiler;
31 324 my $cv = $cd->{cl_value};
32  
33 324 ▶ if ($which eq 'len') {
Branch: 11 branches
BranchTrueFalseTotal
if ($which eq 'len') { } 96 228 324
elsif ($which eq 'min_len') { } 98 130 228
elsif ($which eq 'max_len') { } 51 79 130
elsif ($which eq 'len_between') { } 30 49 79
elsif ($which eq 'has') { } 49 0 49
elsif ($which eq 'each_index') { } 0 0 0
elsif ($which eq 'each_elem') { } 0 0 0
elsif ($which eq 'check_each_index') { } 0 0 0
elsif ($which eq 'check_each_elem') { } 0 0 0
elsif ($which eq 'uniq') { } 0 0 0
elsif ($which eq 'exists') { } 0 0 0
34 96 $c->add_ccl($cd, {
35 expr => 1,
36 fmt => q[length %(modal_verb)s be %s],
37 });
38 } elsif ($which eq 'min_len') {
39 98 $c->add_ccl($cd, {
40 expr => 1,
41 fmt => q[length %(modal_verb)s be at least %s],
42 });
43 } elsif ($which eq 'max_len') {
44 51 $c->add_ccl($cd, {
45 expr => 1,
46 fmt => q[length %(modal_verb)s be at most %s],
47 });
48 } elsif ($which eq 'len_between') {
49 30 $c->add_ccl($cd, {
50 fmt => q[length %(modal_verb)s be between %s and %s],
51 vals => $cv,
52 });
53 } elsif ($which eq 'has') {
54 49 $c->add_ccl($cd, {
55 expr=>1, multi=>1,
56 fmt => "%(modal_verb)s have %s in its elements"});
57 } elsif ($which eq 'each_index') {
58 0 $self_th->clause_each_index($cd);
59 } elsif ($which eq 'each_elem') {
60 0 $self_th->clause_each_elem($cd);
61 } elsif ($which eq 'check_each_index') {
62 0 $self_th->compiler->_die_unimplemented_clause($cd);
63 } elsif ($which eq 'check_each_elem') {
64 0 $self_th->compiler->_die_unimplemented_clause($cd);
65 } elsif ($which eq 'uniq') {
66 0 $self_th->compiler->_die_unimplemented_clause($cd);
67 } elsif ($which eq 'exists') {
68 0 $self_th->compiler->_die_unimplemented_clause($cd);
69 }
70 }
71  
72 17 1;
73 # ABSTRACT: human's type handler for role "HasElems"
74  
75 __END__
« Data/Sah/Compiler/human.pm ↑ Summary Test/Data/Sah/Perl.pm »