blib/lib/Dir/Self.pm

filter: Statementstmt 78.7% 26 / 33 Branchbran 33.3% 2 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 77.7% 7 / 9 Podpod n/a totaltotal 70.5% 36 / 51 CC 6 SCAR 11.3
CC
6
Cov
71%
import
6.1
__DIR__
2.0
_const
2.0
CRAP 3.1
↑ Summary
1 package Dir::Self;
2  
3 1 $VERSION = '0.11';
4  
5 1 ▶use 5.005;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 3 ▶sub __DIR__ () {
Subroutine __DIR__: called CC=2 SCAR=7.1
12 3 ▶ my $level = shift || 0;
Condition50%1/2
shift() || 0
l!l
03
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13 3 my $file = (caller $level)[1];
14 3 File::Spec->rel2abs(join '', (File::Spec->splitpath($file))[0, 1])
15 }
16  
17 0 ▶sub _const {
Subroutine _const: not called CC=1 SCAR=6.9
18 0 my $value = shift;
19 0 ▶ sub () { $value }
Subroutine __ANON__: not called CC=1 SCAR=6.9
20 0 }
21  
22 1 ▶sub import {
Subroutine import: called CC=5 SCAR=18.0
23 1 my $class = shift;
24 1 my $caller = caller;
25  
26 1 ▶ @_ or @_ = '__DIR__';
Branch: 1 branch
BranchTrueFalseTotal
@_ or @_ = "__DIR__" 0 1 1
27  
28 1 for my $item (@_) {
29 1 ▶ if ($item eq '__DIR__') {
Branch: 2 branches
BranchTrueFalseTotal
if ($item eq '__DIR__') { } 1 0 1
elsif ($item eq ':static') { } 0 0 0
30 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 *{$caller . '::__DIR__'} = \&__DIR__;
32 } elsif ($item eq ':static') {
33 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
34 0 *{$caller . '::__DIR__'} = _const &__DIR__(1);
35 } else {
36 0 require Carp;
37 0 Carp::croak(qq{"$item" is not exported by the $class module});
38 }
39 }
40 }
41  
42 1 1
43 __END__
↑ Summary