blib/lib/Test2/Event/Subtest.pm

filter: Statementstmt 84.6% 55 / 65 Branchbran 60.0% 12 / 20 Conditioncond 40.0% 4 / 10 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 90.9% 10 / 11 Podpod 60.0% 3 / 5 totaltotal 73.5% 86 / 117 CC 21 SCAR 22.8
CC
21
Cov
75%
set_effective_pass
25.8
set_subevents
12.0
add_amnesty
4.0
CRAP 9.8
« blib/lib/Test2/API/Context.pm ↑ Summary blib/lib/Test2/API/InterceptResult/Event.pm »
1 package Test2::Event::Subtest;
2 455 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 455 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 455 our $VERSION = '1.302226';
6  
7 455 ▶BEGIN { require Test2::Event::Ok; our @ISA = qw(Test2::Event::Ok) }
Subroutine BEGIN: called CC=1 SCAR=0.0
8 455 ▶use Test2::Util::HashBase qw{subevents buffered subtest_id subtest_uuid start_stamp stop_stamp};
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 732 ▶sub init {
Subroutine init: called CC=4 SCAR=13.9
Pod undocumented
11 732 my $self = shift;
12 732 $self->SUPER::init();
13 732 ▶ $self->{+SUBEVENTS} ||= [];
Condition100%2/2
$self->{"subevents"} ||= []
l!l
7311
MC/DC100%1/1
$self->{"subevents"} ||= []
$self->{"subevents"}
Truth table100%2/2
A
A= $self->{"subevents"}
Aresult
11
00
14 732 ▶ if ($self->{+EFFECTIVE_PASS}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"effective_pass"}) 711 21 732
15 711 $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}};
16 }
17 }
18  
19 {
20 455 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 0 ▶ sub set_subevents {
Subroutine set_subevents: not called CC=3 SCAR=24.8
23 0 my $self = shift;
24 0 my @subevents = @_;
25  
26 0 ▶ if ($self->{+EFFECTIVE_PASS}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"effective_pass"}) 0 0 0
27 0 $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @subevents;
28 }
29  
30 0 $self->{+SUBEVENTS} = \@subevents;
31 }
32  
33 382 ▶ sub set_effective_pass {
Subroutine set_effective_pass: called CC=8 SCAR=32.5
Pod undocumented
34 382 my $self = shift;
35 382 my ($pass) = @_;
36  
37 382 ▶ if ($pass) {
Branch: 2 branches
BranchTrueFalseTotal
if ($pass) { } 382 0 382
elsif ($self->{'effective_pass'} and not $pass) { } 0 0 0
38 382 $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}};
39 }
40 ▶ elsif ($self->{+EFFECTIVE_PASS} && !$pass) {
Condition0%0/3
$self->{"effective_pass"} and not $pass
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"effective_pass"} and not $pass
$self->{"effective_pass"} not $pass
Truth table0%0/3
A and not(B)
A= $self->{"effective_pass"}B= not $pass
ABresult
0X0
100
111
41 0 for my $s (grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}}) {
42 0 ▶ $_->set_effective_pass(0) unless $s->can('todo') && defined $s->todo;
Branch: 1 branch
BranchTrueFalseTotal
unless $s->can("todo") and defined $s->todo 0 0 0
Condition0%0/3
$s->can("todo") and defined $s->todo
!ll&&!rl&&r
000
MC/DC0%0/2
$s->can("todo") and defined $s->todo
$s->can("todo") defined $s->todo
Truth table0%0/3
A and B
A= $s->can("todo")B= defined $s->todo
ABresult
0X0
100
111
43 }
44 }
45  
46 382 $self->{+EFFECTIVE_PASS} = $pass;
47 }
48 }
49  
50 455 ▶sub summary {
Subroutine summary: called CC=4 SCAR=13.9
Pod documented
51 4 my $self = shift;
52  
53 4 ▶ my $name = $self->{+NAME} || "Nameless Subtest";
Condition100%2/2
$self->{'name'} || 'Nameless Subtest'
l!l
31
MC/DC100%1/1
$self->{'name'} || 'Nameless Subtest'
$self->{'name'}
Truth table100%2/2
A
A= $self->{'name'}
Aresult
11
00
54  
55 4 my $todo = $self->{+TODO};
56 4 ▶ if ($todo) {
Branch: 2 branches
BranchTrueFalseTotal
if ($todo) { } 1 3 4
elsif (defined $todo) { } 1 2 3
57 1 $name .= " (TODO: $todo)";
58 }
59 elsif (defined $todo) {
60 1 $name .= " (TODO)";
61 }
62  
63 4 return $name;
64 }
65  
66 1592 ▶sub facet_data {
Subroutine facet_data: called CC=3 SCAR=11.0
Pod documented
67 1592 my $self = shift;
68  
69 1592 my $out = $self->SUPER::facet_data();
70  
71 1592 my $start = $self->start_stamp;
72 1592 my $stop = $self->stop_stamp;
73  
74 $out->{parent} = {
75 hid => $self->subtest_id,
76 10751 ▶ children => [map {$_->facet_data} @{$self->{+SUBEVENTS}}],
Branch: 2 branches
BranchTrueFalseTotal
$start ? : 1132 460 1592
$stop ? : 1493 99 1592
77 1592 buffered => $self->{+BUFFERED},
78 $start ? (start_stamp => $start) : (),
79 $stop ? (stop_stamp => $stop) : (),
80 };
81  
82 1592 return $out;
83 }
84  
85 16 ▶sub add_amnesty {
Subroutine add_amnesty: called CC=4 SCAR=13.9
Pod documented
86 16 my $self = shift;
87  
88 16 for my $am (@_) {
89 16 ▶ $am = {%$am} if ref($am) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $am ne "ARRAY" 16 0 16
90 16 $am = Test2::EventFacet::Amnesty->new($am);
91  
92 16 push @{$self->{+AMNESTY}} => $am;
93  
94 16 for my $e (@{$self->{+SUBEVENTS}}) {
95 98 $e->add_amnesty($am->clone(inherited => 1));
96 }
97 }
98 }
99  
100  
101 455 1;
102  
103 __END__
« blib/lib/Test2/API/Context.pm ↑ Summary blib/lib/Test2/API/InterceptResult/Event.pm »