blib/lib/Function/Parameters/Info.pm

filter: Statementstmt 100% 144 / 144 Branchbran 53.3% 48 / 90 Conditioncond 58.3% 7 / 12 MC/DCmcdc 28.5% 2 / 7 Subroutinesub 100% 21 / 21 Podpod 75.0% 9 / 12 totaltotal 80.7% 231 / 286 CC 50 SCAR 18.3
CC
50
Cov
81%
new
16.9
new
8.6
args_max
6.1
CRAP 6.2
« blib/lib/Function/Parameters.pm ↑ Summary Parameters.xs »
1 package Function::Parameters::Info 2.002006;
2  
3 4 ▶use v5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Function::Parameters;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 {
10 package Function::Parameters::Param;
11  
12 use overload
13 40 ▶ fallback => 1,
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method (anon) (expected 1, got ' . @_ . ')') 0 40 40
14 4 ▶ '""' => method (@) { $self->{name} },
Subroutine __ANON__: called CC=2 SCAR=6.9
15 4 ;
16  
17 42 ▶ method new($class: :$name, :$type) {
Subroutine new: called CC=7 SCAR=21.5
Branch: 5 branches
BranchTrueFalseTotal
@_ < 5 and Function::Parameters::_croak('Too few arguments for method new (expected 5, got ' . @_ . ')') 0 42 42
@_ > 1 and (@_ - 1) % 2 and Function::Parameters::_croak("Odd number of paired arguments for method new") 0 42 42
exists ${__rest}{'name'} ? : 42 0 42
exists ${__rest}{'type'} ? : 42 0 42
keys %{__rest} and Function::Parameters::_croak('In method new: no such named parameter: ' . join(", ", sort(keys %{__rest}))) 0 42 42
Condition33%1/3
@_ > 1 and (@_ - 1) % 2
!ll&&!rl&&r
0420
MC/DC0%0/2
@_ > 1 and (@_ - 1) % 2
@_ > 1 (@_ - 1) % 2
Truth table33%1/3
A and B
A= @_ > 1B= (@_ - 1) % 2
ABresult
0X0
100
111
18 42 bless { @_ }, $class
19 4 }
20  
21 8 ▶ method name() { $self->{name} }
Subroutine name: called CC=3 SCAR=11.2
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method name (expected 1, got ' . @_ . ')') 0 8 8
@_ > 1 and Function::Parameters::_croak('Too many arguments for method name (expected 1, got ' . @_ . ')') 0 8 8
22 8 ▶ method type() { $self->{type} }
Subroutine type: called CC=3 SCAR=11.2
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method type (expected 1, got ' . @_ . ')') 0 8 8
@_ > 1 and Function::Parameters::_croak('Too many arguments for method type (expected 1, got ' . @_ . ')') 0 8 8
23 }
24  
25 16 ▶method new($class:
Subroutine new: called CC=12 SCAR=28.3
Pod undocumented
26 :$keyword,
27 :$nshift,
28 :$_positional_required,
29 :$_positional_optional,
30 :$_named_required,
31 :$_named_optional,
32 :$slurpy,
33 16 ▶) {
Branch: 10 branches
BranchTrueFalseTotal
@_ < 15 and Function::Parameters::_croak('Too few arguments for method new (expected 15, got ' . @_ . ')') 0 16 16
@_ > 1 and (@_ - 1) % 2 and Function::Parameters::_croak("Odd number of paired arguments for method new") 0 16 16
exists ${__rest}{'keyword'} ? : 16 0 16
exists ${__rest}{'nshift'} ? : 16 0 16
exists ${__rest}{'_positional_required'} ? : 16 0 16
exists ${__rest}{'_positional_optional'} ? : 16 0 16
exists ${__rest}{'_named_required'} ? : 16 0 16
exists ${__rest}{'_named_optional'} ? : 16 0 16
exists ${__rest}{'slurpy'} ? : 16 0 16
keys %{__rest} and Function::Parameters::_croak('In method new: no such named parameter: ' . join(", ", sort(keys %{__rest}))) 0 16 16
Condition33%1/3
@_ > 1 and (@_ - 1) % 2
!ll&&!rl&&r
0160
MC/DC0%0/2
@_ > 1 and (@_ - 1) % 2
@_ > 1 (@_ - 1) % 2
Truth table33%1/3
A and B
A= @_ > 1B= (@_ - 1) % 2
ABresult
0X0
100
111
34 16 bless {@_}, $class
35 4 }
36  
37 11 ▶method keyword() { $self->{keyword} }
Subroutine keyword: called CC=3 SCAR=11.2
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method keyword (expected 1, got ' . @_ . ')') 0 11 11
@_ > 1 and Function::Parameters::_croak('Too many arguments for method keyword (expected 1, got ' . @_ . ')') 0 11 11
38 55 ▶method nshift () { $self->{nshift} }
Subroutine nshift: called CC=3 SCAR=11.2
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method nshift (expected 1, got ' . @_ . ')') 0 55 55
@_ > 1 and Function::Parameters::_croak('Too many arguments for method nshift (expected 1, got ' . @_ . ')') 0 55 55
39 21 ▶method slurpy () { $self->{slurpy} }
Subroutine slurpy: called CC=3 SCAR=11.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method slurpy (expected 1, got ' . @_ . ')') 0 21 21
@_ > 1 and Function::Parameters::_croak('Too many arguments for method slurpy (expected 1, got ' . @_ . ')') 0 21 21
40 22 ▶method positional_optional() { @{$self->{_positional_optional}} }
Subroutine positional_optional: called CC=3 SCAR=11.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method positional_optional (expected 1, got ' . @_ . ')') 0 22 22
@_ > 1 and Function::Parameters::_croak('Too many arguments for method positional_optional (expected 1, got ' . @_ . ')') 0 22 22
41 38 ▶method named_required () { @{$self->{_named_required}} }
Subroutine named_required: called CC=3 SCAR=11.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method named_required (expected 1, got ' . @_ . ')') 0 38 38
@_ > 1 and Function::Parameters::_croak('Too many arguments for method named_required (expected 1, got ' . @_ . ')') 0 38 38
42 22 ▶method named_optional () { @{$self->{_named_optional}} }
Subroutine named_optional: called CC=3 SCAR=11.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method named_optional (expected 1, got ' . @_ . ')') 0 22 22
@_ > 1 and Function::Parameters::_croak('Too many arguments for method named_optional (expected 1, got ' . @_ . ')') 0 22 22
43  
44 22 ▶method positional_required() {
Subroutine positional_required: called CC=3 SCAR=11.1
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method positional_required (expected 1, got ' . @_ . ')') 0 22 22
@_ > 1 and Function::Parameters::_croak('Too many arguments for method positional_required (expected 1, got ' . @_ . ')') 0 22 22
45 22 my @p = @{$self->{_positional_required}};
46 22 splice @p, 0, $self->nshift;
47 @p
48 22 }
49  
50 12 ▶method args_min() {
Subroutine args_min: called CC=3 SCAR=11.1
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method args_min (expected 1, got ' . @_ . ')') 0 12 12
@_ > 1 and Function::Parameters::_croak('Too many arguments for method args_min (expected 1, got ' . @_ . ')') 0 12 12
51 12 my $r = 0;
52 12 $r += @{$self->{_positional_required}};
53 12 $r += $self->named_required * 2;
54 12 $r
55 4 }
56  
57 12 ▶method args_max() {
Subroutine args_max: called CC=6 SCAR=18.1
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method args_max (expected 1, got ' . @_ . ')') 0 12 12
@_ > 1 and Function::Parameters::_croak('Too many arguments for method args_max (expected 1, got ' . @_ . ')') 0 12 12
58 12 ▶ return 0 + 'Inf' if defined $self->slurpy || $self->named_required || $self->named_optional;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->slurpy or $self->named_required or $self->named_optional 8 4 12
Condition83%5/6
defined $self->slurpy or $self->named_required or $self->named_optional
l!l&&r!l&&!r
804
defined $self->slurpy or $self->named_required
l!l&&r!l&&!r
444
MC/DC66%2/3
defined $self->slurpy or $self->named_required or $self->named_optional
defined $self->slurpy $self->named_required $self->named_optional
Truth table75%3/4
A or B or C
A= defined $self->slurpyB= $self->named_requiredC= $self->named_optional
ABCresult
1XX1
01X1
0011
0000
59 4 my $r = 0;
60 4 $r += @{$self->{_positional_required}};
61 4 $r += $self->positional_optional;
62 4 $r
63 4 }
64  
65 12 ▶method invocant() {
Subroutine invocant: called CC=5 SCAR=16.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method invocant (expected 1, got ' . @_ . ')') 0 12 12
@_ > 1 and Function::Parameters::_croak('Too many arguments for method invocant (expected 1, got ' . @_ . ')') 0 12 12
66 12 my $nshift = $self->nshift;
67 return undef
68 12 ▶ if $nshift == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $nshift == 0 6 6 12
69 6 ▶ return $self->{_positional_required}[0]
Branch: 1 branch
BranchTrueFalseTotal
if $nshift == 1 3 3 6
70 if $nshift == 1;
71 3 Carp::croak "Can't return a single invocant; this function has $nshift";
72 4 }
73  
74 21 ▶method invocants() {
Subroutine invocants: called CC=3 SCAR=11.1
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method invocants (expected 1, got ' . @_ . ')') 0 21 21
@_ > 1 and Function::Parameters::_croak('Too many arguments for method invocants (expected 1, got ' . @_ . ')') 0 21 21
75 21 my @p = @{$self->{_positional_required}};
76 21 splice @p, $self->nshift;
77 @p
78 21 }
79  
80 4 'ok'
81  
82 __END__
« blib/lib/Function/Parameters.pm ↑ Summary Parameters.xs »