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

filter: Statementstmt 82.4% 47 / 57 Branchbran 25.0% 2 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 72.1% 57 / 79 CC 9 SCAR 21.4
CC
9
Cov
74%
clause_of
13.5
BEGIN
1.0
BEGIN
1.0
CRAP 8.5
« Data/Sah/Compiler/human/TH/int.pm ↑ Summary Data/Sah/Compiler/human/TH/any.pm »
1 package Data::Sah::Compiler::human::TH::all;
2  
3 3 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 #use Log::Any '$log';
7  
8 3 ▶use Mo qw(build default);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 extends 'Data::Sah::Compiler::human::TH';
12 3 with 'Data::Sah::Type::all';
13  
14 3 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
15 3 our $DATE = '2024-02-16'; # DATE
16 3 our $DIST = 'Data-Sah'; # DIST
17 3 our $VERSION = '0.917'; # VERSION
18  
19 13 ▶sub handle_type {
Subroutine handle_type: called CC=1 SCAR=0.0
Pod undocumented
20 }
21  
22 13 ▶sub clause_of {
Subroutine clause_of: called CC=9 SCAR=26.1
Pod undocumented
23 13 my ($self, $cd) = @_;
24 13 my $c = $self->compiler;
25 13 my $cv = $cd->{cl_value};
26  
27 13 my @result;
28 13 my $i = 0;
29 13 for my $cv2 (@$cv) {
30 26 local $cd->{spath} = [@{$cd->{spath}}, $i];
31 26 my %iargs = %{$cd->{args}};
32 26 $iargs{outer_cd} = $cd;
33 26 $iargs{schema} = $cv2;
34 26 $iargs{cache} = $cd->{args}{cache};
35 26 $iargs{schema_is_normalized} = 0;
36 26 my $icd = $c->compile(%iargs);
37 26 push @result, $icd->{ccls};
38 26 $c->_add_msg_catalog($cd, $icd->{ccls});
39 26 $i++;
40 }
41  
42 # can we say 'NOUN1 as well as NOUN2 as well as NOUN3 ...'?
43 13 my $can = 1;
44 13 for my $r (@result) {
45 13 ▶ unless (@$r == 1 && $r->[0]{type} eq 'noun') {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$r == 1 and $r->[0]{"type"} eq "noun") 13 0 13
Condition33%1/3
@$r == 1 and $r->[0]{"type"} eq "noun"
!ll&&!rl&&r
1300
MC/DC0%0/2
@$r == 1 and $r->[0]{"type"} eq "noun"
@$r == 1 $r->[0]{"type"} eq "noun"
Truth table33%1/3
A and B
A= @$r == 1B= $r->[0]{"type"} eq "noun"
ABresult
0X0
100
111
46 13 $can = 0;
47 13 last;
48 }
49 }
50  
51 13 my $vals;
52 13 ▶ if ($can) {
Branch: 1 branch
BranchTrueFalseTotal
if ($can) { } 0 13 13
53 0 my $c0 = $c->_xlt($cd, '%(modal_verb)s be %s');
54 0 my $awa = $c->_xlt($cd, 'as well as %s');
55 0 my $wb = $c->_xlt($cd, ' ');
56 0 my $fmt;
57 0 my $i = 0;
58 0 for my $r (@result) {
59 0 ▶ $fmt .= $i ? $wb . $awa : $c0;
Branch: 1 branch
BranchTrueFalseTotal
$i ? : 0 0 0
60 push @$vals, ref($r->[0]{text}) eq 'ARRAY' ?
61 0 ▶ $r->[0]{text}[0] : $r->[0]{text};
Branch: 1 branch
BranchTrueFalseTotal
ref $r->[0]{'text'} eq 'ARRAY' ? : 0 0 0
62 0 $i++;
63 }
64 0 $c->add_ccl($cd, {
65 fmt => $fmt,
66 vals => $vals,
67 xlt => 0,
68 type => 'noun',
69 });
70 } else {
71 13 $c->add_ccl($cd, {
72 type => 'list',
73 fmt => '%(modal_verb)s be all of the following',
74 items => [
75 @result,
76 ],
77 vals => [],
78 });
79 }
80 }
81  
82 3 1;
83 # ABSTRACT: perl's type handler for type "all"
84  
85 __END__
« Data/Sah/Compiler/human/TH/int.pm ↑ Summary Data/Sah/Compiler/human/TH/any.pm »