| 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
Condition0%0/3
$arg and builtin::blessed($thing)
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)
| |||||||||||||||||||||||||||||
| 18 | if $arg and blessed $thing; | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | return $thing if blessed $thing; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | $arg //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$arg //= {}
MC/DC0%0/1
$arg //= {}
$arg
Truth table0%0/2
A
A= $arg
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 31 | if blessed $inv; | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 21 | ▶ | $inv = [ $inv ] if _CLASS($inv); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 48 | 21 | ▶ | @bases = 'Moose::Object' unless @bases; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 21 | ▶ | my $new_class = Moose::Meta::Class->create_anon_class( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
$arg and builtin::blessed($inv)
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)
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 21 | my $new_class = $class->_class_for($inv); | |||||||||||||||||||||||||||
| 68 | 21 | ▶ | $arg //= {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$arg //= {}
MC/DC100%1/1
$arg //= {}
$arg
Truth table100%2/2
A
A= $arg
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||