| 1 | package Type::Params::Alternatives; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use 5.008001; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | ▶ | if ( $] < 5.010 ) { require Devel::TypeTiny::Perl58Compat } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | } | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | $Type::Params::Alternatives::AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | $Type::Params::Alternatives::VERSION = '2.010001'; | |||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 6 | $Type::Params::Alternatives::VERSION =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 6 | ▶ | use B (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | ▶ | use Eval::TypeTiny::CodeAccumulator; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 6 | ▶ | use Types::Standard qw( -is -types -assert ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 6 | ▶ | use Types::TypeTiny qw( -is -types to_TypeTiny ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 6 | my $Attrs = Enum[ qw/ | |||||||||||||||||||||||||||||||||||||||||
| 24 | caller_level package subname description _is_signature_for ID | ||||||||||||||||||||||||||||||||||||||||||
| 25 | method head tail parameters slurpy | ||||||||||||||||||||||||||||||||||||||||||
| 26 | message on_die next fallback strictness is_named allow_dash method_invocant | ||||||||||||||||||||||||||||||||||||||||||
| 27 | bless class constructor named_to_list list_to_named oo_trace | ||||||||||||||||||||||||||||||||||||||||||
| 28 | class_prefix class_attributes | ||||||||||||||||||||||||||||||||||||||||||
| 29 | returns_scalar returns_list | ||||||||||||||||||||||||||||||||||||||||||
| 30 | want_details want_object want_source can_shortcut coderef | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | sig_class base_options alternatives meta_alternatives | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | quux mite_signature is_wrapper | ||||||||||||||||||||||||||||||||||||||||||
| 35 | / ]; # quux for reasons | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 6 | require Type::Params::Signature; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | our @ISA = 'Type::Params::Signature'; | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 22 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=11 SCAR=25.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 22 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my %self = @_ == 1 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 22 | my $self = bless \%self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 22 | ▶ | $self->{next} ||= delete $self->{goto_next} if exists $self->{goto_next}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"next"} ||= delete $self->{"goto_next"}
MC/DC0%0/2
$self->{"next"} ||= delete $self->{"goto_next"}
$self->{"next"}
delete $self->{"goto_next"}
Truth table0%0/3
A ||= B
A= $self->{"next"}B= delete $self->{"goto_next"}
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | exists( $self->{$_} ) || ( $self->{$_} = $self->{base_options}{$_} ) | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 22 | ▶ | for keys %{ $self->{base_options} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 22 | ▶ | $self->{sig_class} ||= 'Type::Params::Signature'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"sig_class"} ||= "Type::Params::Signature"
MC/DC0%0/1
$self->{"sig_class"} ||= "Type::Params::Signature"
$self->{"sig_class"}
Truth table50%1/2
A
A= $self->{"sig_class"}
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 22 | ▶ | $self->{message} ||= 'Parameter validation failed'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"message"} ||= "Parameter validation failed"
MC/DC100%1/1
$self->{"message"} ||= "Parameter validation failed"
$self->{"message"}
Truth table100%2/2
A
A= $self->{"message"}
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 22 | delete $self->{base_options}{$_} for qw/ returns returns_list returns_scalar /; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 22 | $self->_rationalize_returns; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 22 | ▶ | $Attrs->all( sort keys %$self ) or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | require Type::Utils; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | my @bad = ( ~ $Attrs )->grep( sort keys %$self ); | |||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | ▶ | Carp::carp( sprintf( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | "Warning: unrecognized signature %s: %s, continuing anyway", | ||||||||||||||||||||||||||||||||||||||||||
| 57 | @bad == 1 ? 'option' : 'options', | ||||||||||||||||||||||||||||||||||||||||||
| 58 | Type::Utils::english_list( @bad ), | ||||||||||||||||||||||||||||||||||||||||||
| 59 | ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 60 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 22 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 54 | ▶ | sub base_options { $_[0]{base_options} ||= {} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base_options: called CC=2 SCAR=7.6
Pod
documented
Condition50%1/2
$_[0]{"base_options"} ||= {}
MC/DC0%0/1
$_[0]{"base_options"} ||= {}
$_[0]{"base_options"}
Truth table50%1/2
A
A= $_[0]{"base_options"}
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 22 | ▶ | sub alternatives { $_[0]{alternatives} ||= [] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alternatives: called CC=2 SCAR=7.6
Pod
documented
Condition50%1/2
$_[0]{"alternatives"} ||= []
MC/DC0%0/1
$_[0]{"alternatives"} ||= []
$_[0]{"alternatives"}
Truth table50%1/2
A
A= $_[0]{"alternatives"}
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 54 | ▶ | sub sig_class { $_[0]{sig_class} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sig_class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 27 | ▶ | sub meta_alternatives { $_[0]{meta_alternatives} ||= $_[0]->_build_meta_alternatives } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
meta_alternatives: called CC=2 SCAR=6.9
Pod
documented
Condition100%3/3
$_[0]{"meta_alternatives"} ||= $_[0]->_build_meta_alternatives
MC/DC100%2/2
$_[0]{"meta_alternatives"} ||= $_[0]->_build_meta_alternatives
$_[0]{"meta_alternatives"}
$_[0]->_build_meta_alternatives
Truth table100%3/3
A ||= B
A= $_[0]{"meta_alternatives"}B= $_[0]->_build_meta_alternatives
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 42 | ▶ | sub parameters { [] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parameters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 48 | ▶ | sub next { $_[0]{base_options}{next} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub goto_next { $_[0]{base_options}{next} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
goto_next: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 20 | ▶ | sub package { $_[0]{base_options}{package} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
package: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 20 | ▶ | sub subname { $_[0]{base_options}{subname} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subname: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 22 | ▶ | sub _build_meta_alternatives { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_meta_alternatives: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 22 | my $index = 0; | |||||||||||||||||||||||||||||||||||||||||
| 78 | return [ | ||||||||||||||||||||||||||||||||||||||||||
| 79 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 62 | $self->_build_meta_alternative( $_, $index++ ) | |||||||||||||||||||||||||||||||||||||||||
| 81 | 22 | } @{ $self->alternatives } | |||||||||||||||||||||||||||||||||||||||||
| 82 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 62 | ▶ | sub _build_meta_alternative { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_meta_alternative: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 62 | my ( $self, $alt, $index ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 62 | my $meta; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 62 | ▶ | if ( is_CodeRef $alt ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 6 | $meta = { closure => $alt }; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | ▶ | elsif ( is_HashRef $alt and exists $alt->{closure} ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
is_HashRef($alt) and exists $alt->{"closure"}
MC/DC100%2/2
is_HashRef($alt) and exists $alt->{"closure"}
is_HashRef($alt)
exists $alt->{"closure"}
Truth table100%3/3
A and B
A= is_HashRef($alt)B= exists $alt->{"closure"}
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | $meta = { %$alt }; | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | elsif ( is_HashRef $alt ) { | ||||||||||||||||||||||||||||||||||||||||||
| 96 | my %opts = ( | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 39 | %{ $self->base_options }, | |||||||||||||||||||||||||||||||||||||||||
| 98 | next => !!0, # don't propagate these next few | ||||||||||||||||||||||||||||||||||||||||||
| 99 | returns => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | returns_scalar => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | returns_list => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | %$alt, | ||||||||||||||||||||||||||||||||||||||||||
| 103 | want_source => !!0, | ||||||||||||||||||||||||||||||||||||||||||
| 104 | want_object => !!0, | ||||||||||||||||||||||||||||||||||||||||||
| 105 | want_details => !!1, | ||||||||||||||||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 39 | $meta = $self->sig_class->new_from_v2api( \%opts )->return_wanted; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 39 | ▶ | $meta->{ID} = $alt->{ID} if exists $alt->{ID}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | elsif ( is_ArrayRef $alt ) { | ||||||||||||||||||||||||||||||||||||||||||
| 111 | my %opts = ( | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 15 | %{ $self->base_options }, | |||||||||||||||||||||||||||||||||||||||||
| 113 | next => !!0, # don't propagate these next few | ||||||||||||||||||||||||||||||||||||||||||
| 114 | returns => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | returns_scalar => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 116 | returns_list => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 117 | positional => $alt, | ||||||||||||||||||||||||||||||||||||||||||
| 118 | want_source => !!0, | ||||||||||||||||||||||||||||||||||||||||||
| 119 | want_object => !!0, | ||||||||||||||||||||||||||||||||||||||||||
| 120 | want_details => !!1, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 15 | $meta = $self->sig_class->new_from_v2api( \%opts )->return_wanted; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | $self->_croak( 'Alternative signatures must be CODE, HASH, or ARRAY refs' ); | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 61 | $meta->{_index} = $index; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 61 | return $meta; | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 22 | ▶ | sub _coderef_start_extra { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_coderef_start_extra: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 22 | my ( $self, $coderef ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 22 | $coderef->add_line( 'my $r;' ); | |||||||||||||||||||||||||||||||||||||||||
| 136 | 22 | $coderef->add_line( 'undef ${^_TYPE_PARAMS_MULTISIG};' ); | |||||||||||||||||||||||||||||||||||||||||
| 137 | 22 | $coderef->add_gap; | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 22 | for my $meta ( @{ $self->meta_alternatives } ) { | |||||||||||||||||||||||||||||||||||||||||
| 140 | 61 | $self->_coderef_meta_alternative( $coderef, $meta ); | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 21 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 61 | ▶ | sub _coderef_meta_alternative { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_coderef_meta_alternative: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 61 | my ( $self, $coderef, $meta ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 61 | my @cond = '! $r'; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 61 | ▶ | push @cond, sprintf( '@_ >= %s', $meta->{min_args} ) if defined $meta->{min_args}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 61 | ▶ | push @cond, sprintf( '@_ <= %s', $meta->{max_args} ) if defined $meta->{max_args}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 61 | ▶ | if ( defined $meta->{max_args} and defined $meta->{min_args} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $meta->{"max_args"} and defined $meta->{"min_args"}
MC/DC50%1/2
defined $meta->{"max_args"} and defined $meta->{"min_args"}
defined $meta->{"max_args"}
defined $meta->{"min_args"}
Truth table66%2/3
A and B
A= defined $meta->{"max_args"}B= defined $meta->{"min_args"}
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | splice @cond, -2, 2, sprintf( '@_ == %s', $meta->{min_args} ) | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 32 | ▶ | if $meta->{max_args} == $meta->{min_args}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | # It is sometimes possible to inline $meta->{source} here | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 61 | ▶ | if ( $meta->{source} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$meta->{"source"} and not $meta->{"source"} =~ /return/ and not keys %{$$meta{"environment"};}
$meta->{"source"} and not $meta->{"source"} =~ /return/
MC/DC100%3/3
$meta->{"source"} and not $meta->{"source"} =~ /return/ and not keys %{$$meta{"environment"};}
$meta->{"source"}
not $meta->{"source"} =~ /return/
not keys %{$$meta{"environment"};}
Truth table100%4/4
A and not(B) and not(C)
A= $meta->{"source"}B= not $meta->{"source"} =~ /return/C= not keys %{$$meta{"environment"};}
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | and $meta->{source} !~ /return/ | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 47 | and ! keys %{ $meta->{environment} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 25 | my $alt_code = $meta->{source}; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 25 | $alt_code =~ s/^sub [{]/do {/; | |||||||||||||||||||||||||||||||||||||||||
| 164 | $coderef->add_line( sprintf( | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 'eval { local @_ = @_; $r = [ %s ]; ${^_TYPE_PARAMS_MULTISIG} = %s }%sif ( %s );', | ||||||||||||||||||||||||||||||||||||||||||
| 166 | $alt_code, | ||||||||||||||||||||||||||||||||||||||||||
| 167 | defined( $meta->{ID} ) | ||||||||||||||||||||||||||||||||||||||||||
| 168 | ? B::perlstring( $meta->{ID} ) | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 25 | ▶ | : ( 0 + $meta->{_index} ), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | "\n\t", | ||||||||||||||||||||||||||||||||||||||||||
| 171 | join( ' and ', @cond ), | ||||||||||||||||||||||||||||||||||||||||||
| 172 | ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 25 | $coderef->add_gap; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 36 | my $callback_var = $coderef->add_variable( '$signature', \$meta->{closure} ); | |||||||||||||||||||||||||||||||||||||||||
| 178 | $coderef->add_line( sprintf( | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 'eval { $r = [ %s->(@_) ]; ${^_TYPE_PARAMS_MULTISIG} = %s }%sif ( %s );', | ||||||||||||||||||||||||||||||||||||||||||
| 180 | $callback_var, | ||||||||||||||||||||||||||||||||||||||||||
| 181 | defined( $meta->{ID} ) | ||||||||||||||||||||||||||||||||||||||||||
| 182 | ? B::perlstring( $meta->{ID} ) | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 36 | ▶ | : ( 0 + $meta->{_index} ), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | "\n\t", | ||||||||||||||||||||||||||||||||||||||||||
| 185 | join( ' and ', @cond ), | ||||||||||||||||||||||||||||||||||||||||||
| 186 | ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 36 | $coderef->add_gap; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 61 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 21 | ▶ | sub _coderef_end_extra { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_coderef_end_extra: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 21 | my ( $self, $coderef ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | $coderef->add_line( sprintf( | ||||||||||||||||||||||||||||||||||||||||||
| 197 | '%s unless $r;', | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 21 | $self->_make_general_fail( message => B::perlstring( $self->{message} ) ), | |||||||||||||||||||||||||||||||||||||||||
| 199 | ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 21 | $coderef->add_gap; | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 21 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 21 | ▶ | sub _coderef_check_count { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_coderef_check_count: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 21 | shift; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 21 | ▶ | sub _make_return_list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_return_list: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 21 | '@$r'; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 5 | ▶ | sub make_class_pp_code { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_class_pp_code: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | return join( | ||||||||||||||||||||||||||||||||||||||||||
| 217 | qq{\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 13 | grep { length $_ } | |||||||||||||||||||||||||||||||||||||||||
| 219 | 13 | ▶ | map { $_->{class_definition} || '' } | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_->{'class_definition'} || ''
MC/DC100%1/1
$_->{'class_definition'} || ''
$_->{'class_definition'}
Truth table100%2/2
A
A= $_->{'class_definition'}
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 5 | @{ $self->meta_alternatives } | |||||||||||||||||||||||||||||||||||||||||
| 221 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | __END__ | ||||||||||||||||||||||||||||||||||||||||||