Sub/Meta/Parameters.pm

filter: Statementstmt 100% 232 / 232 Branchbran 100% 120 / 120 Conditioncond 98.5% 66 / 67 MC/DCmcdc 97.6% 41 / 42 Subroutinesub 100% 40 / 40 Podpod 100% 30 / 30 totaltotal 99.6% 529 / 531 CC 86 SCAR 18.9
CC
86
Cov
100%
error_message
12.0
relaxed_error_message
11.0
_normalize_args
10.0
CRAP 6.6
« Sub/Meta/Test.pm ↑ Summary Sub/Meta/Param.pm »
1 package Sub::Meta::Parameters;
2 34 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 34 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 34 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 34 our $VERSION = "0.15";
7  
8 34 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 34 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 34 ▶use Sub::Meta::Param;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 use overload
14 34 ▶ fallback => 1,
Subroutine BEGIN: called CC=1 SCAR=0.0
15 eq => \&is_same_interface
16 34 ;
17  
18 5 ▶sub _croak { require Carp; goto &Carp::croak }
Subroutine _croak: called CC=1 SCAR=0.0
19  
20 132 ▶sub param_class { return 'Sub::Meta::Param' }
Subroutine param_class: called CC=1 SCAR=0.0
Pod documented
21  
22 296 ▶sub new {
Subroutine new: called CC=6 SCAR=17.9
Pod documented
23 296 my ($class, @args) = @_;
24 296 ▶ my %args = @args == 1 ? %{$args[0]} : @args;
Branch: 1 branch
BranchTrueFalseTotal
@args == 1 ? : 260 36 296
25  
26 294 my $self = bless \%args => $class;
27 294 ▶ $self->set_args($args{args}) if exists $args{args};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"args"} 161 133 294
28 294 ▶ $self->set_invocant(delete $args{invocant}) if defined $args{invocant};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"invocant"} 19 275 294
29 294 ▶ $self->set_nshift(delete $args{nshift}) if defined $args{nshift};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"nshift"} 237 57 294
30 294 ▶ $self->set_slurpy(delete $args{slurpy}) if defined $args{slurpy};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"slurpy"} 24 270 294
31  
32 294 return $self;
33 }
34  
35 741 ▶sub nshift() { my $self = shift; return $self->{nshift} // 0 }
Subroutine nshift: called CC=2 SCAR=6.9
Pod documented
Condition100%2/2
$self->{"nshift"} // 0
l!l
531210
MC/DC100%1/1
$self->{"nshift"} // 0
$self->{"nshift"}
Truth table100%2/2
A
A= $self->{"nshift"}
Aresult
11
00
36 278 ▶sub slurpy() { my $self = shift; return $self->{slurpy} }
Subroutine slurpy: called CC=1 SCAR=0.0
Pod documented
37 2255 ▶sub args() { my $self = shift; return $self->{args} // [] }
Subroutine args: called CC=2 SCAR=6.9
Pod documented
Condition100%2/2
$self->{"args"} // []
l!l
1699556
MC/DC100%1/1
$self->{"args"} // []
$self->{"args"}
Truth table100%2/2
A
A= $self->{"args"}
Aresult
11
00
38 332 ▶sub invocant() { my $self = shift; return $self->{invocant} }
Subroutine invocant: called CC=1 SCAR=0.0
Pod documented
39 1800 ▶sub invocants() { my $self = shift; return $self->has_invocant ? [ $self->{invocant} ] : [] }
Subroutine invocants: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$self->has_invocant ? : 531 1269 1800
40 1629 ▶sub all_args() { my $self = shift; return [ @{$self->invocants}, @{$self->args} ] }
Subroutine all_args: called CC=1 SCAR=0.0
Pod documented
41  
42 117 ▶sub has_args() { my $self = shift; return defined $self->{args} }
Subroutine has_args: called CC=1 SCAR=0.0
Pod documented
43 1881 ▶sub has_invocant() { my $self = shift; return defined $self->{invocant} }
Subroutine has_invocant: called CC=1 SCAR=0.0
Pod documented
44 507 ▶sub has_slurpy() { my $self = shift; return defined $self->{slurpy} }
Subroutine has_slurpy: called CC=1 SCAR=0.0
Pod documented
45  
46 30 ▶sub set_slurpy {
Subroutine set_slurpy: called CC=3 SCAR=11.0
Pod documented
47 30 my ($self, $v) = @_;
48 30 ▶ $self->{slurpy} = Scalar::Util::blessed($v) && $v->isa('Sub::Meta::Param')
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($v) && $v->isa('Sub::Meta::Param') ? : 20 10 30
Condition100%3/3
builtin::blessed($v) and $v->isa("Sub::Meta::Param")
!ll&&!rl&&r
9120
MC/DC100%2/2
builtin::blessed($v) and $v->isa("Sub::Meta::Param")
builtin::blessed($v) $v->isa("Sub::Meta::Param")
Truth table100%3/3
A and B
A= builtin::blessed($v)B= $v->isa("Sub::Meta::Param")
ABresult
0X0
100
111
49 ? $v
50 : $self->param_class->new($v);
51 30 return $self;
52 }
53  
54 178 ▶sub set_args {
Subroutine set_args: called CC=1 SCAR=0.0
Pod documented
55 178 my ($self, @args) = @_;
56 178 $self->{args} = $self->_normalize_args(@args);
57 175 return $self;
58 }
59  
60 258 ▶sub set_nshift {
Subroutine set_nshift: called CC=9 SCAR=22.0
Pod documented
61 258 my ($self, $v) = @_;
62  
63 258 ▶ unless (defined $v && ($v == 0 || $v == 1) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $v and $v == 0 || $v == 1) 2 256 258
Condition100%6/6
defined $v and $v == 0 || $v == 1
!ll&&!rl&&r
11256
$v == 0 or $v == 1
l!l&&r!l&&!r
181751
MC/DC100%3/3
defined $v and $v == 0 || $v == 1
defined $v $v == 0 $v == 1
Truth table100%4/4
A and B or C
A= defined $vB= $v == 0C= $v == 1
ABCresult
0XX0
1000
11X1
1011
64 2 ▶ _croak sprintf("Can't set this nshift: %s", $v//'');
Condition100%2/2
$v // ""
l!l
11
MC/DC100%1/1
$v // ""
$v
Truth table100%2/2
A
A= $v
Aresult
11
00
65 }
66  
67 256 $self->{nshift} = $v;
68  
69 256 ▶ if ($v == 1 && !defined $self->invocant) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v == 1 and not defined $self->invocant) 40 216 256
Condition100%3/3
$v == 1 and not defined $self->invocant
!ll&&!rl&&r
1813540
MC/DC100%2/2
$v == 1 and not defined $self->invocant
$v == 1 not defined $self->invocant
Truth table100%3/3
A and not(B)
A= $v == 1B= not defined $self->invocant
ABresult
0X0
100
111
70 40 my $default_invocant = $self->param_class->new(invocant => 1);
71 40 $self->set_invocant($default_invocant)
72 }
73  
74 256 ▶ if ($v == 0 && defined $self->invocant) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v == 0 and defined $self->invocant) 1 255 256
Condition100%3/3
$v == 0 and defined $self->invocant
!ll&&!rl&&r
751801
MC/DC100%2/2
$v == 0 and defined $self->invocant
$v == 0 defined $self->invocant
Truth table100%3/3
A and B
A= $v == 0B= defined $self->invocant
ABresult
0X0
100
111
75 delete $self->{invocant}
76 1 }
77  
78 256 return $self;
79 }
80  
81 64 ▶sub set_invocant {
Subroutine set_invocant: called CC=4 SCAR=13.9
Pod documented
82 64 my ($self, $v) = @_;
83  
84 64 ▶ my $invocant = Scalar::Util::blessed($v) && $v->isa('Sub::Meta::Param')
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($v) && $v->isa('Sub::Meta::Param') ? : 57 7 64
Condition100%3/3
builtin::blessed($v) and $v->isa("Sub::Meta::Param")
!ll&&!rl&&r
6157
MC/DC100%2/2
builtin::blessed($v) and $v->isa("Sub::Meta::Param")
builtin::blessed($v) $v->isa("Sub::Meta::Param")
Truth table100%3/3
A and B
A= builtin::blessed($v)B= $v->isa("Sub::Meta::Param")
ABresult
0X0
100
111
85 ? $v
86 : $self->param_class->new($v);
87  
88 64 $invocant->set_invocant(1);
89  
90 64 $self->{invocant} = $invocant;
91  
92 64 ▶ if ($self->nshift == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->nshift == 0) 15 49 64
93 15 $self->set_nshift(1);
94 }
95  
96 64 return $self;
97 }
98  
99 178 ▶sub _normalize_args {
Subroutine _normalize_args: called CC=10 SCAR=23.0
100 178 my ($self, @args) = @_;
101 178 my $args = $args[0];
102 178 ▶ _croak 'args must be a single reference' unless @args == 1 && ref $args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args == 1 and ref $args 3 175 178
Condition100%3/3
@args == 1 and ref $args
!ll&&!rl&&r
12175
MC/DC100%2/2
@args == 1 and ref $args
@args == 1 ref $args
Truth table100%3/3
A and B
A= @args == 1B= ref $args
ABresult
0X0
100
111
103  
104 175 my @normalized_args;
105 175 ▶ if (ref $args eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $args eq 'ARRAY') { } 165 10 175
elsif (ref $args eq 'HASH') { } 5 5 10
106 165 @normalized_args = @{$args};
107 }
108 elsif (ref $args eq 'HASH') {
109 5 for my $name (sort { $a cmp $b } keys %{$args}) {
110 5 my $v = $args->{$name};
111 5 ▶ my $f = ref $v && ref $v eq 'HASH';
Condition66%2/3
ref $v && ref $v eq 'HASH'
!ll&&!rl&&r
302
MC/DC50%1/2
ref $v && ref $v eq 'HASH'
ref $v ref $v eq 'HASH'
Truth table66%2/3
A && B
A= ref $vB= ref $v eq 'HASH'
ABresult
0X0
100
111
112 5 ▶ push @normalized_args => {
Branch: 1 branch
BranchTrueFalseTotal
$f ? : 2 3 5
113 name => $name,
114 named => 1,
115 ($f ? %$v : (type => $v) ),
116 }
117 }
118 }
119 else {
120 5 @normalized_args = ($args);
121 }
122  
123 return [
124 map {
125 175 ▶ Scalar::Util::blessed($_) && $_->isa('Sub::Meta::Param')
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_) && $_->isa('Sub::Meta::Param') ? : 79 77 156
Condition100%3/3
builtin::blessed($_) and $_->isa("Sub::Meta::Param")
!ll&&!rl&&r
621579
MC/DC100%2/2
builtin::blessed($_) and $_->isa("Sub::Meta::Param")
builtin::blessed($_) $_->isa("Sub::Meta::Param")
Truth table100%3/3
A and B
A= builtin::blessed($_)B= $_->isa("Sub::Meta::Param")
ABresult
0X0
100
111
126 ? $_
127 : $self->param_class->new($_)
128 } @normalized_args
129 ]
130 }
131  
132 125 ▶sub _all_positional_required() {
Subroutine _all_positional_required: called CC=1 SCAR=0.0
133 125 my $self = shift;
134 125 return [ @{$self->invocants}, @{$self->positional_required} ];
135 }
136  
137  
138 45 ▶sub positional() { my $self = shift; return [ grep { $_->positional } @{$self->args} ] }
Subroutine positional: called CC=1 SCAR=0.0
Pod documented
139 170 ▶sub positional_required() { my $self = shift; return [ grep { $_->positional && $_->required } @{$self->args} ] }
Subroutine positional_required: called CC=2 SCAR=6.9
Pod documented
Condition100%3/3
$_->positional && $_->required
!ll&&!rl&&r
331243
MC/DC100%2/2
$_->positional && $_->required
$_->positional $_->required
Truth table100%3/3
A && B
A= $_->positionalB= $_->required
ABresult
0X0
100
111
140 80 ▶sub positional_optional() { my $self = shift; return [ grep { $_->positional && $_->optional } @{$self->args} ] }
Subroutine positional_optional: called CC=2 SCAR=6.9
Pod documented
Condition100%3/3
$_->positional && $_->optional
!ll&&!rl&&r
11196
MC/DC100%2/2
$_->positional && $_->optional
$_->positional $_->optional
Truth table100%3/3
A && B
A= $_->positionalB= $_->optional
ABresult
0X0
100
111
141  
142 88 ▶sub named() { my $self = shift; return [ grep { $_->named } @{$self->args} ] }
Subroutine named: called CC=1 SCAR=0.0
Pod documented
143 90 ▶sub named_required() { my $self = shift; return [ grep { $_->named && $_->required } @{$self->args} ] }
Subroutine named_required: called CC=2 SCAR=6.9
Pod documented
Condition100%3/3
$_->named && $_->required
!ll&&!rl&&r
30616
MC/DC100%2/2
$_->named && $_->required
$_->named $_->required
Truth table100%3/3
A && B
A= $_->namedB= $_->required
ABresult
0X0
100
111
144 45 ▶sub named_optional() { my $self = shift; return [ grep { $_->named && $_->optional } @{$self->args} ] }
Subroutine named_optional: called CC=2 SCAR=6.9
Pod documented
Condition100%3/3
$_->named && $_->optional
!ll&&!rl&&r
1583
MC/DC100%2/2
$_->named && $_->optional
$_->named $_->optional
Truth table100%3/3
A && B
A= $_->namedB= $_->optional
ABresult
0X0
100
111
145  
146 45 ▶sub args_min() {
Subroutine args_min: called CC=1 SCAR=0.0
Pod documented
147 45 my $self = shift;
148 45 my $r = 0;
149 45 $r += @{$self->_all_positional_required};
150 45 $r += @{$self->named_required} * 2;
151 45 return $r
152 }
153  
154 45 ▶sub args_max() {
Subroutine args_max: called CC=3 SCAR=11.0
Pod documented
155 45 my $self = shift;
156 45 ▶ return 0 + 'Inf' if $self->slurpy || @{$self->named}; ## no critic (ProhibitMismatchedOperators)
Branch: 1 branch
BranchTrueFalseTotal
if $self->slurpy or @{$self->named;} 10 35 45
Condition100%3/3
$self->slurpy or @{$self->named;}
l!l&&r!l&&!r
2835
MC/DC100%2/2
$self->slurpy or @{$self->named;}
$self->slurpy @{$self->named;}
Truth table100%3/3
A or B
A= $self->slurpyB= @{$self->named;}
ABresult
1X1
011
000
157 35 my $r = 0;
158 35 $r += @{$self->_all_positional_required};
159 35 $r += @{$self->positional_optional};
160 35 return $r
161 }
162  
163 81 ▶sub is_same_interface {
Subroutine is_same_interface: called CC=10 SCAR=23.0
Pod documented
164 81 my ($self, $other) = @_;
165  
166 81 ▶ return unless Scalar::Util::blessed($other) && $other->isa('Sub::Meta::Parameters');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($other) and $other->isa("Sub::Meta::Parameters") 2 79 81
Condition100%3/3
builtin::blessed($other) and $other->isa("Sub::Meta::Parameters")
!ll&&!rl&&r
1179
MC/DC100%2/2
builtin::blessed($other) and $other->isa("Sub::Meta::Parameters")
builtin::blessed($other) $other->isa("Sub::Meta::Parameters")
Truth table100%3/3
A and B
A= builtin::blessed($other)B= $other->isa("Sub::Meta::Parameters")
ABresult
0X0
100
111
167  
168 79 ▶ if ($self->has_slurpy) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_slurpy) { } 11 68 79
169 11 ▶ return unless $self->slurpy->is_same_interface($other->slurpy)
Branch: 1 branch
BranchTrueFalseTotal
unless $self->slurpy->is_same_interface($other->slurpy) 3 8 11
170 }
171 else {
172 68 ▶ return if $other->has_slurpy;
Branch: 1 branch
BranchTrueFalseTotal
if $other->has_slurpy 3 65 68
173 }
174  
175 73 ▶ return unless $self->nshift == $other->nshift;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->nshift == $other->nshift 6 67 73
176  
177 67 ▶ return unless @{$self->all_args} == @{$other->all_args};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->all_args;} == @{$other->all_args;} 13 54 67
178  
179 54 ▶ for (my $i = 0; $i < @{$self->all_args}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$self->all_args;}) 38 41 79
180 38 ▶ return unless $self->all_args->[$i]->is_same_interface($other->all_args->[$i]);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->all_args->[$i]->is_same_interface($other->all_args->[$i]) 13 25 38
181 }
182  
183 41 return !!1;
184 }
185  
186 87 ▶sub is_relaxed_same_interface {
Subroutine is_relaxed_same_interface: called CC=9 SCAR=22.0
Pod documented
187 87 my ($self, $other) = @_;
188  
189 87 ▶ return unless Scalar::Util::blessed($other) && $other->isa('Sub::Meta::Parameters');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($other) and $other->isa("Sub::Meta::Parameters") 2 85 87
Condition100%3/3
builtin::blessed($other) and $other->isa("Sub::Meta::Parameters")
!ll&&!rl&&r
1185
MC/DC100%2/2
builtin::blessed($other) and $other->isa("Sub::Meta::Parameters")
builtin::blessed($other) $other->isa("Sub::Meta::Parameters")
Truth table100%3/3
A and B
A= builtin::blessed($other)B= $other->isa("Sub::Meta::Parameters")
ABresult
0X0
100
111
190  
191 85 ▶ if ($self->has_slurpy) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_slurpy) 11 74 85
192 11 ▶ return unless $self->slurpy->is_same_interface($other->slurpy)
Branch: 1 branch
BranchTrueFalseTotal
unless $self->slurpy->is_same_interface($other->slurpy) 3 8 11
193 }
194  
195 82 ▶ return unless $self->nshift == $other->nshift;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->nshift == $other->nshift 6 76 82
196  
197 76 ▶ return unless @{$self->all_args} <= @{$other->all_args};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->all_args;} <= @{$other->all_args;} 6 70 76
198  
199 70 ▶ for (my $i = 0; $i < @{$self->all_args}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$self->all_args;}) 49 59 108
200 49 ▶ return unless $self->all_args->[$i]->is_relaxed_same_interface($other->all_args->[$i]);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->all_args->[$i]->is_relaxed_same_interface($other->all_args->[$i]) 11 38 49
201 }
202  
203 59 return !!1;
204 }
205  
206 20 ▶sub is_same_interface_inlined {
Subroutine is_same_interface_inlined: called CC=3 SCAR=11.0
Pod documented
207 20 my ($self, $v) = @_;
208  
209 20 my @src;
210  
211 20 push @src => sprintf("Scalar::Util::blessed(%s) && %s->isa('Sub::Meta::Parameters')", $v, $v);
212  
213 20 ▶ push @src => $self->has_slurpy ? $self->slurpy->is_same_interface_inlined(sprintf('%s->slurpy', $v))
Branch: 1 branch
BranchTrueFalseTotal
$self->has_slurpy ? : 2 18 20
214 : sprintf('!%s->has_slurpy', $v);
215  
216 20 push @src => sprintf('%d == %s->nshift', $self->nshift, $v);
217  
218 20 push @src => sprintf('%d == @{%s->all_args}', scalar @{$self->all_args}, $v);
219  
220 20 ▶ for (my $i = 0; $i < @{$self->all_args}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$self->all_args;}) 15 20 35
221 15 push @src => $self->all_args->[$i]->is_same_interface_inlined(sprintf('%s->all_args->[%d]', $v, $i))
222 }
223  
224 20 return join "\n && ", @src;
225 }
226  
227 24 ▶sub is_relaxed_same_interface_inlined {
Subroutine is_relaxed_same_interface_inlined: called CC=3 SCAR=11.0
Pod documented
228 24 my ($self, $v) = @_;
229  
230 24 my @src;
231  
232 24 push @src => sprintf("Scalar::Util::blessed(%s) && %s->isa('Sub::Meta::Parameters')", $v, $v);
233  
234 24 ▶ push @src => $self->slurpy->is_relaxed_same_interface_inlined(sprintf('%s->slurpy', $v)) if $self->has_slurpy;
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_slurpy 2 22 24
235  
236 24 push @src => sprintf('%d == %s->nshift', $self->nshift, $v);
237  
238 24 push @src => sprintf('%d <= @{%s->all_args}', scalar @{$self->all_args}, $v);
239  
240 24 ▶ for (my $i = 0; $i < @{$self->all_args}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$self->all_args;}) 21 24 45
241 21 push @src => $self->all_args->[$i]->is_relaxed_same_interface_inlined(sprintf('%s->all_args->[%d]', $v, $i))
242 }
243  
244 24 return join "\n && ", @src;
245 }
246  
247  
248 25 ▶sub error_message {
Subroutine error_message: called CC=12 SCAR=24.8
Pod documented
249 25 my ($self, $other) = @_;
250  
251 25 ▶ return sprintf('other parameters must be Sub::Meta::Parameters. got: %s', $other // 'Undef')
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($other) and $other->isa("Sub::Meta::Parameters") 2 23 25
Condition100%5/5
builtin::blessed($other) and $other->isa("Sub::Meta::Parameters")
!ll&&!rl&&r
1123
$other // "Undef"
l!l
11
MC/DC100%2/2
builtin::blessed($other) and $other->isa("Sub::Meta::Parameters")
builtin::blessed($other) $other->isa("Sub::Meta::Parameters")
MC/DC100%1/1
$other // "Undef"
$other
Truth table100%3/3
A and B
A= builtin::blessed($other)B= $other->isa("Sub::Meta::Parameters")
ABresult
0X0
100
111
Truth table100%2/2
A
A= $other
Aresult
11
00
252 unless Scalar::Util::blessed($other) && $other->isa('Sub::Meta::Parameters');
253  
254 23 ▶ if ($self->has_slurpy) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_slurpy) { } 3 20 23
255 3 ▶ return sprintf('invalid slurpy. got: %s, expected: %s', $other->has_slurpy ? $other->slurpy->display : '', $self->slurpy->display)
Branch: 2 branches
BranchTrueFalseTotal
unless $self->slurpy->is_same_interface($other->slurpy) 2 1 3
$other->has_slurpy ? : 1 1 2
256 unless $self->slurpy->is_same_interface($other->slurpy)
257 }
258 else {
259 20 ▶ return 'should not have slurpy' if $other->has_slurpy;
Branch: 1 branch
BranchTrueFalseTotal
if $other->has_slurpy 1 19 20
260 }
261  
262 20 ▶ return sprintf('nshift is not equal. got: %d, expected: %d', $other->nshift, $self->nshift)
Branch: 1 branch
BranchTrueFalseTotal
unless $self->nshift == $other->nshift 3 17 20
263 unless $self->nshift == $other->nshift;
264  
265 4 return sprintf('invalid args length. got: %d, expected: %d', scalar @{$other->all_args}, scalar @{$self->all_args})
266 17 ▶ unless @{$self->all_args} == @{$other->all_args};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->all_args;} == @{$other->all_args;} 4 13 17
267  
268 13 ▶ for (my $i = 0; $i < @{$self->all_args}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$self->all_args;}) 10 8 18
269 10 my $s = $self->all_args->[$i];
270 10 my $o = $other->all_args->[$i];
271 10 ▶ return sprintf('args[%d] is invalid. got: %s, expected: %s', $i, $o->display, $s->display)
Branch: 1 branch
BranchTrueFalseTotal
unless $s->is_same_interface($o) 5 5 10
272 unless $s->is_same_interface($o);
273 }
274  
275 8 return '';
276 }
277  
278 25 ▶sub relaxed_error_message {
Subroutine relaxed_error_message: called CC=11 SCAR=24.0
Pod documented
279 25 my ($self, $other) = @_;
280  
281 25 ▶ return sprintf('other parameters must be Sub::Meta::Parameters. got: %s', $other // 'Undef')
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($other) and $other->isa("Sub::Meta::Parameters") 2 23 25
Condition100%5/5
builtin::blessed($other) and $other->isa("Sub::Meta::Parameters")
!ll&&!rl&&r
1123
$other // "Undef"
l!l
11
MC/DC100%2/2
builtin::blessed($other) and $other->isa("Sub::Meta::Parameters")
builtin::blessed($other) $other->isa("Sub::Meta::Parameters")
MC/DC100%1/1
$other // "Undef"
$other
Truth table100%3/3
A and B
A= builtin::blessed($other)B= $other->isa("Sub::Meta::Parameters")
ABresult
0X0
100
111
Truth table100%2/2
A
A= $other
Aresult
11
00
282 unless Scalar::Util::blessed($other) && $other->isa('Sub::Meta::Parameters');
283  
284 23 ▶ if ($self->has_slurpy) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_slurpy) 3 20 23
285 3 ▶ return sprintf('invalid slurpy. got: %s, expected: %s', $other->has_slurpy ? $other->slurpy->display : '', $self->slurpy->display)
Branch: 2 branches
BranchTrueFalseTotal
unless $self->slurpy->is_same_interface($other->slurpy) 2 1 3
$other->has_slurpy ? : 1 1 2
286 unless $self->slurpy->is_same_interface($other->slurpy)
287 }
288  
289 21 ▶ return sprintf('nshift is not equal. got: %d, expected: %d', $other->nshift, $self->nshift)
Branch: 1 branch
BranchTrueFalseTotal
unless $self->nshift == $other->nshift 3 18 21
290 unless $self->nshift == $other->nshift;
291  
292 3 return sprintf('invalid args length. got: %d, expected: %d', scalar @{$other->all_args}, scalar @{$self->all_args})
293 18 ▶ unless @{$self->all_args} <= @{$other->all_args};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->all_args;} <= @{$other->all_args;} 3 15 18
294  
295 15 ▶ for (my $i = 0; $i < @{$self->all_args}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$self->all_args;}) 10 10 20
296 10 my $s = $self->all_args->[$i];
297 10 my $o = $other->all_args->[$i];
298 10 ▶ return sprintf('args[%d] is invalid. got: %s, expected: %s', $i, $o->display, $s->display)
Branch: 1 branch
BranchTrueFalseTotal
unless $s->is_relaxed_same_interface($o) 5 5 10
299 unless $s->is_relaxed_same_interface($o);
300 }
301  
302 10 return '';
303 }
304 36 ▶sub display {
Subroutine display: called CC=8 SCAR=20.8
Pod documented
305 36 my $self = shift;
306  
307 36 my $s = '';
308 36 ▶ if ($self->has_invocant) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_invocant) 4 32 36
309 4 my $d = $self->invocant->display;
310 4 ▶ $s .= "$d: " if $d;
Branch: 1 branch
BranchTrueFalseTotal
if $d 1 3 4
311 }
312  
313 36 ▶ if ($self->has_args) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_args) 24 12 36
314 24 $s .= join ', ', map { $_->display } @{$self->args};
315 }
316  
317 36 ▶ if ($self->has_slurpy) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_slurpy) 3 33 36
318 3 ▶ $s .= ', ' if $s;
Branch: 1 branch
BranchTrueFalseTotal
if $s 1 2 3
319 3 $s .= $self->slurpy->display;
320 }
321  
322 36 ▶ if(!$self->has_args && !$self->has_slurpy) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->has_args or $self->has_slurpy) 11 25 36
Condition100%3/3
$self->has_args or $self->has_slurpy
l!l&&r!l&&!r
24111
MC/DC100%2/2
$self->has_args or $self->has_slurpy
$self->has_args $self->has_slurpy
Truth table100%3/3
A or B
A= $self->has_argsB= $self->has_slurpy
ABresult
1X1
011
000
323 11 $s .= '*';
324 }
325  
326 36 return $s;
327 }
328  
329 34 1;
330 __END__
« Sub/Meta/Test.pm ↑ Summary Sub/Meta/Param.pm »