blib/lib/Function/Parameters.pm

filter: Statementstmt 94.5% 208 / 220 Branchbran 82.2% 102 / 124 Conditioncond 73.9% 17 / 23 MC/DCmcdc 50.0% 6 / 12 Subroutinesub 93.9% 31 / 33 Podpod 0.0% 0 / 1 totaltotal 88.1% 364 / 413 CC 76 SCAR 31.2
CC
76
Cov
89%
import
48.9
_reify_type_auto_parameterized
8.2
_find_or_add_idx
5.3
CRAP 22.7
↑ Summary blib/lib/Function/Parameters/Info.pm »
1 package Function::Parameters 2.002006;
2  
3 49 ▶use v5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 49 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 49 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 49 ▶use Carp qw(croak confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 49 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 251 ▶sub _croak {
Subroutine _croak: called CC=1 SCAR=0.0
11 251 my (undef, $file, $line) = caller 1;
12 251 die @_, " at $file line $line.\n";
13 }
14  
15 49 ▶use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 49 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
17 49 XSLoader::load;
18 }
19  
20 2 ▶sub _warn_config_not_a_reference {
Subroutine _warn_config_not_a_reference: called CC=1 SCAR=0.0
21 2 warnings::warnif sprintf q{%s: $^H{'%s'} is not a reference; skipping: %s}, __PACKAGE__, HINTK_CONFIG, $^H{+HINTK_CONFIG};
22 }
23  
24 278 ▶sub _assert_valid_identifier {
Subroutine _assert_valid_identifier: called CC=3 SCAR=11.0
25 278 my ($name, $with_dollar) = @_;
26 278 ▶ my $bonus = $with_dollar ? '\$' : '';
Branch: 1 branch
BranchTrueFalseTotal
$with_dollar ? : 85 193 278
27 278 ▶ $name =~ /\A${bonus}[^\W\d]\w*\z/
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /\A${bonus}[^\W\d]\w*\z/u or confess(qq["$name" doesn't look like a valid identifier]) 273 5 278
28 or confess qq{"$name" doesn't look like a valid identifier};
29 }
30  
31 78 ▶sub _assert_valid_attributes {
Subroutine _assert_valid_attributes: called CC=2 SCAR=6.9
32 78 my ($attrs) = @_;
33 78 ▶ $attrs =~ m{
Branch: 1 branch
BranchTrueFalseTotal
$attrs =~ / \A \s*+ : \s*+ (?&ident) (?! [^\s:(] ) (?&param)?+ \s*+ (?: (?: : \s*+ )? (?&ident) (?! [^\s:(] ) (?&param)?+ \s*+ )*+ \z (?(DEFINE) (?<ident> [^\W\d] \w*+ ) (?<param> \( [^()\\]*+ (?: (?: \\ . | (?&param) ) [^()\\]*+ )*+ \) ) ) /sux or confess(qq["$attrs" doesn't look like valid attributes]) 76 2 78
34 \A \s*+
35 : \s*+
36 (?&ident) (?! [^\s:(] ) (?&param)?+ \s*+
37 (?:
38 (?: : \s*+ )?
39 (?&ident) (?! [^\s:(] ) (?&param)?+ \s*+
40 )*+
41 \z
42  
43 (?(DEFINE)
44 (?<ident>
45 [^\W\d]
46 \w*+
47 )
48 (?<param>
49 \(
50 [^()\\]*+
51 (?:
52 (?:
53 \\ .
54 |
55 (?&param)
56 )
57 [^()\\]*+
58 )*+
59 \)
60 )
61 )
62 }sx or confess qq{"$attrs" doesn't look like valid attributes};
63 }
64  
65 0 ▶sub _reify_type_moose {
Subroutine _reify_type_moose: not called CC=1 SCAR=6.9
66 0 require Moose::Util::TypeConstraints;
67 0 Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($_[0])
68 }
69  
70 0 ▶sub _malformed_type {
Subroutine _malformed_type: not called CC=1 SCAR=6.9
71 0 my ($type, $msg) = @_;
72 0 my $pos = pos $_[0];
73 0 substr $type, $pos, 0, ' <-- HERE ';
74 0 croak "Malformed type: $msg marked by <-- HERE in '$type'";
75 }
76  
77 72 ▶sub _reify_type_auto_parameterized {
Subroutine _reify_type_auto_parameterized: called CC=8 SCAR=21.0
78 # (str, caller)
79 72 ▶ $_[0] =~ /\G ( \w+ (?: :: \w+)* ) \s* /xgc or _malformed_type $_[0], "missing type name";
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /\G ( \w+ (?: :: \w+)* ) \s* /cgux or _malformed_type($_[0], "missing type name") 72 0 72
80 72 my $name = $1;
81 72 ▶ $name = "$_[1]::$name" unless $name =~ /::/;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /::/u 72 0 72
82 72 my $fun = do {
83 49 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
84 72 ▶ defined &$name or croak "Undefined type name $name";
Branch: 1 branch
BranchTrueFalseTotal
defined &$name or croak("Undefined type name $name") 70 2 72
85 70 \&$name
86 };
87  
88 70 ▶ $_[0] =~ /\G \[ \s* /xgc
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /\G \[ \s* /cgux or return $fun 8 62 70
89 or return $fun;
90  
91 8 my @args;
92 8 ▶ until ($_[0] =~ /\G \] \s* /xgc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_[0] =~ /\G \] \s* /cgux) 16 8 24
93 16 ▶ $_[0] =~ /\G , \s* /xgc or _malformed_type $_[0], "missing ',' or ']'"
Branch: 1 branch
BranchTrueFalseTotal
if @args 8 8 16
Condition50%3/6
@args && ($_[0] =~ /\G , \s* /cgux || _malformed_type($_[0], q(missing ',' or ']')))
!ll&&!rl&&r
880
$_[0] =~ /\G , \s* /cgux or _malformed_type($_[0], "missing ',' or ']'")
l!l&&r!l&&!r
800
MC/DC0%0/3
@args && ($_[0] =~ /\G , \s* /cgux || _malformed_type($_[0], q(missing ',' or ']')))
@args $_[0] =~ /\G , \s* /cgux _malformed_type($_[0], "missing ',' or ']'")
Truth table0%0/4
A && B or C
A= @argsB= $_[0] =~ /\G , \s* /cguxC= _malformed_type($_[0], "missing ',' or ']'")
ABCresult
0XX0
1000
11X1
1011
94 if @args;
95 16 push @args, &_reify_type_auto_union;
96 }
97  
98 8 ▶ sub { $fun->([map $_->(), @args]) }
Subroutine __ANON__: called CC=1 SCAR=0.0
99 8 }
100  
101 76 ▶sub _reify_type_auto_term {
Subroutine _reify_type_auto_term: called CC=5 SCAR=16.1
102 # (str, caller)
103 76 my $compl = 0;
104 76 ▶ while ($_[0] =~ /\G ~ \s* /xgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /\G ~ \s* /cgux) 8 76 84
105 8 $compl++;
106 }
107  
108 76 my $inner;
109 76 ▶ if ($_[0] =~ /\G \( \s* /xgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /\G \( \s* /cgux) { } 4 72 76
110 4 $inner = &_reify_type_auto_union;
111 4 ▶ $_[0] =~ /\G \) \s* /xgc or _malformed_type $_[0], "missing ')'";
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /\G \) \s* /cgux or _malformed_type($_[0], "missing ')'") 4 0 4
112 } else {
113 72 $inner = &_reify_type_auto_parameterized;
114 }
115  
116 !$compl
117 ? $inner
118 4 ▶ : sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
119 4 my $t = $inner->();
120 4 for my $i (1 .. $compl) {
121 8 $t = ~$t;
122 }
123 $t
124 4 }
125 74 ▶}
Branch: 1 branch
BranchTrueFalseTotal
!$compl ? : 70 4 74
126  
127 72 ▶sub _reify_type_auto_alternative {
Subroutine _reify_type_auto_alternative: called CC=2 SCAR=6.9
128 # (str, caller)
129 72 my $fun = &_reify_type_auto_term;
130 70 ▶ while ($_[0] =~ m!\G / \s* !xgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ m[\G / \s* ]cgux) 4 70 74
131 4 my $right = &_reify_type_auto_term;
132 4 my $left = $fun;
133 4 ▶ $fun = sub { $left->() / $right->() };
Subroutine __ANON__: called CC=1 SCAR=0.0
134 }
135 $fun
136 70 }
137  
138 64 ▶sub _reify_type_auto_intersection {
Subroutine _reify_type_auto_intersection: called CC=2 SCAR=6.9
139 # (str, caller)
140 64 my $fun = &_reify_type_auto_alternative;
141 62 ▶ while ($_[0] =~ /\G & \s* /xgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /\G & \s* /cgux) 8 62 70
142 8 my $right = &_reify_type_auto_alternative;
143 8 my $left = $fun;
144 8 ▶ $fun = sub { $left->() & $right->() };
Subroutine __ANON__: called CC=1 SCAR=0.0
145 }
146 $fun
147 62 }
148  
149 50 ▶sub _reify_type_auto_union {
Subroutine _reify_type_auto_union: called CC=2 SCAR=6.9
150 # (str, caller)
151 50 my $fun = &_reify_type_auto_intersection;
152 48 ▶ while ($_[0] =~ /\G \| \s* /xgc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /\G \| \s* /cgux) 14 48 62
153 14 my $right = &_reify_type_auto_intersection;
154 14 my $left = $fun;
155 14 ▶ $fun = sub { $left->() | $right->() };
Subroutine __ANON__: called CC=1 SCAR=0.0
156 }
157 $fun
158 48 }
159  
160 30 ▶sub _reify_type_auto {
Subroutine _reify_type_auto: called CC=2 SCAR=7.0
161 30 my ($type) = @_;
162 30 my $caller = caller;
163  
164 30 $type =~ /\G \s+ /xgc;
165 30 my $tfun = _reify_type_auto_union $type, $caller;
166 28 ▶ $type =~ /\G \z/xgc or _malformed_type $type, "trailing garbage";
Branch: 1 branch
BranchTrueFalseTotal
$type =~ /\G \z/cgux or _malformed_type($type, "trailing garbage") 28 0 28
167 28 $tfun->()
168 }
169  
170 1176 ▶sub _delete_default {
Subroutine _delete_default: called CC=2 SCAR=6.9
171 1176 my ($href, $key, $default) = @_;
172 1176 ▶ exists $href->{$key} ? delete $href->{$key} : $default
Branch: 1 branch
BranchTrueFalseTotal
exists $href->{$key} ? : 120 1056 1176
173 }
174  
175 1 ▶sub _find_or_add_idx {
Subroutine _find_or_add_idx: called CC=4 SCAR=16.6
176 1 my ($array, $x) = @_;
177 1 my $index;
178 1 for my $i (0 .. $#$array) {
179 0 ▶ if ($array->[$i] == $x) {
Branch: 1 branch
BranchTrueFalseTotal
if ($array->[$i] == $x) 0 0 0
180 0 $index = $i;
181 0 last;
182 }
183 }
184 1 ▶ unless (defined $index) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $index) 1 0 1
185 1 $index = @$array;
186 1 push @$array, $x;
187 }
188 $index
189 1 }
190  
191 49 my %type_map = (
192 function_strict => {},
193 function_lax => {
194 defaults => 'function_strict',
195 strict => 0,
196 },
197 function => { defaults => 'function_strict' },
198  
199 method_strict => {
200 defaults => 'function_strict',
201 attributes => ':method',
202 shift => '$self',
203 invocant => 1,
204 },
205 method_lax => {
206 defaults => 'method_strict',
207 strict => 0,
208 },
209 method => { defaults => 'method_strict' },
210  
211 classmethod_strict => {
212 defaults => 'method_strict',
213 shift => '$class',
214 },
215 classmethod_lax => {
216 defaults => 'classmethod_strict',
217 strict => 0,
218 },
219 classmethod => { defaults => 'classmethod_strict' },
220  
221 around => {
222 defaults => 'method',
223 name => 'required',
224 install_sub => 'around',
225 shift => ['$orig', '$self'],
226 runtime => 1,
227 },
228 (
229 map +(
230 $_ => {
231 defaults => 'method',
232 name => 'required',
233 install_sub => $_,
234 runtime => 1,
235 }
236 ), qw(
237 before after augment override
238 ),
239 ),
240 );
241  
242 49 my %import_map = (
243 fun => 'function',
244 (
245 map +($_ => $_),
246 qw(
247 method
248 classmethod
249 before
250 after
251 around
252 augment
253 override
254 )
255 ),
256  
257 ':strict' => {
258 fun => 'function_strict',
259 method => 'method_strict',
260 },
261  
262 ':lax' => {
263 fun => 'function_lax',
264 method => 'method_lax',
265 },
266  
267 ':std' => [qw(fun method)],
268 ':modifiers' => [qw(
269 before
270 after
271 around
272 augment
273 override
274 )],
275 );
276 49 for my $v (values %import_map) {
277 588 ▶ if (ref $v eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v eq "ARRAY") 98 490 588
278 $v = {
279 98 ▶ map +($_ => $import_map{$_} || die "Internal error: $v => $_"),
Condition50%1/2
$import_map{$_} || die("Internal error: $v => $_")
l!l
3430
MC/DC0%0/1
$import_map{$_} || die("Internal error: $v => $_")
$import_map{$_}
Truth table50%1/2
A
A= $import_map{$_}
Aresult
11
00
280 @$v
281 };
282 }
283 }
284  
285 96 ▶sub import {
Subroutine import: called CC=46 SCAR=38.9
286 96 my $class = shift;
287  
288 96 my %imports;
289 96 ▶ @_ = qw(:std) if !@_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 27 69 96
290 96 for my $item (@_) {
291 102 my $part;
292 102 ▶ if (ref $item) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item) { } 51 51 102
293 51 $part = $item;
294 } else {
295 51 ▶ my $type = $import_map{$item}
Branch: 1 branch
BranchTrueFalseTotal
my $type = $import_map{$item} or croak(qq["$item" is not exported by the $class module]) 49 2 51
296 or croak qq{"$item" is not exported by the $class module};
297 49 ▶ $part = ref $type
Branch: 1 branch
BranchTrueFalseTotal
ref $type ? : 46 3 49
298 ? $type
299 : { $item => $type };
300 }
301 100 @imports{keys %$part} = values %$part;
302 }
303  
304 94 my %spec;
305  
306 94 for my $name (sort keys %imports) {
307 176 _assert_valid_identifier $name;
308 171 my $proto_type = $imports{$name};
309  
310 171 ▶ $proto_type = {defaults => $proto_type} unless ref $proto_type;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $proto_type 125 46 171
311  
312 171 my %type = %$proto_type;
313 171 ▶ while (my $defaults = delete $type{defaults}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $defaults = delete $type{"defaults"}) 345 170 515
314 345 ▶ my $base = $type_map{$defaults}
Branch: 1 branch
BranchTrueFalseTotal
my $base = $type_map{$defaults} or confess(qq["$defaults" doesn't look like a valid type (one of ${\join(", ", sort(keys %type_map));})]) 344 1 345
315 1 or confess qq["$defaults" doesn't look like a valid type (one of ${\join ', ', sort keys %type_map})];
316 344 %type = (%$base, %type);
317 }
318  
319 170 ▶ if (exists $type{strict}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $type{"strict"}) 21 149 170
320 21 ▶ $type{check_argument_count} ||= $type{strict};
Condition66%2/3
$type{"check_argument_count"} ||= $type{"strict"}
l!l&&r!l&&!r
0615
MC/DC50%1/2
$type{"check_argument_count"} ||= $type{"strict"}
$type{"check_argument_count"} $type{"strict"}
Truth table66%2/3
A ||= B
A= $type{"check_argument_count"}B= $type{"strict"}
ABresult
1X1
011
000
321 21 delete $type{strict};
322 }
323  
324 170 my %clean;
325  
326 170 ▶ $clean{name} = delete $type{name} // 'optional';
Condition100%2/2
delete $type{"name"} // "optional"
l!l
30140
MC/DC100%1/1
delete $type{"name"} // "optional"
delete $type{"name"}
Truth table100%2/2
A
A= delete $type{"name"}
Aresult
11
00
327 170 ▶ $clean{name} =~ /\A(?:optional|required|prohibited)\z/
Branch: 1 branch
BranchTrueFalseTotal
$clean{"name"} =~ /\A(?:optional|required|prohibited)\z/u or confess(qq["$clean{"name"}" doesn't look like a valid name attribute (one of optional, required, prohibited)]) 170 0 170
328 or confess qq["$clean{name}" doesn't look like a valid name attribute (one of optional, required, prohibited)];
329  
330 170 ▶ $clean{attrs} = delete $type{attributes} // '';
Condition100%2/2
delete $type{"attributes"} // ""
l!l
7892
MC/DC100%1/1
delete $type{"attributes"} // ""
delete $type{"attributes"}
Truth table100%2/2
A
A= delete $type{"attributes"}
Aresult
11
00
331 170 ▶ _assert_valid_attributes $clean{attrs} if $clean{attrs};
Branch: 1 branch
BranchTrueFalseTotal
if $clean{"attrs"} 78 92 170
332  
333 168 ▶ if (!exists $type{reify_type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $type{'reify_type'}) { } 164 4 168
334 164 $clean{reify_type} = \&_reify_type_auto;
335 } else {
336 4 ▶ my $rt = delete $type{reify_type} // '(undef)';
Condition50%1/2
delete $type{"reify_type"} // "(undef)"
l!l
40
MC/DC0%0/1
delete $type{"reify_type"} // "(undef)"
delete $type{"reify_type"}
Truth table50%1/2
A
A= delete $type{"reify_type"}
Aresult
11
00
337 4 ▶ if (!ref $rt) {
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $rt) { } 0 4 4
elsif (ref $rt ne 'CODE') { } 0 4 4
338 0 ▶ $rt =
Branch: 2 branches
BranchTrueFalseTotal
$rt eq 'auto' ? : 0 0 0
$rt eq 'moose' ? : 0 0 0
339 $rt eq 'auto' ? \&_reify_type_auto :
340 $rt eq 'moose' ? \&_reify_type_moose :
341 confess qq{"$rt" isn't a known predefined type reifier};
342 } elsif (ref $rt ne 'CODE') {
343 0 confess qq{"$rt" doesn't look like a type reifier};
344 }
345  
346 4 $clean{reify_type} = $rt;
347 }
348  
349 168 ▶ if (!exists $type{install_sub}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $type{'install_sub'}) { } 150 18 168
350 150 $clean{install_sub} = '';
351 } else {
352 18 my $is = delete $type{install_sub};
353 18 ▶ if (!ref $is) {
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $is) { } 17 1 18
elsif (ref $is ne 'CODE') { } 0 1 1
354 17 _assert_valid_identifier $is;
355 } elsif (ref $is ne 'CODE') {
356 0 confess qq{"$is" doesn't look like a sub installer};
357 }
358  
359 18 $clean{install_sub} = $is;
360 }
361  
362 168 $clean{shift} = do {
363 168 ▶ my $shift = delete $type{shift} // [];
Condition100%2/2
delete $type{"shift"} // []
l!l
8187
MC/DC100%1/1
delete $type{"shift"} // []
delete $type{"shift"}
Truth table100%2/2
A
A= delete $type{"shift"}
Aresult
11
00
364 168 ▶ $shift = [$shift] if !ref $shift;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $shift 76 92 168
365 168 my $str = '';
366 168 my @shifty_types;
367 168 for my $item (@$shift) {
368 85 my ($name, $type);
369 85 ▶ if (ref $item) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item) { } 1 84 85
370 1 ▶ @$item == 2 or confess "A 'shift' item must have 2 elements, not " . @$item;
Branch: 1 branch
BranchTrueFalseTotal
@$item == 2 or confess(q[A 'shift' item must have 2 elements, not ] . @$item) 1 0 1
371 1 ($name, $type) = @$item;
372 } else {
373 84 $name = $item;
374 }
375 85 _assert_valid_identifier $name, 1;
376 85 ▶ $name eq '$_' and confess q[Using "$_" as a parameter is not supported];
Branch: 1 branch
BranchTrueFalseTotal
$name eq "\$_" and confess("Using \"\$_\" as a parameter is not supported") 0 85 85
377 85 $str .= $name;
378 85 ▶ if (defined $type) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type) 1 84 85
379 1 ▶ blessed($type) or confess "${name}'s type must be an object, not $type";
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($type) or confess("${name}'s type must be an object, not $type") 1 0 1
380 1 my $index = _find_or_add_idx \@shifty_types, $type;
381 1 $str .= "/$index";
382 }
383 85 $str .= ' ';
384 }
385 168 $clean{shift_types} = \@shifty_types;
386 168 $str
387 };
388  
389 168 $clean{default_arguments} = _delete_default \%type, 'default_arguments', 1;
390 168 $clean{named_parameters} = _delete_default \%type, 'named_parameters', 1;
391 168 $clean{types} = _delete_default \%type, 'types', 1;
392 168 $clean{invocant} = _delete_default \%type, 'invocant', 0;
393 168 $clean{runtime} = _delete_default \%type, 'runtime', 0;
394 168 $clean{check_argument_count} = _delete_default \%type, 'check_argument_count', 1;
395 168 $clean{check_argument_types} = _delete_default \%type, 'check_argument_types', 1;
396  
397 168 ▶ %type and confess "Invalid keyword property: @{[sort keys %type]}";
Branch: 1 branch
BranchTrueFalseTotal
%type and confess("Invalid keyword property: @{[sort(keys %type)];}") 1 167 168
398  
399 167 $spec{$name} = \%clean;
400 }
401  
402 85 ▶ my %config = %{$^H{+HINTK_CONFIG} // {}};
Condition100%2/2
$^H{"Function::Parameters/config"} // {}
l!l
1273
MC/DC100%1/1
$^H{"Function::Parameters/config"} // {}
$^H{"Function::Parameters/config"}
Truth table100%2/2
A
A= $^H{"Function::Parameters/config"}
Aresult
11
00
403 85 for my $kw (keys %spec) {
404 167 my $type = $spec{$kw};
405  
406 my $flags =
407 $type->{name} eq 'prohibited' ? FLAG_ANON_OK :
408 167 ▶ $type->{name} eq 'required' ? FLAG_NAME_OK :
Branch: 2 branches
BranchTrueFalseTotal
$type->{'name'} eq 'prohibited' ? : 5 162 167
$type->{'name'} eq 'required' ? : 25 137 162
409 FLAG_ANON_OK | FLAG_NAME_OK
410 ;
411 167 ▶ $flags |= FLAG_DEFAULT_ARGS if $type->{default_arguments};
Branch: 1 branch
BranchTrueFalseTotal
if $type->{"default_arguments"} 166 1 167
412 167 ▶ $flags |= FLAG_CHECK_NARGS if $type->{check_argument_count};
Branch: 1 branch
BranchTrueFalseTotal
if $type->{"check_argument_count"} 152 15 167
413 167 ▶ $flags |= FLAG_CHECK_TARGS if $type->{check_argument_types};
Branch: 1 branch
BranchTrueFalseTotal
if $type->{"check_argument_types"} 167 0 167
414 167 ▶ $flags |= FLAG_INVOCANT if $type->{invocant};
Branch: 1 branch
BranchTrueFalseTotal
if $type->{"invocant"} 76 91 167
415 167 ▶ $flags |= FLAG_NAMED_PARAMS if $type->{named_parameters};
Branch: 1 branch
BranchTrueFalseTotal
if $type->{"named_parameters"} 167 0 167
416 167 ▶ $flags |= FLAG_TYPES_OK if $type->{types};
Branch: 1 branch
BranchTrueFalseTotal
if $type->{"types"} 167 0 167
417 167 ▶ $flags |= FLAG_RUNTIME if $type->{runtime};
Branch: 1 branch
BranchTrueFalseTotal
if $type->{"runtime"} 15 152 167
418 $config{$kw} = {
419 HINTSK_FLAGS, => $flags,
420 HINTSK_SHIFT, => $type->{shift},
421 HINTSK_ATTRS, => $type->{attrs},
422 HINTSK_REIFY, => $type->{reify_type},
423 HINTSK_INSTL, => $type->{install_sub},
424 167 !@{$type->{shift_types}} ? () : (
425 HINTSK_SHIF2, => $type->{shift_types},
426 167 ▶ ),
Branch: 1 branch
BranchTrueFalseTotal
!@{$type->{'shift_types'};} ? : 166 1 167
427 };
428 }
429 85 $^H{+HINTK_CONFIG} = \%config;
430 }
431  
432 8 ▶sub unimport {
Subroutine unimport: called CC=2 SCAR=6.9
433 8 my $class = shift;
434  
435 8 ▶ if (!@_) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_) 3 5 8
436 3 delete $^H{+HINTK_CONFIG};
437 3 return;
438 }
439  
440 5 my %config = %{$^H{+HINTK_CONFIG}};
441 5 delete @config{@_};
442 5 $^H{+HINTK_CONFIG} = \%config;
443 }
444  
445  
446 49 our %metadata;
447  
448 556 ▶sub _register_info {
Subroutine _register_info: called CC=2 SCAR=6.9
449 my (
450 556 $key,
451 $declarator,
452 $shift,
453 $positional_required,
454 $positional_optional,
455 $named_required,
456 $named_optional,
457 $slurpy,
458 $slurpy_type,
459 ) = @_;
460  
461 556 ▶ my $info = {
Branch: 1 branch
BranchTrueFalseTotal
defined $slurpy ? : 36 520 556
462 declarator => $declarator,
463 shift => $shift,
464 positional_required => $positional_required,
465 positional_optional => $positional_optional,
466 named_required => $named_required,
467 named_optional => $named_optional,
468 slurpy => defined $slurpy ? [$slurpy, $slurpy_type] : undef,
469 };
470  
471 556 $metadata{$key} = $info;
472 }
473  
474 16 ▶sub _mkparam1 {
Subroutine _mkparam1: called CC=3 SCAR=11.0
475 16 my ($pair) = @_;
476 16 ▶ my ($v, $t) = @{$pair || []} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
() = @{$pair or [];} or return undef 4 12 16
Condition100%2/2
$pair || []
l!l
412
MC/DC100%1/1
$pair || []
$pair
Truth table100%2/2
A
A= $pair
Aresult
11
00
477 4 Function::Parameters::Param->new(
478 name => $v,
479 type => $t,
480 )
481 }
482  
483 64 ▶sub _mkparams {
Subroutine _mkparams: called CC=2 SCAR=6.9
484 64 my @r;
485 64 ▶ while (my ($v, $t) = splice @_, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@_, 0, 2)) 38 64 102
486 38 push @r, Function::Parameters::Param->new(
487 name => $v,
488 type => $t,
489 );
490 }
491 \@r
492 64 }
493  
494 18 ▶sub info {
Subroutine info: called CC=3 SCAR=11.0
Pod undocumented
495 18 my ($func) = @_;
496 18 ▶ my $key = _cv_root $func or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $key = &_cv_root($func) or return undef 18 0 18
497 18 ▶ my $info = $metadata{$key} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $info = $metadata{$key} or return undef 16 2 18
498 16 require Function::Parameters::Info;
499 Function::Parameters::Info->new(
500 keyword => $info->{declarator},
501 nshift => $info->{shift},
502 slurpy => _mkparam1($info->{slurpy}),
503 (
504 16 map +("_$_" => _mkparams @{$info->{$_}}),
505 qw(
506 positional_required
507 positional_optional
508 named_required
509 named_optional
510 )
511 )
512 )
513 }
514  
515 49 'ok'
516  
517 __END__
↑ Summary blib/lib/Function/Parameters/Info.pm »