lib/Mite/Shim.pm

filter: Statementstmt 99.1% 355 / 358 Branchbran 78.9% 60 / 76 Conditioncond 52.5% 21 / 40 MC/DCmcdc 18.1% 4 / 22 Subroutinesub 97.2% 104 / 107 Podpod 0.0% 0 / 35 totaltotal 85.2% 544 / 638 CC 110 SCAR 14.8
CC
110
Cov
92%
_finalize_application_roletiny
12.2
_finalize_application_roletiny
12.2
HANDLE_has
9.0
CRAP 4.4
« lib/Mite/App/Command/preview.pm ↑ Summary lib/Mite/Compiled.pm »
1 # NOTE: Since the intention is to ship this file with a project, this file
2 # cannot have any non-core dependencies.
3 package Mite::Shim;
4 183 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 183 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 183 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 183 ▶no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5167 ▶if ( $] < 5.009005 ) { require MRO::Compat; }
Branch: 1 branch
BranchTrueFalseTotal
if ($] < 5.009005) { } 0 174 174
10 4893 else { require mro; }
11  
12 defined ${^GLOBAL_PHASE}
13 5158 or eval { require Devel::GlobalDestruction; 1 }
14 650 ▶or do {
Branch: 1 branch
BranchTrueFalseTotal
defined ${^GLOBAL_PHASE} or eval { do { require Devel::GlobalDestruction; 1 } } or do { carp("WARNING: Devel::GlobalDestruction recommended!"); *Devel::GlobalDestruction::in_global_destruction = sub { undef; } } 173 1 174
Condition33%1/3
defined ${^GLOBAL_PHASE} or eval { do { require Devel::GlobalDestruction; 1 } }
l!l&&r!l&&!r
17400
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 } }
ABresult
1X1
011
000
15 4559 carp( "WARNING: Devel::GlobalDestruction recommended!" );
16 131 ▶ *Devel::GlobalDestruction::in_global_destruction = sub { undef; };
Subroutine __ANON__: called CC=1 SCAR=0.0
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 182 ▶BEGIN {
Subroutine BEGIN: called CC=4 SCAR=17.2
26 182 my @bool = ( \&false, \&true );
27 182 *_HAS_AUTOCLEAN = $bool[ 0+!! eval { require namespace::autoclean } ];
28 182 ▶ *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'}
l!l&&r!l&&!r
17400
$ENV{"PERL_STRICT"} or $ENV{"EXTENDED_TESTING"} or $ENV{"AUTHOR_TESTING"}
l!l&&r!l&&!r
17400
$ENV{"PERL_STRICT"} or $ENV{"EXTENDED_TESTING"}
l!l&&r!l&&!r
01740
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'}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
29 };
30  
31 # Exportable error handlers
32 134 ▶sub _error_handler {
Subroutine _error_handler: called CC=4 SCAR=14.2
33 139 my ( $func, $message, @args ) = @_;
34 139 ▶ if ( @args ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@args) 48 844 892
if (@args) 1 0 1
35 135 require Data::Dumper;
36 138 local $Data::Dumper::Terse = 1;
37 135 local $Data::Dumper::Indent = 0;
38 $message = sprintf $message, map {
39 134 ▶ ref($_) ? Data::Dumper::Dumper($_) : defined($_) ? $_ : '(undef)'
Branch: 4 branches
BranchTrueFalseTotal
ref $_ ? : 0 109 109
defined $_ ? : 109 0 109
ref $_ ? : 0 1 1
defined $_ ? : 1 0 1
40 } @args;
41 }
42 124 my $next = do { require Carp; \&{"Carp::$func"} };
43 129 @_ = ( $message );
44 135 goto $next;
45 }
46  
47 138 ▶sub carp { unshift @_, 'carp' ; goto \&_error_handler }
Subroutine carp: called CC=1 SCAR=0.0
Pod undocumented
48 142 ▶sub croak { unshift @_, 'croak' ; goto \&_error_handler }
Subroutine croak: called CC=1 SCAR=0.0
Pod undocumented
49 131 ▶sub confess { unshift @_, 'confess'; goto \&_error_handler }
Subroutine confess: called CC=1 SCAR=0.0
Pod undocumented
50  
51 # Exportable guard function
52 {
53 261 my $GUARD_PACKAGE = __PACKAGE__ . '::Guard';
54 135 ▶ *{"$GUARD_PACKAGE\::DESTROY"} = sub { $_[0][0] or $_[0][1]->() };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0][0] or $_[0][1]->() 2 243 245
55 131 ▶ *{"$GUARD_PACKAGE\::restore"} = sub { $_[0]->DESTROY; $_[0][0] = true };
Subroutine __ANON__: called CC=1 SCAR=0.0
56 126 ▶ *{"$GUARD_PACKAGE\::dismiss"} = sub { $_[0][0] = true };
Subroutine __ANON__: called CC=1 SCAR=0.0
57 123 ▶ *{"$GUARD_PACKAGE\::peek"} = sub { $_[0][2] };
Subroutine __ANON__: called CC=1 SCAR=0.0
58 129 ▶ *guard = sub (&) { bless [ 0, @_ ] => $GUARD_PACKAGE };
Subroutine __ANON__: called CC=1 SCAR=0.0
59 }
60  
61 # Exportable lock and unlock
62 119 ▶sub _lul {
Subroutine _lul: called CC=5 SCAR=16.5
63 125 my ( $lul, $ref ) = @_;
64 117 ▶ if ( ref $ref eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ref eq "ARRAY") 6 0 6
65 117 &Internals::SvREADONLY( $ref, $lul );
66 117 &Internals::SvREADONLY( \$_, $lul ) for @$ref;
67 117 return;
68 }
69 119 ▶ if ( ref $ref eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ref eq "HASH") 0 0 0
70 119 &Internals::hv_clear_placeholders( $ref );
71 119 &Internals::SvREADONLY( $ref, $lul );
72 119 &Internals::SvREADONLY( \$_, $lul ) for values %$ref;
73 119 return;
74 }
75 119 return;
76 }
77  
78 119 ▶sub lock {
Subroutine lock: called CC=1 SCAR=0.0
Pod undocumented
79 214 unshift @_, true;
80 202 goto \&_lul;
81 }
82  
83 214 ▶sub unlock {
Subroutine unlock: called CC=1 SCAR=0.0
Pod undocumented
84 202 my $ref = shift;
85 204 _lul( 0 , $ref );
86 204 ▶ &guard( sub { _lul( 1, $ref ) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
87 }
88  
89 308 ▶sub _is_compiling {
Subroutine _is_compiling: called CC=2 SCAR=6.9
90 307 ▶ defined $Mite::COMPILING and $Mite::COMPILING eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
defined $Mite::COMPILING and $Mite::COMPILING eq __PACKAGE__ 186 1947 2133
91 }
92  
93 145 ▶sub import {
Subroutine import: called CC=8 SCAR=20.8
94 209 my $me = shift;
95 207 my %arg = map +( lc($_) => true ), @_;
96 222 my ( $caller, $file ) = caller;
97  
98 798 ▶ if( _is_compiling() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_compiling()) { } 111 187 298
99 199 require Mite::Project;
100 207 '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 226 require File::Spec;
111 207 my $orig = $file;
112 211 for my $base ( @INC ) {
113 162 ▶ $base eq substr $file, 0, length $base
Branch: 1 branch
BranchTrueFalseTotal
$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) and last 1 1488 1489
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)
!ll&&!rl&&r
148801
$base eq substr($file, 0, length $base) and -f "File::Spec"->catfile($base, substr($file, 1 + length($base)))
!ll&&!rl&&r
148801
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)
ABCresult
0XX0
10X0
1100
1111
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 123 my $mite_file = $orig . '.mite.pm';
121 208 local $@;
122 221 ▶ if ( not eval { require $mite_file; 1 } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { require $mite_file; 1 } }) 0 187 187
123 155 my $e = $@;
124 47 croak "Compiled Mite file ($mite_file) for $file is missing or an error occurred loading it: $e";
125 }
126 }
127  
128 749 'warnings'->import;
129 772 'strict'->import;
130 'namespace::autoclean'->import( -cleanee => $caller )
131 58 ▶ if _HAS_AUTOCLEAN && !$arg{'-unclean'};
Branch: 1 branch
BranchTrueFalseTotal
if not $arg{"-unclean"} 285 13 298
132 }
133  
134 {
135 932 my ( $cb_before, $cb_after );
136 482 ▶ sub _finalize_application_roletiny {
Subroutine _finalize_application_roletiny: called CC=12 SCAR=25.0
137 70 my ( $me, $role, $caller, $args ) = @_;
138 66 ▶ if ( $INC{'Role/Hooks.pm'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"Role/Hooks.pm"}) 1 1 2
139 51 ▶ $cb_before ||= \%Role::Hooks::CALLBACKS_BEFORE_APPLY;
Condition50%1/2
$cb_before ||= \%Role::Hooks::CALLBACKS_BEFORE_APPLY
l!l
01
MC/DC0%0/1
$cb_before ||= \%Role::Hooks::CALLBACKS_BEFORE_APPLY
$cb_before
Truth table50%1/2
A
A= $cb_before
Aresult
11
00
140 81 ▶ $cb_after ||= \%Role::Hooks::CALLBACKS_AFTER_APPLY;
Condition50%1/2
$cb_after ||= \%Role::Hooks::CALLBACKS_AFTER_APPLY
l!l
01
MC/DC0%0/1
$cb_after ||= \%Role::Hooks::CALLBACKS_AFTER_APPLY
$cb_after
Truth table50%1/2
A
A= $cb_after
Aresult
11
00
141 }
142 749 ▶ if ( $cb_before ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cb_before) 1 1 2
143 727 ▶ $_->( $role, $caller ) for @{ $cb_before->{$role} || [] };
Condition50%1/2
$cb_before->{$role} || []
l!l
01
MC/DC0%0/1
$cb_before->{$role} || []
$cb_before->{$role}
Truth table50%1/2
A
A= $cb_before->{$role}
Aresult
11
00
144 }
145 749 'Role::Tiny'->_check_requires( $caller, $role );
146 740 my $info = $Role::Tiny::INFO{$role};
147 754 ▶ for ( @{ $info->{modifiers} || [] } ) {
Condition100%2/2
$info->{'modifiers'} || []
l!l
11
MC/DC100%1/1
$info->{'modifiers'} || []
$info->{'modifiers'}
Truth table100%2/2
A
A= $info->{'modifiers'}
Aresult
11
00
148 56 my @args = @$_;
149 761 my $modification = shift @args;
150 759 my $handler = "HANDLE_$modification";
151 60 $me->$handler( $caller, undef, @args );
152 }
153 79 ▶ if ( $cb_after ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cb_after) 1 1 2
154 268 ▶ $_->( $role, $caller ) for @{ $cb_after->{$role} || [] };
Condition50%1/2
$cb_after->{$role} || []
l!l
10
MC/DC0%0/1
$cb_after->{$role} || []
$cb_after->{$role}
Truth table50%1/2
A
A= $cb_after->{$role}
Aresult
11
00
155 }
156 61 return;
157 }
158  
159 # Usage: $me, $caller, @with_args
160 137 ▶ sub HANDLE_with {
Subroutine HANDLE_with: called CC=5 SCAR=16.1
Pod undocumented
161 70 my ( $me, $caller ) = ( shift, shift );
162 55 ▶ while ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 930 150 1080
163 690 my $role = shift;
164 476 ▶ my $args = ref($_[0]) ? shift : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 1 929 930
165 98 ▶ if ( $INC{'Role/Tiny.pm'} and 'Role::Tiny'->is_role( $role ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{'Role/Tiny.pm'} and 'Role::Tiny'->is_role($role)) { } 2 928 930
Condition100%3/3
$INC{"Role/Tiny.pm"} and "Role::Tiny"->is_role($role)
!ll&&!rl&&r
904242
MC/DC100%2/2
$INC{"Role/Tiny.pm"} and "Role::Tiny"->is_role($role)
$INC{"Role/Tiny.pm"} "Role::Tiny"->is_role($role)
Truth table100%3/3
A and B
A= $INC{"Role/Tiny.pm"}B= "Role::Tiny"->is_role($role)
ABresult
0X0
100
111
166 36 $me->_finalize_application_roletiny( $role, $caller, $args );
167 }
168 else {
169 471 $role->__FINALIZE_APPLICATION__( $caller, $args );
170 }
171 }
172 393 return;
173 }
174 }
175  
176 # Usage: $me, $caller, $keyword, @has_args
177 962 ▶sub HANDLE_has {
Subroutine HANDLE_has: called CC=9 SCAR=22.0
Pod undocumented
178 844 my ( $me, $caller, $keyword, $names ) = ( shift, shift, shift, shift );
179 915 ▶ if ( @_ % 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ % 2) 4 6254 6258
180 477 my $default = shift;
181 87 ▶ unshift @_, ( 'CODE' eq ref( $default ) )
Branch: 1 branch
BranchTrueFalseTotal
'CODE' eq ref $default ? : 1 3 4
182 ? ( is => lazy, builder => $default )
183 : ( is => ro, default => $default );
184 }
185 924 my %spec = @_;
186 494 my $code;
187 909 ▶ for my $name ( ref($names) ? @$names : $names ) {
Branch: 1 branch
BranchTrueFalseTotal
ref $names ? : 336 5922 6258
188 508 $name =~ s/^\+//;
189 'CODE' eq ref( $code = $spec{default} )
190 954 ▶ and ${"$caller\::__$name\_DEFAULT__"} = $code;
Branch: 1 branch
BranchTrueFalseTotal
"CODE" eq ref($code = $spec{"default"}) and ${"${caller}::__${name}_DEFAULT__";} = $code 1557 5538 7095
191 'CODE' eq ref( $code = $spec{builder} )
192 1014 ▶ and *{"$caller\::_build_$name"} = $code;
Branch: 1 branch
BranchTrueFalseTotal
"CODE" eq ref($code = $spec{"builder"}) and *{"${caller}::_build_$name";} = $code 1213 5882 7095
193 'CODE' eq ref( $code = $spec{trigger} )
194 1745 ▶ and *{"$caller\::_trigger_$name"} = $code;
Branch: 1 branch
BranchTrueFalseTotal
"CODE" eq ref($code = $spec{"trigger"}) and *{"${caller}::_trigger_$name";} = $code 117 6978 7095
195 'CODE' eq ref( $code = $spec{clone} )
196 638 ▶ and *{"$caller\::_clone_$name"} = $code;
Branch: 1 branch
BranchTrueFalseTotal
"CODE" eq ref($code = $spec{"clone"}) and *{"${caller}::_clone_$name";} = $code 3 7092 7095
197 }
198 705 return;
199 }
200  
201 {
202 211 ▶ my $_kind = sub { ${ shift() . '::USES_MITE' } =~ /Role/ ? 'role' : 'class' };
Subroutine __ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
${(shift()) . '::USES_MITE';} =~ /Role/ ? : 0 2 2
203  
204 297 ▶ sub _get_orig_method {
Subroutine _get_orig_method: called CC=2 SCAR=7.0
205 461 my ( $caller, $name ) = @_;
206 451 my $orig = $caller->can( $name );
207 622 ▶ return $orig if $orig;
Branch: 1 branch
BranchTrueFalseTotal
if $orig 2920 0 2920
208 531 croak "Cannot modify method $name in $caller: no such method";
209 }
210  
211 1137 ▶ sub _parse_mm_args {
Subroutine _parse_mm_args: called CC=2 SCAR=6.9
212 480 my $coderef = pop;
213 606 ▶ my $names = [ map { ref($_) ? @$_ : $_ } @_ ];
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 2105 2729 4834
214 485 ( $names, $coderef );
215 }
216  
217 # Usage: $me, $caller, $caller_kind, @before_args
218 137 ▶ sub HANDLE_before {
Subroutine HANDLE_before: called CC=5 SCAR=16.1
Pod undocumented
219 170 my ( $me, $caller, $kind ) = ( shift, shift, shift );
220 136 my ( $names, $coderef ) = &_parse_mm_args;
221 109 ▶ $kind ||= $caller->$_kind;
Condition33%1/3
$kind ||= $caller->$_kind
l!l&&r!l&&!r
103200
MC/DC0%0/2
$kind ||= $caller->$_kind
$kind $caller->$_kind
Truth table33%1/3
A ||= B
A= $kindB= $caller->$_kind
ABresult
1X1
011
000
222 251 ▶ if ( $kind eq 'role' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "role") 487 545 1032
223 212 push @{"$caller\::METHOD_MODIFIERS"},
224 [ before => $names, $coderef ];
225 66 return;
226 }
227 82 for my $name ( @$names ) {
228 60 my $orig = _get_orig_method( $caller, $name );
229 57 local $@;
230 0 ▶ eval <<"BEFORE" or die $@;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine inject_mite_functions: called CC=1 SCAR=0.0
Subroutine inject_mite_functions: called CC=1 SCAR=0.0
Subroutine inject_mite_functions: called CC=1 SCAR=0.0
Subroutine inject_mite_functions: called CC=1 SCAR=0.0
Subroutine inject_mite_functions: called CC=1 SCAR=0.0
Subroutine inject_mite_functions: called CC=1 SCAR=0.0
Subroutine inject_mite_functions: called CC=1 SCAR=0.0
Subroutine inject_mite_functions: called CC=1 SCAR=0.0
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
eval " package $caller;\n no warnings 'redefine';\n sub $name {\n \$coderef->( \@_ );\n \$orig->( \@_ );\n }\n 1;\n" or die $@ 545 0 545
231 package $caller;
232 no warnings 'redefine';
233 sub $name {
234 \$coderef->( \@_ );
235 \$orig->( \@_ );
236 }
237 1;
238 BEFORE
239 }
240 56 return;
241 }
242  
243 # Usage: $me, $caller, $caller_kind, @after_args
244 746 ▶ sub HANDLE_after {
Subroutine HANDLE_after: called CC=5 SCAR=16.6
Pod undocumented
245 9 my ( $me, $caller, $kind ) = ( shift, shift, shift );
246 8 my ( $names, $coderef ) = &_parse_mm_args;
247 8 ▶ $kind ||= $caller->$_kind;
Condition33%1/3
$kind ||= $caller->$_kind
l!l&&r!l&&!r
100
MC/DC0%0/2
$kind ||= $caller->$_kind
$kind $caller->$_kind
Truth table33%1/3
A ||= B
A= $kindB= $caller->$_kind
ABresult
1X1
011
000
248 31 ▶ if ( $kind eq 'role' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "role") 0 1 1
249 21 push @{"$caller\::METHOD_MODIFIERS"},
250 [ after => $names, $coderef ];
251 3 return;
252 }
253 17 for my $name ( @$names ) {
254 3 my $orig = _get_orig_method( $caller, $name );
255 92 local $@;
256 92 ▶ eval <<"AFTER" or die $@;
Branch: 1 branch
BranchTrueFalseTotal
eval " package $caller;\n no warnings 'redefine';\n sub $name {\n my \@r;\n if ( wantarray ) {\n \@r = \$orig->( \@_ );\n }\n elsif ( defined wantarray ) {\n \@r = scalar \$orig->( \@_ );\n }\n else {\n \$orig->( \@_ );\n 1;\n }\n \$coderef->( \@_ );\n wantarray ? \@r : \$r[0];\n }\n 1;\n" or die $@ 1 0 1
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 2 return;
278 }
279  
280 # Usage: $me, $caller, $caller_kind, @around_args
281 369 ▶ sub HANDLE_around {
Subroutine HANDLE_around: called CC=5 SCAR=16.1
Pod undocumented
282 504 my ( $me, $caller, $kind ) = ( shift, shift, shift );
283 515 my ( $names, $coderef ) = &_parse_mm_args;
284 515 ▶ $kind ||= $caller->$_kind;
Condition66%2/3
$kind ||= $caller->$_kind
l!l&&r!l&&!r
379520
MC/DC0%0/2
$kind ||= $caller->$_kind
$kind $caller->$_kind
Truth table66%2/3
A ||= B
A= $kindB= $caller->$_kind
ABresult
1X1
011
000
285 1001 ▶ if ( $kind eq 'role' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "role") 1425 2372 3797
286 808 push @{"$caller\::METHOD_MODIFIERS"},
287 [ around => $names, $coderef ];
288 151 return;
289 }
290 905 for my $name ( @$names ) {
291 341 my $orig = _get_orig_method( $caller, $name );
292 4570 local $@;
293 137 ▶ eval <<"AROUND" or die $@;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine change_parent_dir: called CC=1 SCAR=0.0
Subroutine fix_pm_to_blib: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _build_kingpin_command: called CC=1 SCAR=0.0
Subroutine _build_kingpin_command: called CC=1 SCAR=0.0
Subroutine _build_kingpin_command: called CC=1 SCAR=0.0
Subroutine _compile_meta_method: called CC=1 SCAR=0.0
Subroutine _compile_mop_attributes: called CC=1 SCAR=0.0
Subroutine _compile_mop_attributes: called CC=1 SCAR=0.0
Subroutine _compile_mop_postamble: called CC=1 SCAR=0.0
Subroutine _compile_mop_postamble: called CC=1 SCAR=0.0
Subroutine _compile_mop_postamble: called CC=1 SCAR=0.0
Subroutine _compile_mop_required_methods: called CC=1 SCAR=0.0
Subroutine _compile_pragmas: called CC=1 SCAR=0.0
Subroutine _compile_pragmas: called CC=1 SCAR=0.0
Subroutine _recurse_directory: called CC=1 SCAR=0.0
Subroutine _source_file2compiled_file: called CC=1 SCAR=0.0
Subroutine add_attributes: called CC=1 SCAR=0.0
Subroutine add_attributes: called CC=1 SCAR=0.0
Subroutine all_attributes: called CC=1 SCAR=0.0
Subroutine compilation_stages: called CC=1 SCAR=0.0
Subroutine compilation_stages: called CC=1 SCAR=0.0
Subroutine compilation_stages: called CC=1 SCAR=0.0
Subroutine compilation_stages: called CC=1 SCAR=0.0
Subroutine compilation_stages: called CC=1 SCAR=0.0
Subroutine compilation_stages: not called CC=1 SCAR=0.0
Subroutine compilation_stages: not called CC=1 SCAR=0.0
Subroutine compilation_stages: not called CC=1 SCAR=0.0
Subroutine compilation_stages: called CC=1 SCAR=0.0
Subroutine compilation_stages: called CC=1 SCAR=0.0
Subroutine extend_attribute: called CC=1 SCAR=0.0
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
eval " package $caller;\n no warnings 'redefine';\n sub $name {\n \$coderef->( \$orig, \@_ );\n }\n 1;\n" or die $@ 2374 0 2374
294 package $caller;
295 no warnings 'redefine';
296 sub $name {
297 \$coderef->( \$orig, \@_ );
298 }
299 1;
300 AROUND
301 }
302 407 return;
303 }
304 }
305  
306 # Usage: $me, $caller, $caller_kind, @signature_for_args
307 440 ▶sub HANDLE_signature_for {
Subroutine HANDLE_signature_for: called CC=1 SCAR=0.0
Pod undocumented
308 4275 my ( $me, $caller, $kind, $name ) = @_;
309 4202 $name =~ s/^\+//;
310 4916 $me->HANDLE_around( $caller, $kind, $name, ${"$caller\::SIGNATURE_FOR"}{$name} );
311 1532 return;
312 }
313  
314 875 1;
« lib/Mite/App/Command/preview.pm ↑ Summary lib/Mite/Compiled.pm »