blib/lib/Test2/Tools/AsyncSubtest.pm

filter: Statementstmt 92.4% 49 / 53 Branchbran 77.7% 14 / 18 Conditioncond 61.1% 11 / 18 MC/DCmcdc 33.3% 4 / 12 Subroutinesub 100% 10 / 10 Podpod 100% 3 / 3 totaltotal 79.8% 91 / 114 CC 16 SCAR 17.4
CC
16
Cov
83%
thread_subtest
10.5
async_subtest
6.1
fork_subtest
6.0
CRAP 5.7
« blib/lib/Test2/Hub/Interceptor.pm ↑ Summary blib/lib/Test2/Util/Ref.pm »
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
BranchTrueFalseTotal
if @_ and ref $_[0] eq "HASH" 0 16 16
Condition66%2/3
@_ and ref $_[0] eq "HASH"
!ll&&!rl&&r
6100
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"
ABresult
0X0
100
111
19 16 ▶ $code = shift(@_) if @_ && ref($_[0]) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if @_ and ref $_[0] eq "CODE" 10 6 16
Condition66%2/3
@_ and ref $_[0] eq "CODE"
!ll&&!rl&&r
6010
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"
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if $code 10 6 16
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
BranchTrueFalseTotal
if @_ and ref $_[0] eq "HASH" 17 150 167
Condition100%3/3
@_ and ref $_[0] eq "HASH"
!ll&&!rl&&r
114917
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"
ABresult
0X0
100
111
35 167 ▶ $code = shift(@_) if @_ && ref($_[0]) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if @_ and ref $_[0] eq "CODE" 166 1 167
Condition66%2/3
@_ and ref $_[0] eq "CODE"
!ll&&!rl&&r
10166
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"
ABresult
0X0
100
111
36  
37 167 my $ctx = context();
38  
39 167 ▶ croak "fork_subtest requires a CODE reference as the second argument"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $code eq "CODE" 1 166 167
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
BranchTrueFalseTotal
if @_ and ref $_[0] eq "HASH" 0 1 1
Condition33%1/3
@_ and ref $_[0] eq "HASH"
!ll&&!rl&&r
100
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"
ABresult
0X0
100
111
54 1 ▶ $code = shift(@_) if @_ && ref($_[0]) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if @_ and ref $_[0] eq "CODE" 0 1 1
Condition33%1/3
@_ and ref $_[0] eq "CODE"
!ll&&!rl&&r
100
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"
ABresult
0X0
100
111
55  
56 1 my $ctx = context();
57  
58 1 ▶ croak "thread_subtest requires a CODE reference as the second argument"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $code eq "CODE" 1 0 1
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__
« blib/lib/Test2/Hub/Interceptor.pm ↑ Summary blib/lib/Test2/Util/Ref.pm »