| 1 | # NOTE: Since the intention is to ship this file with a project, this file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # cannot have any non-core dependencies. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Acme::Marvel::CinematicUniverse::Mite; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use 5.008001; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | ▶ | if ( $] < 5.009005 ) { require MRO::Compat; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | else { require mro; } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | defined ${^GLOBAL_PHASE} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | or eval { require Devel::GlobalDestruction; 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined ${^GLOBAL_PHASE} or eval {
do {
require Devel::GlobalDestruction;
1
}
}
MC/DC0%0/2
defined ${^GLOBAL_PHASE} or eval {
do {
require Devel::GlobalDestruction;
1
}
}
defined ${^GLOBAL_PHASE}
eval {
do {
require Devel::GlobalDestruction;
1
}
}
Truth table33%1/3
A or B
A= defined ${^GLOBAL_PHASE}B= eval {
do {
require Devel::GlobalDestruction;
1
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | carp( "WARNING: Devel::GlobalDestruction recommended!" ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | *Devel::GlobalDestruction::in_global_destruction = sub { undef; }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # Constants | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | sub true () { !!1 } sub false () { !!0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | sub ro () { 'ro' } sub rw () { 'rw' } sub rwp () { 'rwp' } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | sub lazy () { 'lazy' } sub bare () { 'bare' } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # More complicated constants | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=17.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | my @bool = ( \&false, \&true ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | *_HAS_AUTOCLEAN = $bool[ 0+!! eval { require namespace::autoclean } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | *STRICT = $bool[ 0+!! ( $ENV{PERL_STRICT} || $ENV{EXTENDED_TESTING} || $ENV{AUTHOR_TESTING} || $ENV{RELEASE_TESTING} ) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%3/9
$ENV{'PERL_STRICT'} || $ENV{'EXTENDED_TESTING'} || $ENV{'AUTHOR_TESTING'} || $ENV{'RELEASE_TESTING'}
$ENV{"PERL_STRICT"} or $ENV{"EXTENDED_TESTING"} or $ENV{"AUTHOR_TESTING"}
$ENV{"PERL_STRICT"} or $ENV{"EXTENDED_TESTING"}
MC/DC0%0/4
$ENV{'PERL_STRICT'} || $ENV{'EXTENDED_TESTING'} || $ENV{'AUTHOR_TESTING'} || $ENV{'RELEASE_TESTING'}
$ENV{"PERL_STRICT"}
$ENV{"EXTENDED_TESTING"}
$ENV{"AUTHOR_TESTING"}
$ENV{'RELEASE_TESTING'}
Truth table20%1/5
A or B or C || D
A= $ENV{"PERL_STRICT"}B= $ENV{"EXTENDED_TESTING"}C= $ENV{"AUTHOR_TESTING"}D= $ENV{'RELEASE_TESTING'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # Exportable error handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub _error_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_error_handler: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my ( $func, $message, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if ( @args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | local $Data::Dumper::Terse = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | local $Data::Dumper::Indent = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $message = sprintf $message, map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | ref($_) ? Data::Dumper::Dumper($_) : defined($_) ? $_ : '(undef)' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $next = do { require Carp; \&{"Carp::$func"} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | @_ = ( $message ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | goto $next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub carp { unshift @_, 'carp' ; goto \&_error_handler } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
carp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub croak { unshift @_, 'croak' ; goto \&_error_handler } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
croak: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub confess { unshift @_, 'confess'; goto \&_error_handler } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
confess: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # Exportable guard function | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | my $GUARD_PACKAGE = __PACKAGE__ . '::Guard'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | *{"$GUARD_PACKAGE\::DESTROY"} = sub { $_[0][0] or $_[0][1]->() }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=10.5
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | *{"$GUARD_PACKAGE\::restore"} = sub { $_[0]->DESTROY; $_[0][0] = true }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | *{"$GUARD_PACKAGE\::dismiss"} = sub { $_[0][0] = true }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | *{"$GUARD_PACKAGE\::peek"} = sub { $_[0][2] }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | *guard = sub (&) { bless [ 0, @_ ] => $GUARD_PACKAGE }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # Exportable lock and unlock | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub _lul { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lul: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my ( $lul, $ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ( ref $ref eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | &Internals::SvREADONLY( $ref, $lul ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | &Internals::SvREADONLY( \$_, $lul ) for @$ref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ( ref $ref eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | &Internals::hv_clear_placeholders( $ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | &Internals::SvREADONLY( $ref, $lul ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | &Internals::SvREADONLY( \$_, $lul ) for values %$ref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub lock { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lock: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | unshift @_, true; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | goto \&_lul; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub unlock { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unlock: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $ref = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | _lul( 0 , $ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | &guard( sub { _lul( 1, $ref ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | ▶ | sub _is_compiling { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_compiling: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | ▶ | defined $Mite::COMPILING and $Mite::COMPILING eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=7 SCAR=20.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | my $me = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | my %arg = map +( lc($_) => true ), @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | my ( $caller, $file ) = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | ▶ | if( _is_compiling() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | require Mite::Project; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | 'Mite::Project'->default->inject_mite_functions( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 'package' => $caller, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 'file' => $file, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 'arg' => \%arg, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 'shim' => $me, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # Try to determine original filename for caller, minus libdir. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # This would normally be in %INC but caller hasn't finished loading yet. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | require File::Spec; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | my $orig = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | for my $base ( @INC ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | ▶ | $base eq substr $file, 0, length $base | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$base eq substr($file, 0, length $base) and -f "File::Spec"->catfile($base, substr($file, 1 + length($base))) and $orig = "File::Spec"->abs2rel($file, $base)
$base eq substr($file, 0, length $base) and -f "File::Spec"->catfile($base, substr($file, 1 + length($base)))
MC/DC33%1/3
$base eq substr($file, 0, length $base) and -f "File::Spec"->catfile($base, substr($file, 1 + length($base))) and $orig = "File::Spec"->abs2rel($file, $base)
$base eq substr($file, 0, length $base)
-f "File::Spec"->catfile($base, substr($file, 1 + length($base)))
$orig = "File::Spec"->abs2rel($file, $base)
Truth table50%2/4
A and B and C
A= $base eq substr($file, 0, length $base)B= -f "File::Spec"->catfile($base, substr($file, 1 + length($base)))C= $orig = "File::Spec"->abs2rel($file, $base)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | and -f File::Spec->catfile( $base, substr $file, 1 + length $base ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | and $orig = File::Spec->abs2rel( $file, $base ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | and last; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # Changes to this filename must be coordinated with Mite::Compiled | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | my $mite_file = $orig . '.mite.pm'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | ▶ | if ( not eval { require $mite_file; 1 } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $e = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | croak "Compiled Mite file ($mite_file) for $file is missing or an error occurred loading it: $e"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | 'warnings'->import; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | 'strict'->import; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 'namespace::autoclean'->import( -cleanee => $caller ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | if _HAS_AUTOCLEAN && !$arg{'-unclean'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | my ( $cb_before, $cb_after ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub _finalize_application_roletiny { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finalize_application_roletiny: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my ( $me, $role, $caller, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if ( $INC{'Role/Hooks.pm'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | $cb_before ||= \%Role::Hooks::CALLBACKS_BEFORE_APPLY; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$cb_before ||= \%Role::Hooks::CALLBACKS_BEFORE_APPLY
MC/DC0%0/1
$cb_before ||= \%Role::Hooks::CALLBACKS_BEFORE_APPLY
$cb_before
Truth table0%0/2
A
A= $cb_before
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | $cb_after ||= \%Role::Hooks::CALLBACKS_AFTER_APPLY; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$cb_after ||= \%Role::Hooks::CALLBACKS_AFTER_APPLY
MC/DC0%0/1
$cb_after ||= \%Role::Hooks::CALLBACKS_AFTER_APPLY
$cb_after
Truth table0%0/2
A
A= $cb_after
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if ( $cb_before ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | $_->( $role, $caller ) for @{ $cb_before->{$role} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$cb_before->{$role} || []
MC/DC0%0/1
$cb_before->{$role} || []
$cb_before->{$role}
Truth table0%0/2
A
A= $cb_before->{$role}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | 'Role::Tiny'->_check_requires( $caller, $role ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $info = $Role::Tiny::INFO{$role}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | for ( @{ $info->{modifiers} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$info->{'modifiers'} || []
MC/DC0%0/1
$info->{'modifiers'} || []
$info->{'modifiers'}
Truth table0%0/2
A
A= $info->{'modifiers'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my @args = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my $modification = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $handler = "HANDLE_$modification"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $me->$handler( $caller, undef, @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if ( $cb_after ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | $_->( $role, $caller ) for @{ $cb_after->{$role} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$cb_after->{$role} || []
MC/DC0%0/1
$cb_after->{$role} || []
$cb_after->{$role}
Truth table0%0/2
A
A= $cb_after->{$role}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # Usage: $me, $caller, @with_args | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | sub HANDLE_with { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
HANDLE_with: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my ( $me, $caller ) = ( shift, shift ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | while ( @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $role = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | my $args = ref($_[0]) ? shift : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if ( $INC{'Role/Tiny.pm'} and 'Role::Tiny'->is_role( $role ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$INC{"Role/Tiny.pm"} and "Role::Tiny"->is_role($role)
MC/DC0%0/2
$INC{"Role/Tiny.pm"} and "Role::Tiny"->is_role($role)
$INC{"Role/Tiny.pm"}
"Role::Tiny"->is_role($role)
Truth table0%0/3
A and B
A= $INC{"Role/Tiny.pm"}B= "Role::Tiny"->is_role($role)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $me->_finalize_application_roletiny( $role, $caller, $args ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $role->__FINALIZE_APPLICATION__( $caller, $args ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # Usage: $me, $caller, $keyword, @has_args | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | ▶ | sub HANDLE_has { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
HANDLE_has: called CC=9 SCAR=27.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 8 | my ( $me, $caller, $keyword, $names ) = ( shift, shift, shift, shift ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 8 | ▶ | if ( @_ % 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $default = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | unshift @_, ( 'CODE' eq ref( $default ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | ? ( is => lazy, builder => $default ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | : ( is => ro, default => $default ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 8 | my %spec = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 8 | my $code; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 8 | ▶ | for my $name ( ref($names) ? @$names : $names ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 8 | $name =~ s/^\+//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 'CODE' eq ref( $code = $spec{default} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | and ${"$caller\::__$name\_DEFAULT__"} = $code; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 'CODE' eq ref( $code = $spec{builder} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | and *{"$caller\::_build_$name"} = $code; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 'CODE' eq ref( $code = $spec{trigger} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | and *{"$caller\::_trigger_$name"} = $code; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 'CODE' eq ref( $code = $spec{clone} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | and *{"$caller\::_clone_$name"} = $code; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 8 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | my $_kind = sub { ${ shift() . '::USES_MITE' } =~ /Role/ ? 'role' : 'class' }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | sub _get_orig_method { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_orig_method: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my ( $caller, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $orig = $caller->can( $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | return $orig if $orig; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | croak "Cannot modify method $name in $caller: no such method"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub _parse_mm_args { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_mm_args: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $coderef = pop; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | my $names = [ map { ref($_) ? @$_ : $_ } @_ ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ( $names, $coderef ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # Usage: $me, $caller, $caller_kind, @before_args | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | sub HANDLE_before { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
HANDLE_before: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my ( $me, $caller, $kind ) = ( shift, shift, shift ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my ( $names, $coderef ) = &_parse_mm_args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | $kind ||= $caller->$_kind; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$kind ||= $caller->$_kind
MC/DC0%0/2
$kind ||= $caller->$_kind
$kind
$caller->$_kind
Truth table0%0/3
A ||= B
A= $kindB= $caller->$_kind
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ( $kind eq 'role' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | push @{"$caller\::METHOD_MODIFIERS"}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | [ before => $names, $coderef ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | for my $name ( @$names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $orig = _get_orig_method( $caller, $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | eval <<"BEFORE" or die $@; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | package $caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | sub $name { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | \$coderef->( \@_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | \$orig->( \@_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | BEFORE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # Usage: $me, $caller, $caller_kind, @after_args | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub HANDLE_after { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
HANDLE_after: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my ( $me, $caller, $kind ) = ( shift, shift, shift ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my ( $names, $coderef ) = &_parse_mm_args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | $kind ||= $caller->$_kind; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$kind ||= $caller->$_kind
MC/DC0%0/2
$kind ||= $caller->$_kind
$kind
$caller->$_kind
Truth table0%0/3
A ||= B
A= $kindB= $caller->$_kind
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if ( $kind eq 'role' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | push @{"$caller\::METHOD_MODIFIERS"}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | [ after => $names, $coderef ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | for my $name ( @$names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | my $orig = _get_orig_method( $caller, $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | eval <<"AFTER" or die $@; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | package $caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | sub $name { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | my \@r; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | if ( wantarray ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | \@r = \$orig->( \@_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | elsif ( defined wantarray ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | \@r = scalar \$orig->( \@_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | \$orig->( \@_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | \$coderef->( \@_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | wantarray ? \@r : \$r[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | AFTER | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # Usage: $me, $caller, $caller_kind, @around_args | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | sub HANDLE_around { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
HANDLE_around: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my ( $me, $caller, $kind ) = ( shift, shift, shift ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my ( $names, $coderef ) = &_parse_mm_args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | $kind ||= $caller->$_kind; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$kind ||= $caller->$_kind
MC/DC0%0/2
$kind ||= $caller->$_kind
$kind
$caller->$_kind
Truth table0%0/3
A ||= B
A= $kindB= $caller->$_kind
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | if ( $kind eq 'role' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | push @{"$caller\::METHOD_MODIFIERS"}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | [ around => $names, $coderef ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | for my $name ( @$names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $orig = _get_orig_method( $caller, $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | eval <<"AROUND" or die $@; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | package $caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | sub $name { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | \$coderef->( \$orig, \@_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | AROUND | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # Usage: $me, $caller, $caller_kind, @signature_for_args | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | ▶ | sub HANDLE_signature_for { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
HANDLE_signature_for: not called CC=1 SCAR=4.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my ( $me, $caller, $kind, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $name =~ s/^\+//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $me->HANDLE_around( $caller, $kind, $name, ${"$caller\::SIGNATURE_FOR"}{$name} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||