blib/lib/Test/Lib.pm

filter: Statementstmt 100% 34 / 34 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 95.6% 44 / 46 CC 5 SCAR 11.0
CC
5
Cov
95%
import
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
↑ Summary
1 package Test::Lib;
2 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 7 our $VERSION = '0.003';
6 7 $VERSION =~ tr/_/d/;
7  
8 7 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 ▶use Cwd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶use lib ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 7 ▶sub import {
Subroutine import: called CC=5 SCAR=16.1
13 7 my $class = shift;
14 7 my $dir = shift;
15 7 ▶ if (! defined $dir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $dir) 7 0 7
16 7 my $file = File::Spec->rel2abs((caller)[1]);
17 7 $dir = File::Spec->catpath((File::Spec->splitpath($file))[0,1], '');
18 }
19 7 for my $i (0..5) {
20 27 my $tdir = File::Spec->catdir($dir, (File::Spec->updir) x $i);
21 27 my $abs_path = Cwd::abs_path($tdir);
22 27 my $dirname = (File::Spec->splitdir($abs_path))[-1];
23  
24 27 ▶ if ($dirname eq 't') {
Branch: 1 branch
BranchTrueFalseTotal
if ($dirname eq "t") 6 21 27
25 6 my $tlib = File::Spec->catdir($tdir, 'lib');
26 6 ▶ if (-d $tlib) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $tlib) 6 0 6
27 6 lib->import($tlib);
28 6 return;
29 }
30 }
31 }
32 1 require Carp;
33 1 Carp::croak("unable to find t/lib directory in $dir");
34 }
35  
36 7 1;
37  
38 __END__
↑ Summary