| 1 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 2 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | package Test::Routine::Util 0.032; | ||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: helpful exports for dealing with test routines | ||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | #pod =head1 OVERVIEW | ||||||||||||||||||||||||||||||||
| 7 | #pod | ||||||||||||||||||||||||||||||||
| 8 | #pod Test::Routine::Util is documented in L<the Test::Routine docs on running | ||||||||||||||||||||||||||||||||
| 9 | #pod tests|Test::Routine/Running Tests>. Please consult those for more information. | ||||||||||||||||||||||||||||||||
| 10 | #pod | ||||||||||||||||||||||||||||||||
| 11 | #pod Both C<run_tests> and C<run_me> are simple wrappers around the process of | ||||||||||||||||||||||||||||||||
| 12 | #pod composing given Test::Routine roles into a class and instance using | ||||||||||||||||||||||||||||||||
| 13 | #pod L<Test::Routine::Compositor>, creating a L<Test::Routine::Runner> object and | ||||||||||||||||||||||||||||||||
| 14 | #pod telling it to execute the tests on the test instance. | ||||||||||||||||||||||||||||||||
| 15 | #pod | ||||||||||||||||||||||||||||||||
| 16 | #pod =cut | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 11 | ▶ | use Scalar::Util qw(reftype); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 11 | ▶ | use Sub::Exporter::Util qw(curry_method); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | 11 | ▶ | use Test::Routine::Compositor; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | 11 | ▶ | use Test::Routine::Runner (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 11 | ▶ | use Sub::Exporter -setup => { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 25 | exports => [ | ||||||||||||||||||||||||||||||||
| 26 | run_tests => \'_curry_tester', | ||||||||||||||||||||||||||||||||
| 27 | run_me => \'_curry_tester', | ||||||||||||||||||||||||||||||||
| 28 | ], | ||||||||||||||||||||||||||||||||
| 29 | groups => [ default => [ qw(run_me run_tests) ] ], | ||||||||||||||||||||||||||||||||
| 30 | 11 | }; | |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 11 | our $UPLEVEL = 0; | |||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | 22 | ▶ | sub _curry_tester { | ||||||||||||||||||||||||||||||
|
Subroutine
_curry_tester: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||
| 35 | 22 | my ($class, $name, $arg) = @_; | |||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | 22 | ▶ | Carp::confess("the $name generator does not accept any arguments") | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 38 | if keys %$arg; | ||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | 22 | ▶ | return sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 41 | 22 | local $UPLEVEL = $UPLEVEL + 1; | |||||||||||||||||||||||||||||||
| 42 | 22 | $class->$name(@_); | |||||||||||||||||||||||||||||||
| 43 | 22 | }; | |||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 13 | ▶ | sub run_me { | ||||||||||||||||||||||||||||||
|
Subroutine
run_me: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 47 | 13 | my ($class, $desc, $arg) = @_; | |||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 13 | ▶ | if (@_ == 2 and (reftype $desc // '') eq 'HASH') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%5/5
@_ == 2 and (builtin::reftype($desc) // "") eq "HASH"
builtin::reftype($desc) // ""
MC/DC100%2/2
@_ == 2 and (builtin::reftype($desc) // "") eq "HASH"
@_ == 2
builtin::reftype($desc)
Truth table100%3/3
A and B
A= @_ == 2B= builtin::reftype($desc)
| |||||||||||||||||||||||||||||||||
| 50 | 3 | ($desc, $arg) = (undef, $desc); | |||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | 13 | my $caller = caller($UPLEVEL); | |||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 13 | local $UPLEVEL = $UPLEVEL + 1; | |||||||||||||||||||||||||||||||
| 56 | 13 | $class->run_tests($desc, $caller, $arg); | |||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 22 | ▶ | sub _runner_class { 'Test::Routine::Runner' } | ||||||||||||||||||||||||||||||
|
Subroutine
_runner_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 60 | 22 | ▶ | sub _compositor_class { 'Test::Routine::Compositor' } | ||||||||||||||||||||||||||||||
|
Subroutine
_compositor_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 22 | ▶ | sub run_tests { | ||||||||||||||||||||||||||||||
|
Subroutine
run_tests: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 63 | 22 | my ($class, $desc, $inv, $arg) = @_; | |||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 22 | my @caller = caller($UPLEVEL); | |||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 22 | ▶ | $desc = $desc | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$desc // sprintf('tests from %s, line %s', $caller[1], $caller[2])
MC/DC100%1/1
$desc // sprintf('tests from %s, line %s', $caller[1], $caller[2])
$desc
Truth table100%2/2
A
A= $desc
| |||||||||||||||||||||||||||||||||
| 68 | // sprintf 'tests from %s, line %s', $caller[1], $caller[2]; | ||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | 22 | my $builder = $class->_compositor_class->instance_builder($inv, $arg); | |||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 22 | my $self = $class->_runner_class->new({ | |||||||||||||||||||||||||||||||
| 73 | description => $desc, | ||||||||||||||||||||||||||||||||
| 74 | instance_from => $builder, | ||||||||||||||||||||||||||||||||
| 75 | }); | ||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | 22 | $self->run; | |||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | 11 | 1; | |||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | __END__ | ||||||||||||||||||||||||||||||||