Kavorka/Sub.pm

filter: Statementstmt 94.7% 252 / 266 Branchbran 66.6% 64 / 96 Conditioncond 43.3% 13 / 30 MC/DCmcdc 29.4% 5 / 17 Subroutinesub 87.7% 43 / 49 Podpod 89.4% 17 / 19 totaltotal 82.6% 394 / 477 CC 63 SCAR 19.2
CC
63
Cov
84%
_apply_return_types
22.8
parse_subname
9.9
parse
8.2
CRAP 6.8
« Kavorka/Multi.pm ↑ Summary Parse/KeywordX.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 warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 38 ▶use Kavorka::Signature ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 38 ▶use Sub::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package Kavorka::Sub;
9  
10 38 our $AUTHORITY = 'cpan:TOBYINK';
11 38 our $VERSION = '0.039';
12  
13 38 ▶use Text::Balanced qw( extract_bracketed );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 38 ▶use Parse::Keyword {};
Subroutine BEGIN: called CC=1 SCAR=0.0
15 38 ▶use Parse::KeywordX;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 38 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 38 our @CARP_NOT = qw(Kavorka);
19  
20 38 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 38 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 38 ▶use overload (
Subroutine BEGIN: called CC=1 SCAR=2.1
24 0 ▶ q[&{}] => sub { shift->body },
Subroutine __ANON__: called CC=1 SCAR=1.2
Subroutine (&{}: not called CC=1 SCAR=1.2
25 0 ▶ q[bool] => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=1.2
Subroutine (bool: not called CC=1 SCAR=1.2
26 0 ▶ q[""] => sub { shift->qualified_name // '__ANON__' },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Condition0%0/4
(shift())->qualified_name // "__ANON__"
l!l
00
(shift())->qualified_name // "__ANON__"
l!l
00
MC/DC0%0/1
(shift())->qualified_name // "__ANON__"
(shift())->qualified_name
MC/DC0%0/1
(shift())->qualified_name // "__ANON__"
(shift())->qualified_name
Truth table0%0/2
A
A= (shift())->qualified_name
Aresult
11
00
Truth table0%0/2
A
A= (shift())->qualified_name
Aresult
11
00
27 0 ▶ q[0+] => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 38 fallback => 1,
29 38 );
30  
31 38 has keyword => (is => 'ro');
32 188 ▶has signature_class => (is => 'lazy', default => sub { 'Kavorka::Signature' });
Subroutine __ANON__: called CC=1 SCAR=0.0
33 38 has package => (is => 'ro');
34 38 has declared_name => (is => 'rwp');
35 38 has signature => (is => 'rwp');
36 188 ▶has traits => (is => 'lazy', default => sub { +{} });
Subroutine __ANON__: called CC=1 SCAR=0.0
37 38 has prototype => (is => 'rwp');
38 188 ▶has attributes => (is => 'lazy', default => sub { [] });
Subroutine __ANON__: called CC=1 SCAR=0.0
39 38 has body => (is => 'rwp');
40 38 has qualified_name => (is => 'rwp');
41  
42 38 has _unwrapped_body => (is => 'rwp');
43 38 has _pads_to_poke => (is => 'lazy');
44 38 has _tmp_name => (is => 'lazy');
45  
46 23 ▶sub allow_anonymous { 1 }
Subroutine allow_anonymous: called CC=1 SCAR=0.0
Pod documented
47 4 ▶sub allow_lexical { 1 }
Subroutine allow_lexical: called CC=1 SCAR=0.0
Pod undocumented
48 902 ▶sub is_anonymous { !defined( shift->declared_name ) }
Subroutine is_anonymous: called CC=1 SCAR=0.0
Pod documented
49 802 ▶sub is_lexical { (shift->declared_name || '') =~ /\A\$/ }
Subroutine is_lexical: called CC=2 SCAR=7.6
Pod undocumented
Condition50%1/2
(shift())->declared_name || ''
l!l
8020
MC/DC0%0/1
(shift())->declared_name || ''
(shift())->declared_name
Truth table50%1/2
A
A= (shift())->declared_name
Aresult
11
00
50 0 ▶sub invocation_style { +undef }
Subroutine invocation_style: not called CC=1 SCAR=6.9
Pod documented
51 132 ▶sub default_attributes { return; }
Subroutine default_attributes: called CC=1 SCAR=0.0
Pod documented
52 111 ▶sub default_invocant { return; }
Subroutine default_invocant: called CC=1 SCAR=0.0
Pod documented
53 161 ▶sub forward_declare_sub { return; }
Subroutine forward_declare_sub: called CC=1 SCAR=0.0
Pod documented
54  
55 sub bypass_custom_parsing
56 0 ▶{
Subroutine bypass_custom_parsing: not called CC=1 SCAR=6.9
Pod documented
57 0 my $class = shift;
58 0 my ($keyword, $caller, $args) = @_;
59 0 croak("Attempt to call keyword '$keyword' bypassing prototype not supported");
60 }
61  
62 sub install_sub
63 160 ▶{
Subroutine install_sub: called CC=3 SCAR=11.0
Pod documented
64 160 my $self = shift;
65 160 my $code = $self->body;
66
67 160 ▶ if ($self->is_anonymous)
Branch: 2 branches
BranchTrueFalseTotal
if ($self->is_anonymous) { } 29 131 160
elsif ($self->is_lexical) { } 6 125 131
68 {
69 # no installation
70 }
71 elsif ($self->is_lexical)
72 {
73 6 require PadWalker;
74 6 PadWalker::peek_my(2)->{ $self->declared_name } = \$code;
75 }
76 else
77 {
78 125 my $name = $self->qualified_name;
79 38 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
80 125 *{$name} = $code;
81 }
82
83 160 $code;
84 }
85  
86 sub inject_attributes
87 165 ▶{
Subroutine inject_attributes: called CC=2 SCAR=7.0
Pod documented
88 165 my $self = shift;
89 38 ▶ no warnings; # Perl 5.21+ sprintf emits warnings for redundant arguments
Subroutine BEGIN: called CC=1 SCAR=0.0
90 165 ▶ join(' ', map sprintf($_->[1] ? ':%s(%s)' : ':%s', @$_), @{ $self->attributes }),
Branch: 1 branch
BranchTrueFalseTotal
$_->[1] ? : 0 52 52
91 }
92  
93 sub inject_prelude
94 188 ▶{
Subroutine inject_prelude: called CC=1 SCAR=0.0
Pod documented
95 188 my $self = shift;
96 188 $self->signature->injection;
97 }
98  
99 sub parse
100 188 ▶{
Subroutine parse: called CC=8 SCAR=21.0
Pod documented
101 188 my $class = shift;
102 188 my $self = $class->new(@_, package => compiling_package);
103
104 188 lex_read_space;
105
106 # sub name
107 188 $self->parse_subname;
108 188 ▶ unless ($self->is_anonymous or $self->is_lexical)
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_anonymous or $self->is_lexical) 161 27 188
Condition100%3/3
$self->is_anonymous or $self->is_lexical
l!l&&r!l&&!r
234161
MC/DC100%2/2
$self->is_anonymous or $self->is_lexical
$self->is_anonymous $self->is_lexical
Truth table100%3/3
A or B
A= $self->is_anonymousB= $self->is_lexical
ABresult
1X1
011
000
109 {
110 161 my $qualified = Kavorka::_fqname($self->declared_name);
111 161 $self->_set_qualified_name($qualified);
112 161 $self->forward_declare_sub;
113 }
114
115 # Thanks to Perl 5.20 subs, we have to allow attributes before
116 # the signature too.
117 188 lex_read_space;
118 188 ▶ $self->parse_attributes
Branch: 1 branch
BranchTrueFalseTotal
if lex_peek() eq ":" and lex_peek(2) ne ":(" 0 0 0
Condition0%0/3
lex_peek() eq ":" and lex_peek(2) ne ":("
!ll&&!rl&&r
000
MC/DC0%0/2
lex_peek() eq ":" and lex_peek(2) ne ":("
lex_peek() eq ":" lex_peek(2) ne ":("
Truth table0%0/3
A and B
A= lex_peek() eq ":"B= lex_peek(2) ne ":("
ABresult
0X0
100
111
119 if lex_peek eq ':'
120 && lex_peek(2) ne ':(';
121
122 # signature
123 188 $self->parse_signature;
124 188 my $sig = $self->signature;
125 188 ▶ unless ($sig->has_invocants)
Branch: 1 branch
BranchTrueFalseTotal
unless ($sig->has_invocants) 182 6 188
126 {
127 182 my @defaults = $self->default_invocant;
128 182 unshift @{$sig->params}, @defaults;
129 182 $sig->_set_has_invocants(scalar @defaults);
130 }
131
132 # traits
133 188 $self->parse_traits;
134 188 my $traits = $self->traits;
135 188 ▶ if (keys %$traits)
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$traits) 10 178 188
136 {
137 # traits handled natively (none so far)
138 10 state $native_traits = {};
139
140 my @custom_traits =
141 map "Kavorka::TraitFor::Sub::$_",
142 10 grep !exists($native_traits->{$_}),
143 keys %$traits;
144
145 10 ▶ 'Moo::Role'->apply_roles_to_object($self, @custom_traits) if @custom_traits;
Branch: 1 branch
BranchTrueFalseTotal
if @custom_traits 10 0 10
146 }
147
148 # prototype and attributes
149 188 $self->parse_prototype;
150 188 $self->parse_attributes;
151 188 push @{$self->attributes}, $self->default_attributes;
152
153 # body
154 188 $self->parse_body;
155
156 188 $self;
157 }
158  
159 sub parse_subname
160 188 ▶{
Subroutine parse_subname: called CC=9 SCAR=22.9
Pod documented
161 188 my $self = shift;
162 188 my $peek = lex_peek(2);
163
164 188 my $saw_my = 0;
165
166 188 ▶ if ($peek =~ /\A(?:\w|::)/) # normal sub
Branch: 1 branch
BranchTrueFalseTotal
if ($peek =~ /\A(?:\w|::)/u) 165 23 188
167 {
168 165 my $name = parse_name('subroutine', 1);
169
170 165 ▶ if ($name eq 'my')
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "my") 4 161 165
171 {
172 4 lex_read_space;
173 4 ▶ $saw_my = 1 if lex_peek eq '$';
Branch: 1 branch
BranchTrueFalseTotal
if lex_peek() eq "\$" 0 0 0
174 }
175
176 165 ▶ if ($saw_my)
Branch: 1 branch
BranchTrueFalseTotal
if ($saw_my) { } 4 161 165
177 {
178 4 $peek = lex_peek(2);
179 }
180 else
181 {
182 161 $self->_set_declared_name($name);
183 161 return;
184 }
185 }
186
187 27 ▶ if ($peek =~ /\A\$[^\W0-9]/) # lexical sub
Branch: 1 branch
BranchTrueFalseTotal
if ($peek =~ /\A\$[^\W0-9]/u) 4 23 27
188 {
189 0 ▶ carp("'${\ $self->keyword }' should be '${\ $self->keyword } my'")
Branch: 1 branch
BranchTrueFalseTotal
unless $saw_my 0 4 4
190 unless $saw_my;
191
192 4 lex_read(1);
193 4 $self->_set_declared_name('$' . parse_name('lexical subroutine', 0));
194
195 0 ▶ croak("Keyword '${\ $self->keyword }' does not support defining lexical subs")
Branch: 1 branch
BranchTrueFalseTotal
unless $self->allow_lexical 0 4 4
196 unless $self->allow_lexical;
197
198 4 return;
199 }
200
201 0 ▶ croak("Keyword '${\ $self->keyword }' does not support defining anonymous subs")
Branch: 1 branch
BranchTrueFalseTotal
unless $self->allow_anonymous 0 23 23
202 unless $self->allow_anonymous;
203
204 23 ();
205 }
206  
207 sub parse_signature
208 188 ▶{
Subroutine parse_signature: called CC=3 SCAR=11.4
Pod documented
209 188 my $self = shift;
210 188 lex_read_space;
211
212 # default signature
213 188 my $dummy = 0;
214 188 ▶ if (lex_peek ne '(')
Branch: 1 branch
BranchTrueFalseTotal
if (lex_peek() ne "(") 0 0 0
215 {
216 32 $dummy = 1;
217 32 lex_stuff('(...)');
218 }
219
220 188 lex_read(1);
221 188 my $sig = $self->signature_class->parse(package => $self->package, _is_dummy => $dummy);
222 188 ▶ lex_peek eq ')' or croak('Expected ")" after signature');
Branch: 1 branch
BranchTrueFalseTotal
lex_peek() eq ")" or croak("Expected \")\" after signature") 0 0 0
223 188 lex_read(1);
224 188 lex_read_space;
225
226 188 $self->_set_signature($sig);
227
228 188 ();
229 }
230  
231 sub parse_prototype
232 188 ▶{
Subroutine parse_prototype: called CC=2 SCAR=6.9
Pod documented
233 188 my $self = shift;
234 188 lex_read_space;
235
236 188 my $peek = lex_peek(1000);
237 188 ▶ if ($peek =~ / \A \: \s* \( /xsm )
Branch: 1 branch
BranchTrueFalseTotal
if ($peek =~ / \A \: \s* \( /msux) 3 185 188
238 {
239 3 lex_read(1);
240 3 lex_read_space;
241 3 $peek = lex_peek(1000);
242
243 3 my $extracted = extract_bracketed($peek, '()');
244 3 lex_read(length $extracted);
245 3 $extracted =~ s/(?: \A\( | \)\z )//xgsm;
246
247 3 $self->_set_prototype($extracted);
248 }
249
250 188 ();
251 }
252  
253 sub parse_traits
254 188 ▶{
Subroutine parse_traits: called CC=2 SCAR=7.1
Pod documented
255 188 my $self = shift;
256 188 lex_read_space;
257
258 188 ▶ while (lex_peek(5) =~ m{ \A (is|does|but) \s }xsm)
Branch: 1 branch
BranchTrueFalseTotal
if (lex_peek(5) =~ / \A (is|does|but) \s /msux) 0 0 0
259 {
260 10 lex_read(length($1));
261 10 lex_read_space;
262 10 my ($name, undef, $args) = parse_trait;
263 10 $self->traits->{$name} = $args;
264 10 lex_read_space;
265 }
266
267 188 ();
268 }
269  
270 sub parse_attributes
271 193 ▶{
Subroutine parse_attributes: called CC=5 SCAR=17.6
Pod documented
272 193 my $self = shift;
273 193 lex_read_space;
274
275 193 ▶ if (lex_peek eq ':')
Branch: 1 branch
BranchTrueFalseTotal
if (lex_peek() eq ':') { } 0 0 0
276 {
277 7 lex_read(1);
278 7 lex_read_space;
279 }
280 else
281 {
282 186 return;
283 }
284
285 7 ▶ while (lex_peek(4) =~ /\A([^\W0-9]\w+)/)
Branch: 1 branch
BranchTrueFalseTotal
if (lex_peek(4) =~ /\A([^\W0-9]\w+)/u) 0 0 0
286 {
287 7 my $parsed = [parse_trait];
288 7 lex_read_space;
289
290 7 ▶ if ($parsed->[0] eq 'prototype')
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->[0] eq 'prototype') { } 3 4 7
291 {
292 3 $self->_set_prototype($parsed->[1]);
293 }
294 else
295 {
296 4 push @{$self->attributes}, $parsed;
297 }
298
299 7 ▶ if (lex_peek eq ':')
Branch: 1 branch
BranchTrueFalseTotal
if (lex_peek() eq ":") 0 0 0
300 {
301 0 lex_read(1);
302 0 lex_read_space;
303 }
304 }
305  
306 7 ();
307 }
308  
309 sub _build__tmp_name
310 164 ▶{
Subroutine _build__tmp_name: called CC=1 SCAR=0.0
311 164 state $i = 0;
312 164 "Kavorka::Temp::f" . ++$i;
313 }
314  
315 sub parse_body
316 188 ▶{
Subroutine parse_body: called CC=6 SCAR=18.0
Pod documented
317 188 my $self = shift;
318
319 188 lex_read_space;
320 188 ▶ lex_peek(1) eq '{' or croak("expected block!");
Branch: 1 branch
BranchTrueFalseTotal
lex_peek(1) eq "{" or croak("expected block!") 0 0 0
321 188 lex_read(1);
322
323 188 ▶ if ($self->is_anonymous)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_anonymous) { } 23 165 188
324 {
325 23 lex_stuff(sprintf("{ %s", $self->inject_prelude));
326
327 # Parse the actual code
328 23 ▶ my $code = parse_block(0) or Carp::croak("cannot parse block!");
Branch: 1 branch
BranchTrueFalseTotal
my $code = parse_block(0) or Carp::croak("cannot parse block!") 0 0 0
329
330 # Set up prototype
331 23 &Scalar::Util::set_prototype($code, $self->prototype);
332
333 # Fix sub name
334 23 $code = Sub::Util::set_subname(join('::', $self->package, '__ANON__'), $code);
335
336 # Set up attributes - this doesn't much work
337 23 my $attrs = $self->attributes;
338 23 ▶ if (@$attrs)
Branch: 1 branch
BranchTrueFalseTotal
if (@$attrs) 7 16 23
339 {
340 7 require attributes;
341 38 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
342 7 attributes->import(
343 $self->package,
344 $code,
345 map($_->[0], @$attrs),
346 );
347 }
348
349 # And keep the coderef
350 23 $self->_set_body($code);
351 }
352 else
353 {
354 165 state $i = 0;
355
356 165 my $lex = '';
357 165 ▶ if ($self->is_lexical)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_lexical) 4 161 165
358 {
359 4 $lex = sprintf(
360 '&Internals::SvREADONLY(\\(my %s = \&%s), 1);',
361 $self->declared_name,
362 $self->_tmp_name,
363 );
364 }
365
366 # Here instead of parsing the body we'll leave it to plain old
367 # Perl. We'll pick it up later from this name in _post_parse
368 lex_stuff(
369 165 sprintf(
370 "%s sub %s %s { no warnings 'closure'; %s",
371 $lex,
372 $self->_tmp_name,
373 $self->inject_attributes,
374 $self->inject_prelude,
375 )
376 );
377 165 $self->{argh} = $self->_tmp_name;
378 }
379
380 188 ();
381 }
382  
383 sub _post_parse
384 196 ▶{
Subroutine _post_parse: called CC=7 SCAR=19.5
385 196 my $self = shift;
386
387 196 ▶ if ($self->{argh})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"argh"}) 167 29 196
388 {
389 38 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
390 167 ▶ my $code = $self->is_lexical ? \&{$self->{argh}} : \&{ delete $self->{argh} };
Branch: 1 branch
BranchTrueFalseTotal
$self->is_lexical ? : 6 161 167
391 167 ▶ Sub::Util::set_subname(
Branch: 1 branch
BranchTrueFalseTotal
$self->is_anonymous || $self->is_lexical ? : 6 161 167
Condition66%2/3
$self->is_anonymous or $self->is_lexical
l!l&&r!l&&!r
06161
MC/DC50%1/2
$self->is_anonymous or $self->is_lexical
$self->is_anonymous $self->is_lexical
Truth table66%2/3
A or B
A= $self->is_anonymousB= $self->is_lexical
ABresult
1X1
011
000
392 $self->is_anonymous || $self->is_lexical
393 ? join('::', $self->package, '__ANON__')
394 : $self->qualified_name,
395 $code,
396 );
397 167 &Scalar::Util::set_prototype($code, $self->prototype);
398 167 $self->_set_body($code);
399 }
400
401 196 $self->_apply_return_types;
402
403 196 ▶ $self->_set_signature(undef)
Branch: 1 branch
BranchTrueFalseTotal
if $self->signature and $self->signature->_is_dummy 32 164 196
Condition100%3/3
$self->signature and $self->signature->_is_dummy
!ll&&!rl&&r
216232
MC/DC100%2/2
$self->signature and $self->signature->_is_dummy
$self->signature $self->signature->_is_dummy
Truth table100%3/3
A and B
A= $self->signatureB= $self->signature->_is_dummy
ABresult
0X0
100
111
404 if $self->signature && $self->signature->_is_dummy;
405
406 196 ();
407 }
408  
409 sub _apply_return_types
410 196 ▶{
Subroutine _apply_return_types: called CC=16 SCAR=31.3
411 196 my $self = shift;
412
413 196 ▶ my @rt = @{ $self->signature ? $self->signature->return_types : [] };
Branch: 1 branch
BranchTrueFalseTotal
$self->signature ? : 194 2 196
414
415 196 ▶ if (@rt)
Branch: 1 branch
BranchTrueFalseTotal
if (@rt) 3 193 196
416 {
417 3 my @scalar = grep !$_->list, @rt;
418 3 my @list = grep $_->list, @rt;
419
420 3 ▶ my $scalar =
Branch: 2 branches
BranchTrueFalseTotal
@scalar == 0 ? : 0 3 3
@scalar == 1 ? : 3 0 3
421 (@scalar == 0) ? undef :
422 (@scalar == 1) ? $scalar[0] :
423 croak("Multiple scalar context return types specified for function");
424
425 3 ▶ my $list =
Branch: 2 branches
BranchTrueFalseTotal
@list == 0 ? : 2 1 3
@list == 1 ? : 1 0 1
426 (@list == 0) ? undef :
427 (@list == 1) ? $list[0] :
428 croak("Multiple list context return types specified for function");
429
430 3 ▶ return if (!$scalar || $scalar->assumed) && (!$list || $list->assumed);
Branch: 1 branch
BranchTrueFalseTotal
if !$scalar || $scalar->assumed and !$list || $list->assumed 0 3 3
Condition22%2/9
!$scalar || $scalar->assumed and !$list || $list->assumed
!ll&&!rl&&r
300
not $scalar or $scalar->assumed
l!l&&r!l&&!r
003
not $list or $list->assumed
l!l&&r!l&&!r
000
MC/DC0%0/4
!$scalar || $scalar->assumed and !$list || $list->assumed
not $scalar $scalar->assumed not $list $list->assumed
Truth table14%1/7
not(A) or B and not(C) or D
A= not $scalarB= $scalar->assumedC= not $listD= $list->assumed
ABCDresult
00XX0
1X000
01000
1X1X1
1X011
011X1
01011
431
432 3 require Return::Type;
433 3 ▶ my $wrapped = Return::Type->wrap_sub(
Branch: 5 branches
BranchTrueFalseTotal
$scalar ? : 3 0 3
$list ? : 1 2 3
$scalar ? : 3 0 3
$list ? : 1 2 3
$scalar ? : 2 0 2
434 $self->body,
435 scalar => ($scalar ? $scalar->_effective_type : undef),
436 list => ($list ? $list->_effective_type : undef),
437 coerce_scalar => ($scalar ? $scalar->coerce : 0),
438 coerce_list => ($list ? $list->coerce : $scalar ? $scalar->coerce : 0),
439 );
440 3 $self->_set__unwrapped_body($self->body);
441 3 $self->_set_body($wrapped);
442 }
443
444 196 ();
445 }
446  
447 sub _build__pads_to_poke
448 179 ▶{
Subroutine _build__pads_to_poke: called CC=5 SCAR=16.1
449 179 my $self = shift;
450
451 179 ▶ my @pads = $self->_unwrapped_body // $self->body;
Condition66%2/3
$self->_unwrapped_body // $self->body
l!l&&r!l&&!r
31760
MC/DC0%0/2
$self->_unwrapped_body // $self->body
$self->_unwrapped_body $self->body
Truth table66%2/3
A // B
A= $self->_unwrapped_bodyB= $self->body
ABresult
1X1
011
000
452
453 179 ▶ for my $param (@{ $self->signature ? $self->signature->params : [] })
Branch: 1 branch
BranchTrueFalseTotal
$self->signature ? : 150 29 179
454 {
455 244 ▶ push @pads, $param->default if $param->default;
Branch: 1 branch
BranchTrueFalseTotal
if $param->default 13 231 244
456 244 push @pads, @{ $param->constraints };
457 }
458
459 179 \@pads;
460 }
461  
462 sub _poke_pads
463 213 ▶{
Subroutine _poke_pads: called CC=4 SCAR=13.9
464 213 my $self = shift;
465 213 my ($vars) = @_;
466
467 213 for my $code (@{$self->_pads_to_poke})
468 {
469 239 my $closed_over = PadWalker::closed_over($code);
470 ref($vars->{$_}) && ($closed_over->{$_} = $vars->{$_})
471 239 ▶ for keys %$closed_over;
Branch: 1 branch
BranchTrueFalseTotal
ref $vars->{$_} and $closed_over->{$_} = $vars->{$_} 29 1 30
472 239 PadWalker::set_closed_over($code, $closed_over);
473 }
474
475 213 ();
476 }
477  
478 38 1;
479  
480 __END__
« Kavorka/Multi.pm ↑ Summary Parse/KeywordX.pm »