| 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
| |||||||||||||
| 21 | |||||||||||||
| 22 | 78 | ▶ | croak "No targets specified" unless @_; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | |||||||||||||
| 24 | 78 | my %targets; | |||||||||||
| 25 | 78 | ▶ | if (@_ == 1) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 26 | 77 | ▶ | if (ref $_[0] eq 'HASH') { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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"
MC/DC0%0/1
$name ||= "CLASS"
$name
Truth table50%1/2
A
A= $name
| |||||||||||||
| 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__ | ||||||||||||