blib/lib/Test2/Tools/Target.pm

filter: Statementstmt 93.1% 41 / 44 Branchbran 62.5% 5 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 1 totaltotal 84.3% 54 / 64 CC 7 SCAR 14.3
CC
7
Cov
87%
import_into
7.3
__ANON__
1.1
BEGIN
1.0
CRAP 4.2
« blib/lib/Test2/Tools/Ref.pm ↑ Summary blib/lib/ok.pm »
1 package Test2::Tools::Target;
2 163 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 163 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 163 our $VERSION = '1.302226';
6  
7 163 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 163 ▶use Test2::Util qw/pkg_to_file/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
12 3 my $class = shift;
13  
14 3 my $caller = caller;
15 3 $class->import_into($caller, @_);
16 }
17  
18 78 ▶sub import_into {
Subroutine import_into: called CC=7 SCAR=19.9
Pod undocumented
19 78 my $class = shift;
20 78 ▶ my $into = shift or croak "no destination package provided";
Branch: 1 branch
BranchTrueFalseTotal
my $into = shift() or croak("no destination package provided") 78 0 78
21  
22 78 ▶ croak "No targets specified" unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 78 78
23  
24 78 my %targets;
25 78 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 77 1 78
26 77 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 77 77
27 0 %targets = %{ $_[0] };
28 }
29 else {
30 77 ($targets{CLASS}) = @_;
31 }
32 }
33 else {
34 1 %targets = @_;
35 }
36  
37 78 for my $name (keys %targets) {
38 78 my $target = $targets{$name};
39  
40 78 my $file = pkg_to_file($target);
41 78 require $file;
42  
43 78 ▶ $name ||= 'CLASS';
Condition50%1/2
$name ||= "CLASS"
l!l
780
MC/DC0%0/1
$name ||= "CLASS"
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
44  
45 78 my $const;
46 {
47 78 my $const_target = "$target";
48 0 ▶ $const = sub() { $const_target };
Subroutine __ANON__: not called CC=1 SCAR=1.2
49 }
50  
51 163 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
52 78 *{"$into\::$name"} = \$target;
53 78 *{"$into\::$name"} = $const;
54 }
55 }
56  
57 163 1;
58  
59 __END__
« blib/lib/Test2/Tools/Ref.pm ↑ Summary blib/lib/ok.pm »