File Coverage

blib/lib/Data/Sah/Compiler/human/TH/HasElems.pm
Criterion Covered Total %
statement 29 35 82.8
branch 9 22 40.9
condition n/a
subroutine 9 9 100.0
pod 0 3 0.0
total 47 69 68.1


line stmt bran cond sub pod time code
1              
2             use 5.010;
3 11     11   4804 use strict;
  11         33  
4 11     11   49 use warnings;
  11         17  
  11         212  
5 11     11   46 #use Log::Any '$log';
  11         17  
  11         326  
6              
7             use Mo qw(build default);
8 11     11   54 use Role::Tiny;
  11         27  
  11         52  
9 11     11   2629 use Role::Tiny::With;
  11         20  
  11         49  
10 11     11   2434  
  11         17  
  11         4077  
11             with 'Data::Sah::Type::HasElems';
12              
13             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
14             our $DATE = '2022-09-30'; # DATE
15             our $DIST = 'Data-Sah'; # DIST
16             our $VERSION = '0.913'; # VERSION
17              
18             my ($self_th, $which, $cd) = @_;
19             }
20 3051     3051 0 7429  
21             my ($self, $cd) = @_;
22             $cd->{CLAUSE_DO_MULTI} = 0;
23             }
24 30     30 0 61  
25 30         55 my ($self_th, $which, $cd) = @_;
26             my $c = $self_th->compiler;
27             my $cv = $cd->{cl_value};
28              
29 324     324 0 556 if ($which eq 'len') {
30 324         906 $c->add_ccl($cd, {
31 324         1429 expr => 1,
32             fmt => q[length %(modal_verb)s be %s],
33 324 100       951 });
    100          
    100          
    100          
    50          
    0          
    0          
    0          
    0          
    0          
    0          
34 96         388 } elsif ($which eq 'min_len') {
35             $c->add_ccl($cd, {
36             expr => 1,
37             fmt => q[length %(modal_verb)s be at least %s],
38             });
39 98         371 } elsif ($which eq 'max_len') {
40             $c->add_ccl($cd, {
41             expr => 1,
42             fmt => q[length %(modal_verb)s be at most %s],
43             });
44 51         204 } elsif ($which eq 'len_between') {
45             $c->add_ccl($cd, {
46             fmt => q[length %(modal_verb)s be between %s and %s],
47             vals => $cv,
48             });
49 30         125 } elsif ($which eq 'has') {
50             $c->add_ccl($cd, {
51             expr=>1, multi=>1,
52             fmt => "%(modal_verb)s have %s in its elements"});
53             } elsif ($which eq 'each_index') {
54 49         224 $self_th->clause_each_index($cd);
55             } elsif ($which eq 'each_elem') {
56             $self_th->clause_each_elem($cd);
57             } elsif ($which eq 'check_each_index') {
58 0           $self_th->compiler->_die_unimplemented_clause($cd);
59             } elsif ($which eq 'check_each_elem') {
60 0           $self_th->compiler->_die_unimplemented_clause($cd);
61             } elsif ($which eq 'uniq') {
62 0           $self_th->compiler->_die_unimplemented_clause($cd);
63             } elsif ($which eq 'exists') {
64 0           $self_th->compiler->_die_unimplemented_clause($cd);
65             }
66 0           }
67              
68 0           1;
69             # ABSTRACT: human's type handler for role "HasElems"
70              
71              
72             =pod
73              
74             =encoding UTF-8
75              
76             =head1 NAME
77              
78             Data::Sah::Compiler::human::TH::HasElems - human's type handler for role "HasElems"
79              
80             =head1 VERSION
81              
82             This document describes version 0.913 of Data::Sah::Compiler::human::TH::HasElems (from Perl distribution Data-Sah), released on 2022-09-30.
83              
84             =for Pod::Coverage ^(name|clause_.+|superclause_.+|before_.+|after_.+)$
85              
86             =head1 HOMEPAGE
87              
88             Please visit the project's homepage at L<https://metacpan.org/release/Data-Sah>.
89              
90             =head1 SOURCE
91              
92             Source repository is at L<https://github.com/perlancar/perl-Data-Sah>.
93              
94             =head1 AUTHOR
95              
96             perlancar <perlancar@cpan.org>
97              
98             =head1 CONTRIBUTING
99              
100              
101             To contribute, you can send patches by email/via RT, or send pull requests on
102             GitHub.
103              
104             Most of the time, you don't need to build the distribution yourself. You can
105             simply modify the code, then test via:
106              
107             % prove -l
108              
109             If you want to build the distribution (e.g. to try to install it locally on your
110             system), you can install L<Dist::Zilla>,
111             L<Dist::Zilla::PluginBundle::Author::PERLANCAR>,
112             L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
113             Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
114             that are considered a bug and can be reported to me.
115              
116             =head1 COPYRIGHT AND LICENSE
117              
118             This software is copyright (c) 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012 by perlancar <perlancar@cpan.org>.
119              
120             This is free software; you can redistribute it and/or modify it under
121             the same terms as the Perl 5 programming language system itself.
122              
123             =head1 BUGS
124              
125             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah>
126              
127             When submitting a bug or request, please include a test-file or a
128             patch to an existing test-file that illustrates the bug or desired
129             feature.
130              
131             =cut