blib/lib/Test2/Require/Module.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 90.0% 9 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 90.5% 48 / 53 CC 6 SCAR 7.8
CC
6
Cov
95%
check_installed
3.0
skip
3.0
check_version
2.0
CRAP 2.2
« blib/lib/Test2/EventFacet/Info/Table.pm ↑ Summary blib/lib/Test2/Compare/Regex.pm »
1 package Test2::Require::Module;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use base 'Test2::Require';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '1.302226';
8  
9 2 ▶use Test2::Util qw/pkg_to_file/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 ▶sub skip {
Subroutine skip: called CC=3 SCAR=11.0
Pod undocumented
12 5 my $class = shift;
13 5 my ($module, $ver) = @_;
14  
15 5 ▶ return "Module '$module' is not installed"
Branch: 1 branch
BranchTrueFalseTotal
unless check_installed($module) 1 4 5
16 unless check_installed($module);
17  
18 4 ▶ return undef unless defined $ver;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ver 2 2 4
19  
20 2 return check_version($module, $ver);
21 }
22  
23 5 ▶sub check_installed {
Subroutine check_installed: called CC=3 SCAR=11.1
Pod undocumented
24 5 my ($mod) = @_;
25 5 my $file = pkg_to_file($mod);
26  
27 5 ▶ return 1 if eval { require $file; 1 };
Branch: 1 branch
BranchTrueFalseTotal
if eval { do { require $file; 1 } } 4 1 5
28 1 my $error = $@;
29  
30 1 ▶ return 0 if $error =~ m/Can't locate \Q$file\E in \@INC/;
Branch: 1 branch
BranchTrueFalseTotal
if $error =~ /Can't locate \Q$file\E in \@INC/ 1 0 1
31  
32 # Some other error, rethrow it.
33 0 die $error;
34 }
35  
36 2 ▶sub check_version {
Subroutine check_version: called CC=2 SCAR=6.9
Pod undocumented
37 2 my ($mod, $ver) = @_;
38  
39 2 ▶ return undef if eval { $mod->VERSION($ver); 1 };
Branch: 1 branch
BranchTrueFalseTotal
if eval { do { $mod->VERSION($ver); 1 } } 1 1 2
40 1 my $have = $mod->VERSION;
41 1 return "Need '$mod' version $ver, have $have.";
42 }
43  
44 2 1;
45  
46 __END__
« blib/lib/Test2/EventFacet/Info/Table.pm ↑ Summary blib/lib/Test2/Compare/Regex.pm »