| 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 | package Kavorka::Parameter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 38 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 38 | our $VERSION = '0.039'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 38 | our @CARP_NOT = qw( Kavorka::Signature Kavorka::Sub Kavorka ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 38 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 38 | ▶ | use Text::Balanced qw( extract_codeblock extract_bracketed ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 38 | ▶ | use Parse::Keyword {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 38 | ▶ | use Parse::KeywordX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 38 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 38 | ▶ | use namespace::sweep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 38 | has package => (is => 'ro'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 38 | has type => (is => 'ro'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 38 | has name => (is => 'ro'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 76 | ▶ | has constraints => (is => 'ro', default => sub { +[] }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 76 | ▶ | has named => (is => 'ro', default => sub { 0 }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 76 | ▶ | has named_names => (is => 'ro', default => sub { +[] }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 38 | has position => (is => 'rwp'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 38 | has default => (is => 'ro'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 38 | has default_when => (is => 'ro'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 38 | has ID => (is => 'rwp'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | has traits => (is => 'ro', default => sub { +{} }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 61 | ▶ | has sigil => (is => 'lazy', builder => sub { substr(shift->name, 0, 1) }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
_build_sigil: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 38 | has kind => (is => 'lazy', builder => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub readonly { !!shift->traits->{ro} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readonly: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub ro { !!shift->traits->{ro} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ro: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub rw { !shift->traits->{ro} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rw: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | ▶ | sub alias { !!shift->traits->{alias} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alias: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub copy { !shift->traits->{alias} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1993 | ▶ | sub slurpy { !!shift->traits->{slurpy} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
slurpy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 264 | ▶ | sub optional { !!shift->traits->{optional} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
optional: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 2365 | ▶ | sub invocant { !!shift->traits->{invocant} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invocant: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 301 | ▶ | sub coerce { !!shift->traits->{coerce} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coerce: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub locked { !!shift->traits->{locked} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locked: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 38 | our @PARAMS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | sub BUILD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 269 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=12 SCAR=25.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 269 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 269 | my $id = scalar(@PARAMS); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 269 | $self->_set_ID($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 269 | $PARAMS[$id] = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 269 | my $traits = $self->traits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | exists($traits->{rw}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | and !exists($traits->{ro}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 269 | ▶ | and ($traits->{ro} = !$traits->{rw}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $traits->{"rw"} and not exists $traits->{"ro"}
MC/DC50%1/2
exists $traits->{"rw"} and not exists $traits->{"ro"}
exists $traits->{"rw"}
not exists $traits->{"ro"}
Truth table66%2/3
A and not(B)
A= exists $traits->{"rw"}B= not exists $traits->{"ro"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | exists($traits->{ro}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | and !exists($traits->{rw}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 269 | ▶ | and ($traits->{rw} = !$traits->{ro}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $traits->{"ro"} and not exists $traits->{"rw"}
MC/DC100%2/2
exists $traits->{"ro"} and not exists $traits->{"rw"}
exists $traits->{"ro"}
not exists $traits->{"rw"}
Truth table100%3/3
A and not(B)
A= exists $traits->{"ro"}B= not exists $traits->{"rw"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | exists($traits->{copy}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | and !exists($traits->{alias}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 269 | ▶ | and ($traits->{alias} = !$traits->{copy}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $traits->{"copy"} and not exists $traits->{"alias"}
MC/DC0%0/2
exists $traits->{"copy"} and not exists $traits->{"alias"}
exists $traits->{"copy"}
not exists $traits->{"alias"}
Truth table33%1/3
A and not(B)
A= exists $traits->{"copy"}B= not exists $traits->{"alias"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | exists($traits->{alias}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | and !exists($traits->{copy}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 269 | ▶ | and ($traits->{copy} = !$traits->{alias}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $traits->{"alias"} and not exists $traits->{"copy"}
MC/DC0%0/2
exists $traits->{"alias"} and not exists $traits->{"copy"}
exists $traits->{"alias"}
not exists $traits->{"copy"}
Truth table33%1/3
A and not(B)
A= exists $traits->{"alias"}B= not exists $traits->{"copy"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 269 | ▶ | $traits->{$_} || delete($traits->{$_}) for keys %$traits; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # traits handled natively | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 269 | state $native_traits = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | copy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | invocant => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | rw => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | slurpy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | my @custom_traits = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | map "Kavorka::TraitFor::Parameter::$_", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 269 | grep !exists($native_traits->{$_}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | keys %$traits; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 269 | ▶ | 'Moo::Role'->apply_roles_to_object($self, @custom_traits) if @custom_traits; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | sub _build_kind | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 267 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_kind: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 267 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 267 | local $_ = $self->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 267 | ▶ | /::/ ? 'global' : /\A[\$\@\%](?:\W|_\z)/ ? 'magic' : 'my'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 38 | my $variable_re = qr{ [\$\%\@] (?: \{\^[A-Z]+\} | \w* ) }x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | sub parse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 193 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=34 SCAR=40.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 193 | state $deparse = do { require B::Deparse; 'B::Deparse'->new }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 193 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 193 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 193 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 193 | my %traits = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | invocant => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | _optional => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 193 | ▶ | if (lex_peek(6) eq 'slurpy') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 13 | lex_read(6); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 13 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 13 | $traits{slurpy} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 193 | my $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 193 | my $peek = lex_peek(1000); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 193 | ▶ | if ($peek =~ /\A[^\W0-9]/ and not $peek =~ /\A(my|our)\b/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$peek =~ /\A[^\W0-9]/u and not $peek =~ /\A(my|our)\b/u
MC/DC100%2/2
$peek =~ /\A[^\W0-9]/u and not $peek =~ /\A(my|our)\b/u
$peek =~ /\A[^\W0-9]/u
not $peek =~ /\A(my|our)\b/u
Truth table100%3/3
A and not(B)
A= $peek =~ /\A[^\W0-9]/uB= not $peek =~ /\A(my|our)\b/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 60 | my $reg = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 60 | require Type::Registry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 60 | require Type::Utils; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 60 | my $tmp = 'Type::Registry::DWIM'->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 60 | $tmp->{'~~chained'} = $args{package}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 60 | $tmp->{'~~assume'} = 'make_class_type'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 60 | $tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 60 | require Type::Parser; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 60 | ($type, my($remaining)) = Type::Parser::extract_type($peek, $reg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 60 | my $len = length($peek) - length($remaining); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 60 | lex_read($len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 60 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | elsif ($peek =~ /\A\(/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 9 | lex_read(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 9 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 9 | ▶ | my $expr = parse_listexpr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | or croak('Could not parse type constraint expression as listexpr'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 9 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 9 | ▶ | lex_peek eq ')' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | or croak("Expected ')' after type constraint expression"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 9 | lex_read(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 9 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 9 | require Types::TypeTiny; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 9 | $type = Types::TypeTiny::to_TypeTiny( scalar $expr->() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 9 | ▶ | $type->isa('Type::Tiny') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | or croak("Type constraint expression did not return a blessed type constraint object"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 193 | my ($named, $parens, $varname, $varkind, @paramname) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # :foo( ... ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 193 | ▶ | if (lex_peek(2) =~ /\A\:\w/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 5 | $named = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 5 | $traits{_optional} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | ▶ | while (lex_peek(2) =~ /\A\:\w/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 13 | lex_read(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 13 | push @paramname, parse_name('named parameter name', 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 13 | ▶ | if (lex_peek eq '(') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 7 | lex_read(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 7 | $parens++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 13 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # Allow colon before "my"/"our" - just shift it to the correct position | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 193 | my $saw_colon; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 193 | ▶ | if (lex_peek eq ':') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 16 | $saw_colon++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 16 | lex_read(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 16 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 193 | ▶ | if (lex_peek eq '\\') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $traits{ref_alias} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | lex_read(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 193 | ▶ | if (lex_peek(3) =~ /\A(my|our)/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | $varkind = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | lex_read(length $varkind); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 193 | ▶ | if (lex_peek eq '\\') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | croak("cannot be a double-ref-alias") if $traits{ref_alias}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | lex_read(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 193 | ▶ | lex_stuff(':') if $saw_colon; # re-insert colon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 193 | $peek = lex_peek; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # :$foo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 193 | ▶ | if ($peek eq ':') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 16 | lex_read(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 16 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 16 | $varname = parse_variable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 16 | $named = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 16 | $traits{_optional} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 16 | push @paramname, substr($varname, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 16 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | # $foo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | ▶ | elsif ($peek eq '$' or $peek eq '@' or $peek eq '%') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$peek eq "\$" or $peek eq "\@" or $peek eq "%"
$peek eq "\$" or $peek eq "\@"
MC/DC0%0/3
$peek eq "\$" or $peek eq "\@" or $peek eq "%"
$peek eq "\$"
$peek eq "\@"
$peek eq "%"
Truth table75%3/4
A or B or C
A= $peek eq "\$"B= $peek eq "\@"C= $peek eq "%"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 177 | $varname = parse_variable(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 177 | ▶ | $traits{_optional} = 0 unless @paramname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 177 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 193 | undef($peek); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 193 | for (1 .. $parens) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 7 | ▶ | lex_peek(1) eq ')' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | ? lex_read(1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | : croak("Expected close parentheses after named parameter name"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 7 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 193 | ▶ | if (lex_peek eq '!') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | $traits{optional} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | lex_read(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | elsif (lex_peek eq '?') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 4 | $traits{optional} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 4 | lex_read(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 4 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 193 | my (@constraints, $default, $default_when); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 193 | ▶ | while (lex_peek(5) eq 'where') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 4 | lex_read(5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 4 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 4 | push @constraints, parse_block_or_match; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 4 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 193 | ▶ | while (lex_peek(5) =~ m{ \A (is|does|but) \s }xsm) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 14 | lex_read(length($1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 14 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 14 | my ($name, undef, $args) = parse_trait; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 14 | $traits{$name} = $args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 14 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 193 | ▶ | if (lex_peek(5) =~ m{ \A ( (?: [/]{2} | [|]{2} )?= ) }x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 13 | $default_when = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 13 | lex_read(length($1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 13 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | $default = lex_peek(5) =~ m{ \A (?: when\b | [,)] ) }x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 3 | ▶ | ? sub { (); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 13 | ▶ | : parse_arithexpr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 13 | lex_read_space; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 13 | $traits{_optional} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 193 | ▶ | $traits{optional} //= $traits{_optional}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$traits{"optional"} //= $traits{"_optional"}
MC/DC0%0/2
$traits{"optional"} //= $traits{"_optional"}
$traits{"optional"}
$traits{"_optional"}
Truth table66%2/3
A //= B
A= $traits{"optional"}B= $traits{"_optional"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 193 | delete($traits{_optional}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | $traits{slurpy} = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | if defined($varname) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | && !$traits{ref_alias} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 193 | ▶ | && $varname =~ /\A[\@\%]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $varname and not $traits{"ref_alias"} and $varname =~ /\A[\@\%]/u
defined $varname and not $traits{"ref_alias"}
MC/DC33%1/3
defined $varname and not $traits{"ref_alias"} and $varname =~ /\A[\@\%]/u
defined $varname
not $traits{"ref_alias"}
$varname =~ /\A[\@\%]/u
Truth table50%2/4
A and not(B) and C
A= defined $varnameB= not $traits{"ref_alias"}C= $varname =~ /\A[\@\%]/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 193 | return $class->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | %args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | name => $varname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | constraints => \@constraints, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | named => !!$named, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | named_names => \@paramname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | default => $default, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | default_when => $default_when, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | traits => \%traits, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | ((kind => $varkind) x!!(defined $varkind)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | sub sanity_check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 193 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sanity_check: called CC=12 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 193 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 193 | my $traits = $self->traits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 193 | my $name = $self->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 193 | ▶ | if ($self->named) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | length($_) || croak("Bad name for parameter $name") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 19 | ▶ | for @{ $self->named_names or die }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->named_names || die()
MC/DC0%0/1
$self->named_names || die()
$self->named_names
Truth table50%1/2
A
A= $self->named_names
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 19 | ▶ | croak("Bad parameter $name") if $self->invocant; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 19 | ▶ | croak("Bad parameter $name") if $self->slurpy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 193 | ▶ | if ($self->kind eq 'my') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 182 | ▶ | croak("Bad name for lexical variable: $name") if $name =~ /(::|\^)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 11 | ▶ | croak("Bad name for package variable: $name") if length($name) < 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 193 | ▶ | croak("Bad parameter $name") if $self->invocant && $self->slurpy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->invocant and $self->slurpy
MC/DC0%0/2
$self->invocant and $self->slurpy
$self->invocant
$self->slurpy
Truth table66%2/3
A and B
A= $self->invocantB= $self->slurpy
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | sub injection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 301 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
injection: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 301 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 301 | my ($sig) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 301 | my $var = $self->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 301 | my $is_dummy = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 301 | ▶ | if (length($var) == 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 8 | $var .= 'tmp'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 8 | $is_dummy = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 301 | my ($val, $condition) = $self->_injection_extract_and_coerce_value($sig); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 301 | my $code = $self->_injection_assignment($sig, $var, $val) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | . $self->_injection_conditional_type_check($sig, $condition, $var); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 301 | ▶ | $is_dummy ? "{ $code }" : $code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | sub _injection_assignment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 301 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_injection_assignment: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 301 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 301 | my ($sig, $var, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 301 | my $kind = $self->kind; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 301 | ▶ | sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | '%s %s = %s;', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | $kind eq 'our' ? "our $var; local" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | $kind eq 'my' ? 'my' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 'local' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | $var, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | $val, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | sub _injection_conditional_type_check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 301 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_injection_conditional_type_check: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 301 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 301 | my ($sig, $condition, $var) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 301 | my $sigil = $self->sigil; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 301 | ▶ | my $type = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | ($sigil eq '@') ? sprintf('for (%s) { %s }', $var, $self->_injection_type_check('$_')) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | ($sigil eq '%') ? sprintf('for (values %s) { %s }', $var, $self->_injection_type_check('$_')) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | ($condition eq '1') ? sprintf('%s;', $self->_injection_type_check($var)) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | sprintf('if (%s) { %s }', $condition, $self->_injection_type_check($var)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 301 | ▶ | return '' if $type =~ /\{ \}\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 195 | ▶ | return sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 'unless ($____nobble_checks) { %s };', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | $type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | ) if $sig->nobble_checks; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 170 | return $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | sub _injection_extract_and_coerce_value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 301 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_injection_extract_and_coerce_value: called CC=10 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 301 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 301 | my ($sig) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 301 | ▶ | $self->coerce | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | or return $self->_injection_extract_value(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 6 | ▶ | my $type = $self->type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | or croak("Parameter ${\ $self->name } cannot coerce without a type constraint"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 6 | ▶ | $type->has_coercion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | or croak("Parameter ${\ $self->name } cannot coerce because type constraint has no coercions defined"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 6 | my ($val, $condition) = $self->_injection_extract_value(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 6 | ▶ | my $coerce_variable = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 6 | my $variable = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 6 | ▶ | if ($type->coercion->can_be_inlined) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $type->coercion->inline_coercion($variable), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 6 | sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | '$%s::PARAMS[%d]->{type}->coerce(%s)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | $self->ID, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | $variable, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 6 | my $sigil = $self->sigil; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 6 | ▶ | if ($sigil eq '@') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 2 | $val = sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | '(map { %s } %s)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | $coerce_variable->('$_'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | $val, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | elsif ($sigil eq '%') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $val = sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 'do { my %%tmp = %s; for (values %%tmp) { %s }; %%tmp }', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | $val, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | $coerce_variable->('$_'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | ▶ | elsif ($sigil eq '$' and $type->coercion->can_be_inlined) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$sigil eq "\$" and $type->coercion->can_be_inlined
MC/DC0%0/2
$sigil eq "\$" and $type->coercion->can_be_inlined
$sigil eq "\$"
$type->coercion->can_be_inlined
Truth table33%1/3
A and B
A= $sigil eq "\$"B= $type->coercion->can_be_inlined
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | $val = sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 'do { my $tmp = %s; %s}', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | $val, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | $coerce_variable->('$tmp'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | elsif ($sigil eq '$') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 4 | $val = $coerce_variable->($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 6 | ▶ | wantarray ? ($val, $condition) : $val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | sub _injection_default_value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 602 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_injection_default_value: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 602 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 602 | my ($fallback) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 602 | ▶ | return sprintf('$%s::PARAMS[%d]{default}->()', __PACKAGE__, $self->ID) if $self->default; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 576 | ▶ | return $fallback if defined $fallback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 231 | ▶ | return sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 'Carp::croak(sprintf q/Named parameter `%%s` is required/, %s)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | B::perlstring($self->named_names->[0]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | ) if $self->named; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 230 | ▶ | return sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 'Carp::croak(q/Invocant %s is required/)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | $self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | ) if $self->invocant; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 134 | return sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 'Carp::croak(q/Positional parameter %d is required/)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | $self->position, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | sub _injection_extract_value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 301 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_injection_extract_value: called CC=19 SCAR=29.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 301 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 301 | my ($sig) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 301 | my $condition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | my $val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 301 | my $slurpy_style = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 301 | ▶ | if ($self->slurpy) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 35 | ▶ | if ($self->sigil eq '%' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$self->sigil eq "%" or $self->sigil eq "\$" and $self->type and do {
require Types::Standard;
$self->type->is_a_type_of(Types::Standard::HashRef())
}
$self->sigil eq "\$" and $self->type and do {
require Types::Standard;
$self->type->is_a_type_of(Types::Standard::HashRef())
}
$self->sigil eq "\$" and $self->type
MC/DC75%3/4
$self->sigil eq "%" or $self->sigil eq "\$" and $self->type and do {
require Types::Standard;
$self->type->is_a_type_of(Types::Standard::HashRef())
}
$self->sigil eq "%"
$self->sigil eq "\$"
$self->type
do {
require Types::Standard;
$self->type->is_a_type_of(Types::Standard::HashRef())
}
Truth table80%4/5
A or B and C and D
A= $self->sigil eq "%"B= $self->sigil eq "\$"C= $self->typeD= do {
require Types::Standard;
$self->type->is_a_type_of(Types::Standard::HashRef())
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | or ($self->sigil eq '$' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | and $self->type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 13 | and do { require Types::Standard; $self->type->is_a_type_of(Types::Standard::HashRef()) })) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 13 | ▶ | my @names = map(@{$_->named ? $_->named_names : []}, @{$sig->params}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 13 | ▶ | if (@names) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 6 | ▶ | croak("Cannot alias slurpy hash for a function with named parameters") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | if $self->alias; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 6 | ▶ | my $delete = $_->name eq '%_' ? '' : sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 'delete $tmp{$_} for (%s);', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | join(q[,], map B::perlstring($_), @names), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 6 | my $ix = 1 + $sig->last_position; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 6 | $val = sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 'do { use warnings FATAL => qw(all); my %%tmp = ($#_==%d && ref($_[%d]) eq q(HASH)) ? %%{$_[%d]} : @_[ %d .. $#_ ]; %s %%tmp ? %%tmp : (%s) }', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | ($ix) x 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | $delete, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | $self->_injection_default_value('()'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 7 | $val = sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 'do { use warnings FATAL => qw(all); my %%tmp = @_[ %d .. $#_ ]; %%tmp ? @_[ %d .. $#_ ] : (%s) }', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | $sig->last_position + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | $sig->last_position + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | $self->_injection_default_value('()'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 13 | $condition = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 13 | $slurpy_style = '%'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 22 | ▶ | croak("Cannot have a slurpy array for a function with named parameters") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | if $sig->has_named; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 22 | $val = sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | '($#_ >= %d) ? @_[ %d .. $#_ ] : (%s)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | $sig->last_position + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | $sig->last_position + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | $self->_injection_default_value('()'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 22 | $condition = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 22 | $slurpy_style = '@'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 35 | ▶ | if ($self->sigil eq '$') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 13 | ▶ | $val = $slurpy_style eq '%' ? "+{ $val }" : "[ $val ]"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 13 | $slurpy_style = '$'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | elsif ($self->named) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 38 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | my $when = +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | '//=' => 'defined', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | '||=' => '!!', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | '=' => 'exists', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 19 | ▶ | }->{ $self->default_when } || 'exists'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
{'//=', 'defined', '||=', '!!', '=', 'exists'}->{$self->default_when} || 'exists'
MC/DC0%0/1
{'//=', 'defined', '||=', '!!', '=', 'exists'}->{$self->default_when} || 'exists'
{'//=', 'defined', '||=', '!!', '=', 'exists'}->{$self->default_when}
Truth table50%1/2
A
A= {'//=', 'defined', '||=', '!!', '=', 'exists'}->{$self->default_when}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | $val = join '', map( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | sprintf('%s($_{%s}) ? $_{%s} : ', $when, $_, $_), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 19 | map B::perlstring($_), @{$self->named_names} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | ), $self->_injection_default_value(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | $condition = join ' or ', map( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | sprintf('%s($_{%s})', $when, $_), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 19 | map B::perlstring($_), @{$self->named_names} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | elsif ($self->invocant) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 96 | $val = sprintf('@_ ? shift(@_) : %s', $self->_injection_default_value()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 96 | $condition = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 38 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | my $when = +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | '//=' => 'defined($_[%d])', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | '||=' => '!!($_[%d])', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | '=' => '($#_ >= %d)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 151 | ▶ | }->{ $self->default_when } || '($#_ >= %d)'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
{'//=', 'defined($_[%d])', '||=', '!!($_[%d])', '=', '($#_ >= %d)'}->{$self->default_when} || '($#_ >= %d)'
MC/DC100%1/1
{'//=', 'defined($_[%d])', '||=', '!!($_[%d])', '=', '($#_ >= %d)'}->{$self->default_when} || '($#_ >= %d)'
{'//=', 'defined($_[%d])', '||=', '!!($_[%d])', '=', '($#_ >= %d)'}->{$self->default_when}
Truth table100%2/2
A
A= {'//=', 'defined($_[%d])', '||=', '!!($_[%d])', '=', '($#_ >= %d)'}->{$self->default_when}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 151 | my $pos = $self->position; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 151 | $val = sprintf($when.' ? $_[%d] : %s', $pos, $pos, $self->_injection_default_value()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 151 | $condition = sprintf($when, $self->position); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 301 | ▶ | $condition = 1 if $self->_injection_default_value('@@') ne '@@'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 301 | ▶ | wantarray ? ($val, $condition) : $val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | sub _injection_type_check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 301 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_injection_type_check: called CC=9 SCAR=22.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 301 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 301 | my ($var) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 301 | my $check = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 301 | ▶ | if ( my $type = $self->type ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | my $can_xs = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | $INC{'Mouse/Util.pm'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | && Mouse::Util::MOUSE_XS() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 88 | ▶ | && ($type->{_is_core} or $type->is_parameterized && $type->parent->{_is_core}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition58%7/12
$INC{'Mouse/Util.pm'} && Mouse::Util::MOUSE_XS() && ($type->{'_is_core'} || $type->is_parameterized && $type->parent->{'_is_core'})
$INC{"Mouse/Util.pm"} and Mouse::Util::MOUSE_XS()
$type->{"_is_core"} or $type->is_parameterized and $type->parent->{"_is_core"}
$type->is_parameterized and $type->parent->{"_is_core"}
MC/DC0%0/5
$INC{'Mouse/Util.pm'} && Mouse::Util::MOUSE_XS() && ($type->{'_is_core'} || $type->is_parameterized && $type->parent->{'_is_core'})
$INC{"Mouse/Util.pm"}
Mouse::Util::MOUSE_XS()
$type->{"_is_core"}
$type->is_parameterized
$type->parent->{"_is_core"}
Truth table16%1/6
A and B && C or D and E
A= $INC{"Mouse/Util.pm"}B= Mouse::Util::MOUSE_XS()C= $type->{"_is_core"}D= $type->is_parameterizedE= $type->parent->{"_is_core"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 88 | ▶ | if (!$can_xs and $type->can_be_inlined) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $can_xs and $type->can_be_inlined
MC/DC100%2/2
not $can_xs and $type->can_be_inlined
not $can_xs
$type->can_be_inlined
Truth table100%3/3
not(A) and B
A= not $can_xsB= $type->can_be_inlined
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 78 | $check .= sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | '%s;', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | $type->inline_assert($var), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 10 | $check .= sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | '$%s::PARAMS[%d]->{type}->assert_valid(%s);', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | $self->ID, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | $var, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 301 | for my $i (0 .. $#{$self->constraints}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 4 | $check .= sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 'do { local $_ = %s; $%s::PARAMS[%d]->{constraints}[%d]->() } or Carp::croak(sprintf("%%s failed value constraint", %s));', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | $var, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | $self->ID, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | $i, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | B::perlstring($var), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 301 | return $check; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 38 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||