Routine/Compositor.pm

filter: Statementstmt 88.0% 44 / 50 Branchbran 63.6% 14 / 22 Conditioncond 40.0% 4 / 10 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 92.3% 12 / 13 Podpod 0.0% 0 / 1 totaltotal 73.5% 75 / 102 CC 17 SCAR 22.2
CC
17
Cov
76%
_invocant_for
30.0
_class_for
9.1
instance_builder
5.0
CRAP 9.2
« Routine.pm ↑ Summary Routine/Runner/NoSubtest.pm »
1 11 ▶use v5.12.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Test::Routine::Compositor 0.032;
4 # ABSTRACT: the tool for turning test routines into runnable classes
5  
6 11 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use Class::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use Moose::Meta::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use Params::Util qw(_CLASS);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 11 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 11 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 0 ▶sub _invocant_for {
Subroutine _invocant_for: not called CC=5 SCAR=34.0
15 0 my ($self, $thing, $arg) = @_;
16  
17 0 ▶ confess "can't supply preconstructed object for running tests"
Branch: 1 branch
BranchTrueFalseTotal
if $arg and builtin::blessed($thing) 0 0 0
Condition0%0/3
$arg and builtin::blessed($thing)
!ll&&!rl&&r
000
MC/DC0%0/2
$arg and builtin::blessed($thing)
$arg builtin::blessed($thing)
Truth table0%0/3
A and B
A= $argB= builtin::blessed($thing)
ABresult
0X0
100
111
18 if $arg and blessed $thing;
19  
20 0 ▶ return $thing if blessed $thing;
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($thing) 0 0 0
21  
22 0 ▶ $arg //= {};
Condition0%0/2
$arg //= {}
l!l
00
MC/DC0%0/1
$arg //= {}
$arg
Truth table0%0/2
A
A= $arg
Aresult
11
00
23 0 my $new_class = $self->_class_for($thing);
24 0 $new_class->name->new($arg);
25 }
26  
27 21 ▶sub _class_for {
Subroutine _class_for: called CC=9 SCAR=22.1
28 21 my ($class, $inv) = @_;
29  
30 21 ▶ confess "can't supply preconstructed object for test class construction"
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($inv) 0 21 21
31 if blessed $inv;
32  
33 21 ▶ $inv = [ $inv ] if _CLASS($inv);
Branch: 1 branch
BranchTrueFalseTotal
if &_CLASS($inv) 18 3 21
34  
35 21 my @bases;
36 my @roles;
37  
38 21 for my $item (@$inv) {
39 25 Class::Load::load_class($item);
40 25 ▶ my $target = $item->meta->isa('Moose::Meta::Class') ? \@bases
Branch: 2 branches
BranchTrueFalseTotal
$item->meta->isa('Moose::Meta::Class') ? : 5 20 25
$item->meta->isa('Moose::Meta::Role') ? : 20 0 20
41 : $item->meta->isa('Moose::Meta::Role') ? \@roles
42 : confess "can't run tests for this weird thing: $item";
43  
44 25 push @$target, $item;
45 }
46  
47 21 ▶ confess "can't build a test class from multiple base classes" if @bases > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @bases > 1 0 21 21
48 21 ▶ @bases = 'Moose::Object' unless @bases;
Branch: 1 branch
BranchTrueFalseTotal
unless @bases 16 5 21
49  
50 21 ▶ my $new_class = Moose::Meta::Class->create_anon_class(
Branch: 1 branch
BranchTrueFalseTotal
@roles ? : 19 2 21
51 superclasses => \@bases,
52 cache => 1,
53 (@roles ? (roles => \@roles) : ()),
54 );
55  
56 21 return $new_class->name;
57 }
58  
59 22 ▶sub instance_builder {
Subroutine instance_builder: called CC=5 SCAR=16.2
Pod undocumented
60 22 my ($class, $inv, $arg) = @_;
61  
62 22 ▶ confess "can't supply preconstructed object and constructor arguments"
Branch: 1 branch
BranchTrueFalseTotal
if $arg and builtin::blessed($inv) 0 22 22
Condition66%2/3
$arg and builtin::blessed($inv)
!ll&&!rl&&r
1660
MC/DC0%0/2
$arg and builtin::blessed($inv)
$arg builtin::blessed($inv)
Truth table66%2/3
A and B
A= $argB= builtin::blessed($inv)
ABresult
0X0
100
111
63 if $arg and blessed $inv;
64  
65 22 ▶ return sub { $inv } if blessed $inv;
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($inv) 1 21 22
66  
67 21 my $new_class = $class->_class_for($inv);
68 21 ▶ $arg //= {};
Condition100%2/2
$arg //= {}
l!l
615
MC/DC100%1/1
$arg //= {}
$arg
Truth table100%2/2
A
A= $arg
Aresult
11
00
69  
70 21 ▶ return sub { $new_class->new($arg); };
Subroutine __ANON__: called CC=1 SCAR=0.0
71 }
72  
73 11 1;
74  
75 __END__
« Routine.pm ↑ Summary Routine/Runner/NoSubtest.pm »