| 1 | package Test2::Tools::AsyncSubtest; | ||||||||||||||||||||||||||||
| 2 | 29 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 29 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 29 | our $VERSION = '1.302226'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 29 | ▶ | use Test2::IPC; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 29 | ▶ | use Test2::AsyncSubtest; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 29 | ▶ | use Test2::API qw/context/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 29 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 29 | our @EXPORT = qw/async_subtest fork_subtest thread_subtest/; | |||||||||||||||||||||||||||
| 13 | 29 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 16 | ▶ | sub async_subtest { | ||||||||||||||||||||||||||
|
Subroutine
async_subtest: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | 16 | my $name = shift; | |||||||||||||||||||||||||||
| 17 | 16 | my ($params, $code); | |||||||||||||||||||||||||||
| 18 | 16 | ▶ | $params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ and ref $_[0] eq "HASH"
@_
ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= @_B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 19 | 16 | ▶ | $code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and ref $_[0] eq "CODE"
MC/DC50%1/2
@_ and ref $_[0] eq "CODE"
@_
ref $_[0] eq "CODE"
Truth table66%2/3
A and B
A= @_B= ref $_[0] eq "CODE"
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 16 | my $ctx = context(); | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 16 | my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 16 | ▶ | $subtest->run($code, $subtest) if $code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 16 | $ctx->release; | |||||||||||||||||||||||||||
| 28 | 16 | return $subtest; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 167 | ▶ | sub fork_subtest { | ||||||||||||||||||||||||||
|
Subroutine
fork_subtest: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 167 | my $name = shift; | |||||||||||||||||||||||||||
| 33 | 167 | my ($params, $code); | |||||||||||||||||||||||||||
| 34 | 167 | ▶ | $params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ and ref $_[0] eq "HASH"
MC/DC100%2/2
@_ and ref $_[0] eq "HASH"
@_
ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= @_B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 35 | 167 | ▶ | $code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and ref $_[0] eq "CODE"
MC/DC50%1/2
@_ and ref $_[0] eq "CODE"
@_
ref $_[0] eq "CODE"
Truth table66%2/3
A and B
A= @_B= ref $_[0] eq "CODE"
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 167 | my $ctx = context(); | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 167 | ▶ | croak "fork_subtest requires a CODE reference as the second argument" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | unless ref($code) eq 'CODE'; | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 166 | my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 166 | $subtest->run_fork($code, $subtest); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 144 | $ctx->release; | |||||||||||||||||||||||||||
| 47 | 144 | return $subtest; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 1 | ▶ | sub thread_subtest { | ||||||||||||||||||||||||||
|
Subroutine
thread_subtest: called CC=6 SCAR=23.5
Pod
documented
| |||||||||||||||||||||||||||||
| 51 | 1 | my $name = shift; | |||||||||||||||||||||||||||
| 52 | 1 | my ($params, $code); | |||||||||||||||||||||||||||
| 53 | 1 | ▶ | $params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ and ref $_[0] eq "HASH"
@_
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 54 | 1 | ▶ | $code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ and ref $_[0] eq "CODE"
MC/DC0%0/2
@_ and ref $_[0] eq "CODE"
@_
ref $_[0] eq "CODE"
Truth table33%1/3
A and B
A= @_B= ref $_[0] eq "CODE"
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | my $ctx = context(); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 1 | ▶ | croak "thread_subtest requires a CODE reference as the second argument" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | unless ref($code) eq 'CODE'; | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | $subtest->run_thread($code, $subtest); | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | $ctx->release; | |||||||||||||||||||||||||||
| 66 | 0 | return $subtest; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 29 | 1; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | __END__ | ||||||||||||||||||||||||||||