Kavorka/Signature.pm

filter: Statementstmt 94.2% 211 / 224 Branchbran 73.1% 60 / 82 Conditioncond 79.7% 63 / 79 MC/DCmcdc 57.8% 22 / 38 Subroutinesub 100% 43 / 43 Podpod 88.8% 8 / 9 totaltotal 85.6% 407 / 475 CC 72 SCAR 27.8
CC
72
Cov
87%
sanity_check
35.5
parse
28.5
_injection_hash_underscore
10.0
CRAP 16.1
« Kavorka/Parameter.pm ↑ Summary Kavorka/Multi.pm »
1 38 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 38 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 38 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 38 ▶use Kavorka::Parameter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 38 ▶use Kavorka::ReturnType ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 package Kavorka::Signature;
10  
11 38 our $AUTHORITY = 'cpan:TOBYINK';
12 38 our $VERSION = '0.039';
13 38 our @CARP_NOT = qw( Kavorka::Sub Kavorka );
14  
15 38 ▶use Carp qw( croak );
Subroutine __ANON__: called CC=1 SCAR=0.0
16 38 ▶use Parse::Keyword {};
Subroutine __ANON__: called CC=1 SCAR=0.0
17 38 ▶use Parse::KeywordX;
Subroutine __ANON__: called CC=1 SCAR=0.0
18  
19 38 ▶use Moo;
Subroutine __ANON__: called CC=1 SCAR=0.0
20 38 ▶use namespace::sweep;
Subroutine __ANON__: called CC=1 SCAR=0.0
21  
22 38 has package => (is => 'ro');
23 38 has _is_dummy => (is => 'ro');
24 188 ▶has params => (is => 'ro', default => sub { +[] });
Subroutine __ANON__: called CC=1 SCAR=0.0
25 188 ▶has return_types => (is => 'ro', default => sub { +[] });
Subroutine __ANON__: called CC=1 SCAR=0.0
26 188 ▶has has_invocants => (is => 'rwp', default => sub { +undef });
Subroutine __ANON__: called CC=1 SCAR=0.0
27 188 ▶has has_named => (is => 'rwp', default => sub { +undef });
Subroutine __ANON__: called CC=1 SCAR=0.0
28 188 ▶has has_slurpy => (is => 'rwp', default => sub { +undef });
Subroutine __ANON__: called CC=1 SCAR=0.0
29 188 ▶has yadayada => (is => 'rwp', default => sub { 0 });
Subroutine __ANON__: called CC=1 SCAR=0.0
30 188 ▶has parameter_class => (is => 'ro', default => sub { 'Kavorka::Parameter' });
Subroutine __ANON__: called CC=1 SCAR=0.0
31 188 ▶has return_type_class => (is => 'ro', default => sub { 'Kavorka::ReturnType' });
Subroutine __ANON__: called CC=1 SCAR=0.0
32 38 has last_position => (is => 'lazy');
33 38 has args_min => (is => 'lazy');
34 38 has args_max => (is => 'lazy');
35 38 has checker => (is => 'lazy');
36 188 ▶has nobble_checks => (is => 'rwp', default => sub { 0 });
Subroutine __ANON__: called CC=1 SCAR=0.0
37  
38 sub parse
39 188 ▶{
Subroutine parse: called CC=15 SCAR=33.5
Pod documented
40 188 my $class = shift;
41 188 my $self = $class->new(@_);
42
43 188 lex_read_space;
44
45 188 my $found_colon = 0;
46 188 my $arr = $self->params;
47 188 my $_class = 'parameter_class';
48
49 188 ▶ if (lex_peek(4) =~ /\A(\xE2\x86\x92|-->)/)
Branch: 1 branch
BranchTrueFalseTotal
if (lex_peek(4) =~ /\A(\xE2\x86\x92|-->)/u) 0 0 0
50 {
51 0 lex_read(length $1);
52 0 $arr = $self->return_types;
53 0 $_class = 'return_type_class';
54 0 lex_read_space;
55 }
56
57 188 my $skip = 0;
58 188 ▶ while (lex_peek ne ')')
Branch: 1 branch
BranchTrueFalseTotal
if (lex_peek() ne ")") 0 0 0
59 {
60 239 ▶ if (lex_peek(3) eq '...')
Branch: 1 branch
BranchTrueFalseTotal
if (lex_peek(3) eq "...") 0 0 0
61 {
62 42 $self->_set_yadayada(1);
63 42 lex_read(3);
64 42 lex_read_space;
65 42 ▶ ++$skip && next if lex_peek(4) =~ /\A(\xE2\x86\x92|-->)/;
Branch: 1 branch
BranchTrueFalseTotal
if lex_peek(4) =~ /\A(\xE2\x86\x92|-->)/u 0 0 0
Condition0%0/5
lex_peek(4) =~ /\A(\xE2\x86\x92|-->)/u && (++$skip && (next))
!ll&&!rl&&r
000
++$skip and next
!ll
00
MC/DC0%0/2
lex_peek(4) =~ /\A(\xE2\x86\x92|-->)/u && (++$skip && (next))
lex_peek(4) =~ /\A(\xE2\x86\x92|-->)/u ++$skip
Truth table0%0/3
A && B
A= lex_peek(4) =~ /\A(\xE2\x86\x92|-->)/uB= ++$skip
ABresult
0X0
100
111
66 42 ▶ croak("After yada-yada, expected right parenthesis") unless lex_peek eq ")";
Branch: 1 branch
BranchTrueFalseTotal
unless lex_peek() eq ")" 0 0 0
67 42 next;
68 }
69
70 $skip
71 197 ▶ ? ($skip = 0)
Branch: 1 branch
BranchTrueFalseTotal
$skip ? : 0 197 197
72 : push(@$arr, $self->$_class->parse(package => $self->package));
73 197 lex_read_space;
74
75 197 my $peek = lex_peek;
76 197 ▶ if ($found_colon and $peek eq ':')
Branch: 5 branches
BranchTrueFalseTotal
if ($found_colon and $peek eq ':') { } 0 197 197
elsif ($peek eq ':') { } 6 191 197
elsif ($peek eq ',') { } 59 132 191
elsif ($peek eq ')') { } 129 3 132
elsif (lex_peek(4) =~ /\A(\xE2\x86\x92|-->)/u) { } 0 0 0
Condition33%1/3
$found_colon and $peek eq ":"
!ll&&!rl&&r
19700
MC/DC0%0/2
$found_colon and $peek eq ":"
$found_colon $peek eq ":"
Truth table33%1/3
A and B
A= $found_colonB= $peek eq ":"
ABresult
0X0
100
111
77 {
78 0 croak("Cannot have two sets of invocants - unexpected colon!");
79 }
80 elsif ($peek eq ':')
81 {
82 6 $_->traits->{invocant} = 1 for @{$self->params};
83 6 $self->_set_has_invocants( scalar @{$self->params} );
84 6 lex_read(1);
85 }
86 elsif ($peek eq ',')
87 {
88 59 lex_read(1);
89 }
90 elsif ($peek eq ')')
91 {
92 129 last;
93 }
94 elsif (lex_peek(4) =~ /\A(\xE2\x86\x92|-->)/)
95 {
96 3 lex_read(length $1);
97 3 $arr = $self->return_types;
98 3 $_class = 'return_type_class';
99 }
100 else
101 {
102 38 ▶ use Data::Dumper;
Subroutine __ANON__: called CC=1 SCAR=0.0
103 0 print Dumper($self);
104 0 croak("Unexpected characters in signature (${\ lex_peek(8) })");
105 }
106
107 68 lex_read_space;
108 }
109
110 188 $self->sanity_check;
111
112 188 return $self;
113 }
114  
115 # XXX - check not allowed optional parameters and named parameters in same sig
116 sub sanity_check
117 188 ▶{
Subroutine sanity_check: called CC=32 SCAR=35.7
Pod documented
118 188 my $self = shift;
119
120 188 my $has_invocants = 0;
121 188 my $has_slurpy = 0;
122 188 my $has_named = 0;
123 188 ▶ for my $p (reverse @{ $self->params or croak("Huh?") })
Condition50%1/2
$self->params || croak('Huh?')
l!l
1880
MC/DC0%0/1
$self->params || croak('Huh?')
$self->params
Truth table50%1/2
A
A= $self->params
Aresult
11
00
124 {
125 193 ▶ $has_named++ if $p->named;
Branch: 1 branch
BranchTrueFalseTotal
if $p->named 19 174 193
126 193 ▶ $has_slurpy++ if $p->slurpy;
Branch: 1 branch
BranchTrueFalseTotal
if $p->slurpy 35 158 193
127
128 193 ▶ if ($p->invocant) {
Branch: 2 branches
BranchTrueFalseTotal
if ($p->invocant) { } 7 186 193
elsif ($has_invocants) { } 0 186 186
129 7 $has_invocants++;
130 7 next;
131 }
132 elsif ($has_invocants) {
133 0 $has_invocants++;
134 0 $p->traits->{invocant} = 1; # anything prior to an invocant is also an invocant!
135 }
136 }
137 188 $self->_set_has_invocants($has_invocants);
138 188 $self->_set_has_named($has_named);
139 188 $self->_set_has_slurpy($has_slurpy);
140
141 188 ▶ croak("Cannot have more than one slurpy parameter") if $has_slurpy > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $has_slurpy > 1 0 188 188
142
143 188 my $i = 0;
144 188 my $zone = 'invocant';
145 188 my %already;
146 188 for my $p (@{ $self->params })
147 {
148 193 ▶ my $p_type =
Branch: 4 branches
BranchTrueFalseTotal
$p->invocant ? : 7 186 193
$p->named ? : 19 167 186
$p->slurpy ? : 35 132 167
$p->optional ? : 17 115 132
149 $p->invocant ? 'invocant' :
150 $p->named ? 'named' :
151 $p->slurpy ? 'slurpy' :
152 $p->optional ? 'optional' : 'positional';
153
154 193 $p->sanity_check($self);
155 193 ▶ $p->_set_position($i++) unless $p->invocant || $p->slurpy || $p->named;
Branch: 1 branch
BranchTrueFalseTotal
unless $p->invocant or $p->slurpy or $p->named 132 61 193
Condition100%6/6
$p->invocant or $p->slurpy or $p->named
l!l&&r!l&&!r
4219132
$p->invocant or $p->slurpy
l!l&&r!l&&!r
735151
MC/DC100%3/3
$p->invocant or $p->slurpy or $p->named
$p->invocant $p->slurpy $p->named
Truth table100%4/4
A or B or C
A= $p->invocantB= $p->slurpyC= $p->named
ABCresult
1XX1
01X1
0011
0000
156
157 193 my $name = $p->name;
158 croak("Parameter $name occurs twice in signature")
159 193 ▶ if length($name) > 1 && $already{$name}++;
Branch: 1 branch
BranchTrueFalseTotal
if length $name > 1 and $already{$name}++ 0 193 193
Condition66%2/3
length $name > 1 and $already{$name}++
!ll&&!rl&&r
81850
MC/DC0%0/2
length $name > 1 and $already{$name}++
length $name > 1 $already{$name}++
Truth table66%2/3
A and B
A= length $name > 1B= $already{$name}++
ABresult
0X0
100
111
160
161 193 ▶ if ($name eq '@_')
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "\@_") 1 192 193
162 {
163 1 ▶ croak("Cannot have slurpy named \@_ after positional parameters") if $self->positional_params;
Branch: 1 branch
BranchTrueFalseTotal
if $self->positional_params 0 1 1
164 1 ▶ croak("Cannot have slurpy named \@_ after named parameters") if $self->named_params;
Branch: 1 branch
BranchTrueFalseTotal
if $self->named_params 0 1 1
165 }
166
167 193 ▶ next if $p_type eq $zone;
Branch: 1 branch
BranchTrueFalseTotal
if $p_type eq $zone 36 157 193
168
169 # Zone transitions
170 157 ▶ if ($zone eq 'invocant' || $zone eq 'positional'
Branch: 2 branches
BranchTrueFalseTotal
if ($zone eq 'invocant' || $zone eq 'positional' and $p_type eq 'positional' || $p_type eq 'named' || $p_type eq 'slurpy' || $p_type eq 'optional') { } 149 8 157
elsif ($zone eq 'optional' || $zone eq 'named' and $p_type eq 'slurpy') { } 8 0 8
Condition86%13/15
$zone eq "invocant" || $zone eq "positional" and $p_type eq "positional" || $p_type eq "named" || $p_type eq "slurpy" || $p_type eq "optional"
!ll&&!rl&&r
80149
$zone eq "invocant" or $zone eq "positional"
l!l&&r!l&&!r
138118
$p_type eq "positional" or $p_type eq "named" or $p_type eq "slurpy" or $p_type eq "optional"
l!l&&r!l&&!r
137120
$p_type eq "positional" or $p_type eq "named" or $p_type eq "slurpy"
l!l&&r!l&&!r
1102712
$p_type eq "positional" or $p_type eq "named"
l!l&&r!l&&!r
961439
MC/DC33%2/6
$zone eq "invocant" || $zone eq "positional" and $p_type eq "positional" || $p_type eq "named" || $p_type eq "slurpy" || $p_type eq "optional"
$zone eq "invocant" $zone eq "positional" $p_type eq "positional" $p_type eq "named" $p_type eq "slurpy" $p_type eq "optional"
Truth table72%8/11
A or B and C or D or E or F
A= $zone eq "invocant"B= $zone eq "positional"C= $p_type eq "positional"D= $p_type eq "named"E= $p_type eq "slurpy"F= $p_type eq "optional"
ABCDEFresult
00XXXX0
1X00000
0100000
1X1XXX1
1X01XX1
1X001X1
1X00011
011XXX1
0101XX1
01001X1
0100011
171 and $p_type eq 'positional' || $p_type eq 'named' || $p_type eq 'slurpy' || $p_type eq 'optional')
172 {
173 149 $zone = $p_type;
174 149 next;
175 }
176 ▶ elsif ($zone eq 'optional' || $zone eq 'named'
Condition50%3/6
$zone eq "optional" || $zone eq "named" and $p_type eq "slurpy"
!ll&&!rl&&r
008
$zone eq "optional" or $zone eq "named"
l!l&&r!l&&!r
260
MC/DC0%0/3
$zone eq "optional" || $zone eq "named" and $p_type eq "slurpy"
$zone eq "optional" $zone eq "named" $p_type eq "slurpy"
Truth table40%2/5
A or B and C
A= $zone eq "optional"B= $zone eq "named"C= $p_type eq "slurpy"
ABCresult
00X0
1X00
0100
1X11
0111
177 and $p_type eq 'slurpy')
178 {
179 8 $zone = $p_type;
180 8 next;
181 }
182
183 0 croak("Found $p_type parameter ($name) after $zone; forbidden");
184 }
185
186 188 $_->sanity_check for @{ $self->return_types };
187
188 188 ();
189 }
190  
191 sub _build_last_position
192 43 ▶{
Subroutine _build_last_position: called CC=2 SCAR=6.9
193 43 my $self = shift;
194 43 my ($last) = reverse( $self->positional_params );
195 43 ▶ return -1 unless $last;
Branch: 1 branch
BranchTrueFalseTotal
unless $last 32 11 43
196 11 return $last->position;
197 }
198  
199 sub injection
200 207 ▶{
Subroutine injection: called CC=1 SCAR=0.0
Pod documented
201 207 my $self = shift;
202 207 join q[] => (
203 $self->_injection_nobble,
204 $self->_injection_invocants,
205 $self->_injection_parameter_count,
206 $self->_injection_positional_params,
207 $self->_injection_hash_underscore,
208 $self->_injection_named_params,
209 $self->_injection_slurpy_param,
210 '();',
211 );
212 }
213  
214 38 our $NOBBLE = bless(do { my $x = 1; \$x }, 'Kavorka::Signature::NOBBLE');
215 sub _injection_nobble
216 207 ▶{
Subroutine _injection_nobble: called CC=2 SCAR=6.9
217 207 my $self = shift;
218 207 ▶ return unless $self->nobble_checks;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->nobble_checks 192 15 207
219
220 15 sprintf('my $____nobble_checks = (ref($_[0]) eq "Kavorka::Signature::NOBBLE") ? ${+shift} : 0;');
221 }
222  
223 sub _injection_parameter_count
224 207 ▶{
Subroutine _injection_parameter_count: called CC=10 SCAR=23.1
225 207 my $self = shift;
226
227 207 my $min = $self->args_min;
228 207 my $max = $self->args_max;
229
230 207 my @lines;
231
232 207 ▶ return sprintf(
Branch: 2 branches
BranchTrueFalseTotal
if defined $min and defined $max and $min == $max 116 91 207
$min == 1 ? : 87 29 116
Condition83%5/6
defined $min and defined $max and $min == $max
!ll&&!rl&&r
8110116
defined $min and defined $max
!ll&&!rl&&r
081126
MC/DC66%2/3
defined $min and defined $max and $min == $max
defined $min defined $max $min == $max
Truth table75%3/4
A and B and C
A= defined $minB= defined $maxC= $min == $max
ABCresult
0XX0
10X0
1100
1111
233 'Carp::croak("Expected %d parameter%s") if @_ != %d;',
234 $min,
235 $min==1 ? '' : 's',
236 $min,
237 ) if defined($min) && defined($max) && $min==$max;
238
239 91 ▶ push @lines, sprintf(
Branch: 2 branches
BranchTrueFalseTotal
if defined $min and $min > 0 16 75 91
$min == 1 ? : 11 5 16
Condition66%2/3
defined $min and $min > 0
!ll&&!rl&&r
07516
MC/DC50%1/2
defined $min and $min > 0
defined $min $min > 0
Truth table66%2/3
A and B
A= defined $minB= $min > 0
ABresult
0X0
100
111
240 'Carp::croak("Expected at least %d parameter%s") if @_ < %d;',
241 $min,
242 $min==1 ? '' : 's',
243 $min,
244 ) if defined $min && $min > 0;
245
246 91 ▶ push @lines, sprintf(
Branch: 2 branches
BranchTrueFalseTotal
if defined $max 10 81 91
$max == 1 ? : 6 4 10
247 'Carp::croak("Expected at most %d parameter%s") if @_ > %d;',
248 $max,
249 $max==1 ? '' : 's',
250 $max,
251 ) if defined $max;
252
253 91 return @lines;
254 }
255  
256 sub _build_args_min
257 188 ▶{
Subroutine _build_args_min: called CC=1 SCAR=0.0
258 188 my $self = shift;
259 188 0 + scalar grep !$_->optional, $self->positional_params;
260 }
261  
262 sub _build_args_max
263 188 ▶{
Subroutine _build_args_max: called CC=4 SCAR=13.9
264 188 my $self = shift;
265 188 ▶ return if $self->has_named || $self->has_slurpy || $self->yadayada;
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_named or $self->has_slurpy or $self->yadayada 81 107 188
Condition100%6/6
$self->has_named or $self->has_slurpy or $self->yadayada
l!l&&r!l&&!r
4338107
$self->has_named or $self->has_slurpy
l!l&&r!l&&!r
1429145
MC/DC100%3/3
$self->has_named or $self->has_slurpy or $self->yadayada
$self->has_named $self->has_slurpy $self->yadayada
Truth table100%4/4
A or B or C
A= $self->has_namedB= $self->has_slurpyC= $self->yadayada
ABCresult
1XX1
01X1
0011
0000
266 107 0 + scalar $self->positional_params;
267 }
268  
269 sub _injection_hash_underscore
270 207 ▶{
Subroutine _injection_hash_underscore: called CC=10 SCAR=23.1
271 207 my $self = shift;
272
273 207 my $slurpy = $self->slurpy_param;
274
275 207 ▶ if ($self->has_named
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_named or $slurpy and $slurpy->name =~ /\A\%/u or $slurpy and $slurpy->name =~ /\A\$/u and $slurpy->type->is_a_type_of(Types::Standard::HashRef())) 21 186 207
Condition100%15/15
$self->has_named or $slurpy and $slurpy->name =~ /\A\%/u or $slurpy and $slurpy->name =~ /\A\$/u and $slurpy->type->is_a_type_of(Types::Standard::HashRef())
l!l&&r!l&&!r
201186
$self->has_named or $slurpy and $slurpy->name =~ /\A\%/u
l!l&&r!l&&!r
146187
$slurpy and $slurpy->name =~ /\A\%/u
!ll&&!rl&&r
164236
$slurpy and $slurpy->name =~ /\A\$/u and $slurpy->type->is_a_type_of(Types::Standard::HashRef())
!ll&&!rl&&r
176101
$slurpy and $slurpy->name =~ /\A\$/u
!ll&&!rl&&r
1641211
MC/DC100%6/6
$self->has_named or $slurpy and $slurpy->name =~ /\A\%/u or $slurpy and $slurpy->name =~ /\A\$/u and $slurpy->type->is_a_type_of(Types::Standard::HashRef())
$self->has_named $slurpy $slurpy->name =~ /\A\%/u $slurpy $slurpy->name =~ /\A\$/u $slurpy->type->is_a_type_of(Types::Standard::HashRef())
Truth table60%6/10
A or B and C or D and E and F
A= $self->has_namedB= $slurpyC= $slurpy->name =~ /\A\%/uD= $slurpyE= $slurpy->name =~ /\A\$/uF= $slurpy->type->is_a_type_of(Types::Standard::HashRef())
ABCDEFresult
1XXXXX1
011XXX1
00X1111
0101111
00X0XX0
00X10X0
00X1100
0100XX0
01010X0
0101100
276 or $slurpy && $slurpy->name =~ /\A\%/
277 or $slurpy && $slurpy->name =~ /\A\$/ && $slurpy->type->is_a_type_of(Types::Standard::HashRef()))
278 {
279 21 my $ix = 1 + $self->last_position;
280 21 my $str;
281 21 ▶ if ($] >= 5.022)
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= 5.022) { } 21 0 21
282 {
283 21 my $pragma = "use warnings FATAL => qw(all);use experimental 'refaliasing';no warnings 'experimental::refaliasing';";
284 21 $str = sprintf(
285 'local %%_;'
286 .'{ %s '
287 .'if ($#_==%d && ref($_[%d]) eq q(HASH)) { '
288 .'\\%%_ = $_[%d]; '
289 .'} else { '
290 .'my $i = %d; '
291 .'my $slice_length = ($#_ + 1 - $i); '
292 .'if ($slice_length %% 2 != 0) { '
293 .'Carp::croak("Odd number of elements in anonymous hash");'
294 .'} '
295 .'while ($i <= $#_) { '
296 .'my $key = $_[$i]; '
297 .'\\$_{$key} = \\$_[$i+1]; '
298 .'$i += 2; '
299 .'} '
300 .'} '
301 .'};',
302 $pragma,
303 ($ix) x 4,
304 );
305 }
306 else
307 {
308 0 require Data::Alias;
309 0 $str = sprintf(
310 'local %%_; { use warnings FATAL => qw(all); Data::Alias::alias(%%_ = ($#_==%d && ref($_[%d]) eq q(HASH)) ? %%{$_[%d]} : @_[ %d .. $#_ ]) };',
311 ($ix) x 4,
312 );
313 }
314
315 21 ▶ unless ($slurpy or $self->yadayada)
Branch: 1 branch
BranchTrueFalseTotal
unless ($slurpy or $self->yadayada) 4 17 21
Condition100%3/3
$slurpy or $self->yadayada
l!l&&r!l&&!r
1344
MC/DC100%2/2
$slurpy or $self->yadayada
$slurpy $self->yadayada
Truth table100%3/3
A or B
A= $slurpyB= $self->yadayada
ABresult
1X1
011
000
316 {
317 4 my @allowed_names = map +($_=>1), map @{$_->named_names}, $self->named_params;
318 4 $str .= sprintf(
319 '{ my %%OK = (%s); ',
320 join(q[,], map(sprintf('%s=>1,', B::perlstring $_), @allowed_names)),
321 );
322 4 $str .= '$OK{$_}||Carp::croak("Unknown named parameter: $_") for sort keys %_ };';
323 }
324
325 21 return $str;
326 }
327
328 186 return;
329 }
330  
331 sub _injection_invocants
332 207 ▶{
Subroutine _injection_invocants: called CC=1 SCAR=0.0
333 207 my $self = shift;
334 207 map($_->injection($self), $self->invocants);
335 }
336  
337 sub _injection_positional_params
338 207 ▶{
Subroutine _injection_positional_params: called CC=1 SCAR=0.0
339 207 my $self = shift;
340 207 map($_->injection($self), $self->positional_params);
341 }
342  
343 sub _injection_named_params
344 207 ▶{
Subroutine _injection_named_params: called CC=1 SCAR=0.0
345 207 my $self = shift;
346 207 map($_->injection($self), $self->named_params);
347 }
348  
349 sub _injection_slurpy_param
350 207 ▶{
Subroutine _injection_slurpy_param: called CC=1 SCAR=0.0
351 207 my $self = shift;
352 207 map($_->injection($self), grep defined, $self->slurpy_param);
353 }
354  
355 sub named_params
356 213 ▶{
Subroutine named_params: called CC=1 SCAR=0.0
Pod documented
357 213 my $self = shift;
358 213 grep $_->named, @{$self->params};
359 }
360  
361 sub positional_params
362 547 ▶{
Subroutine positional_params: called CC=3 SCAR=11.0
Pod documented
363 547 my $self = shift;
364 547 ▶ grep !$_->named && !$_->invocant && !$_->slurpy, @{$self->params};
Condition100%6/6
$_->named || $_->invocant || $_->slurpy
l!l&&r!l&&!r
299107407
$_->named or $_->invocant
l!l&&r!l&&!r
58241514
MC/DC100%3/3
$_->named || $_->invocant || $_->slurpy
$_->named $_->invocant $_->slurpy
Truth table100%4/4
A or B || C
A= $_->namedB= $_->invocantC= $_->slurpy
ABCresult
1XX1
01X1
0011
0000
365 }
366  
367 sub slurpy_param
368 415 ▶{
Subroutine slurpy_param: called CC=1 SCAR=0.0
Pod undocumented
369 415 my $self = shift;
370 415 my ($s) = grep $_->slurpy, @{$self->params};
371 415 $s;
372 }
373  
374 sub invocants
375 208 ▶{
Subroutine invocants: called CC=1 SCAR=0.0
Pod documented
376 208 my $self = shift;
377 208 grep $_->invocant, @{$self->params};
378 }
379  
380 sub check
381 7 ▶{
Subroutine check: called CC=1 SCAR=0.0
Pod documented
382 7 my $checker = shift->checker;
383 7 goto $checker;
384 }
385  
386 sub _build_checker
387 2 ▶{
Subroutine _build_checker: called CC=1 SCAR=0.0
388 2 my $self = shift;
389 2 ▶ eval sprintf(
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
390 'sub { eval { %s; 1 } }',
391 $self->injection,
392 );
393 }
394  
395 sub inline_check
396 17 ▶{
Subroutine inline_check: called CC=2 SCAR=7.0
Pod documented
397 17 my $self = shift;
398 17 my ($arr) = @_;
399
400 17 my $tmp = $self->nobble_checks;
401 17 $self->_set_nobble_checks(0);
402
403 17 my $inline = sprintf(
404 'do { local @_ = %s; eval { %s; 1 } }',
405 $arr,
406 $self->injection,
407 );
408
409 17 ▶ $self->_set_nobble_checks($tmp) if $tmp;
Branch: 1 branch
BranchTrueFalseTotal
if $tmp 17 0 17
410
411 17 return $inline;
412 }
413  
414 38 1;
415  
416 __END__
« Kavorka/Parameter.pm ↑ Summary Kavorka/Multi.pm »