blib/lib/Test2/Workflow/Task/Group.pm

filter: Statementstmt 100% 48 / 48 Branchbran 93.7% 15 / 16 Conditioncond 75.0% 9 / 12 MC/DCmcdc 57.1% 4 / 7 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 90.3% 84 / 93 CC 17 SCAR 20.0
CC
17
Cov
95%
filter
11.0
init
7.2
BEGIN
1.0
CRAP 7.4
« blib/lib/Test2/Workflow.pm ↑ Summary blib/lib/Test2/Mock.pm »
1 package Test2::Workflow::Task::Group;
2 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 38 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 38 our $VERSION = '1.302226';
6  
7 38 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 38 ▶use Test2::Workflow::Task::Action;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 38 ▶use base 'Test2::Workflow::Task';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 38 ▶use Test2::Util::HashBase qw/before after primary rand variant/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 201 ▶sub init {
Subroutine init: called CC=7 SCAR=19.7
Pod undocumented
15 201 my $self = shift;
16  
17 201 ▶ if (my $take = delete $self->{take}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $take = delete $self->{"take"}) 134 67 201
18 134 $self->{$_} = delete $take->{$_} for ISO, ASYNC, TODO, SKIP;
19 134 $self->{$_} = $take->{$_} for FLAT, SCAFFOLD, NAME, CODE, FRAME;
20 134 $take->{+FLAT} = 1;
21 134 $take->{+SCAFFOLD} = 1;
22 }
23  
24 {
25 201 local $Carp::CarpLevel = $Carp::CarpLevel + 1;
26 201 $self->SUPER::init();
27 }
28  
29 201 ▶ $self->{+BEFORE} ||= [];
Condition50%1/2
$self->{"before"} ||= []
l!l
2010
MC/DC0%0/1
$self->{"before"} ||= []
$self->{"before"}
Truth table50%1/2
A
A= $self->{"before"}
Aresult
11
00
30 201 ▶ $self->{+AFTER} ||= [];
Condition50%1/2
$self->{"after"} ||= []
l!l
2010
MC/DC0%0/1
$self->{"after"} ||= []
$self->{"after"}
Truth table50%1/2
A
A= $self->{"after"}
Aresult
11
00
31 201 ▶ $self->{+PRIMARY} ||= [];
Condition50%1/2
$self->{"primary"} ||= []
l!l
2010
MC/DC0%0/1
$self->{"primary"} ||= []
$self->{"primary"}
Truth table50%1/2
A
A= $self->{"primary"}
Aresult
11
00
32 }
33  
34 601 ▶sub filter {
Subroutine filter: called CC=11 SCAR=24.0
Pod undocumented
35 601 my $self = shift;
36 601 my ($filter) = @_;
37  
38 601 ▶ return if $self->{+IS_ROOT};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"is_root"} 0 601 601
39  
40 601 my $result = $self->SUPER::filter($filter);
41  
42 601 my $child_ok = 0;
43 601 for my $c (@{$self->{+PRIMARY}}) {
44 894 ▶ next if $c->{+SCAFFOLD};
Branch: 1 branch
BranchTrueFalseTotal
if $c->{"scaffold"} 464 430 894
45 # A child matches the filter, so we should not be filtered, but also
46 # should not satisfy the filter.
47 430 my $res = $c->filter($filter);
48  
49 # A child satisfies the filter
50 430 ▶ $child_ok++ if !$res || $res->{satisfied};
Branch: 1 branch
BranchTrueFalseTotal
if not $res or $res->{"satisfied"} 74 356 430
Condition100%3/3
not $res or $res->{"satisfied"}
l!l&&r!l&&!r
2945356
MC/DC100%2/2
not $res or $res->{"satisfied"}
not $res $res->{"satisfied"}
Truth table100%3/3
not(A) or B
A= not $resB= $res->{"satisfied"}
ABresult
1X1
011
000
51 430 ▶ last if $child_ok;
Branch: 1 branch
BranchTrueFalseTotal
if $child_ok 74 356 430
52 }
53  
54 # If the filter says we are ok
55 601 ▶ unless($result) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 78 523 601
56 # If we are a variant then allow everything under us to be run
57 78 ▶ return {satisfied => 1} if $self->{+VARIANT} || !$child_ok;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"variant"} or not $child_ok 70 8 78
Condition100%3/3
$self->{"variant"} or not $child_ok
l!l&&r!l&&!r
9618
MC/DC100%2/2
$self->{"variant"} or not $child_ok
$self->{"variant"} not $child_ok
Truth table100%3/3
A or not(B)
A= $self->{"variant"}B= not $child_ok
ABresult
1X1
011
000
58  
59 # Normal group
60 8 return;
61 }
62  
63 523 ▶ return if $child_ok;
Branch: 1 branch
BranchTrueFalseTotal
if $child_ok 66 457 523
64  
65 457 return $result;
66 }
67  
68 38 1;
69  
70 __END__
« blib/lib/Test2/Workflow.pm ↑ Summary blib/lib/Test2/Mock.pm »