blib/lib/Test2/API/InterceptResult/Event.pm

filter: Statementstmt 93.6% 308 / 329 Branchbran 86.0% 172 / 200 Conditioncond 61.9% 44 / 71 MC/DCmcdc 39.4% 15 / 38 Subroutinesub 92.2% 83 / 90 Podpod 94.2% 66 / 70 totaltotal 86.2% 688 / 798 CC 141 SCAR 22.6
CC
141
Cov
87%
flatten
39.9
BEGIN
14.6
init
11.0
CRAP 9.6
« blib/lib/Test2/Event/Subtest.pm ↑ Summary blib/lib/Test2/Event.pm »
1 package Test2::API::InterceptResult::Event;
2 98 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 98 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 98 our $VERSION = '1.302226';
6  
7 98 ▶use List::Util qw/first/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 98 ▶use Test2::Util qw/pkg_to_file/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 98 ▶use Scalar::Util qw/reftype blessed/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 98 ▶use Storable qw/dclone/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 98 ▶use Carp qw/confess croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 98 ▶use Test2::API::InterceptResult::Facet;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 98 ▶use Test2::API::InterceptResult::Hub;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 98 ▶use Test2::Util::HashBase qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
18 +causes_failure
19 <facet_data
20 <result_class
21 98 };
22  
23 98 my %FACETS;
24 98 ▶BEGIN {
Subroutine BEGIN: called CC=5 SCAR=26.8
25 98 local $@;
26 98 local *plugins;
27 0 ▶ if (eval { require Module::Pluggable; 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Module::Pluggable; 1 } }) 0 98 98
28 Module::Pluggable->import(
29 # We will replace the sub later
30 require => 1,
31 0 ▶ on_require_error => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
32 0 search_path => ['Test2::EventFacet'],
33 max_depth => 3,
34 min_depth => 3,
35 );
36  
37 0 for my $facet_type (__PACKAGE__->plugins) {
38 0 my ($key, $list);
39 0 eval {
40 0 $key = $facet_type->facet_key;
41 0 $list = $facet_type->is_list;
42 };
43 0 ▶ next unless $key && defined($list);
Branch: 1 branch
BranchTrueFalseTotal
unless $key and defined $list 0 0 0
Condition0%0/3
$key and defined $list
!ll&&!rl&&r
000
MC/DC0%0/2
$key and defined $list
$key defined $list
Truth table0%0/3
A and B
A= $keyB= defined $list
ABresult
0X0
100
111
44  
45 0 $FACETS{$key} = {list => $list, class => $facet_type, loaded => 1};
46 }
47 }
48  
49 98 $FACETS{__GENERIC__} = {class => 'Test2::API::InterceptResult::Facet', loaded => 1};
50 }
51  
52 1 ▶sub facet_map { \%FACETS }
Subroutine facet_map: called CC=1 SCAR=0.0
Pod undocumented
53  
54 807 ▶sub facet_info {
Subroutine facet_info: called CC=6 SCAR=17.9
Pod undocumented
55 807 my $facet = pop;
56  
57 807 ▶ return $FACETS{$facet} if exists $FACETS{$facet};
Branch: 1 branch
BranchTrueFalseTotal
if exists $FACETS{$facet} 778 29 807
58  
59 29 my $mname = ucfirst(lc($facet));
60 29 $mname =~ s/s$//;
61  
62 29 for my $name ($mname, "${mname}s") {
63 32 my $file = "Test2/EventFacet/$name.pm";
64 32 my $class = "Test2::EventFacet::$name";
65  
66 32 local $@;
67 32 my $ok = eval {
68 32 require $file;
69  
70 26 my $key = $class->facet_key;
71 26 my $list = $class->is_list;
72  
73 26 $FACETS{$key} = {list => $list, class => $class, loaded => 1};
74 26 ▶ $FACETS{$facet} = $FACETS{$key} if $facet ne $key;
Branch: 1 branch
BranchTrueFalseTotal
if $facet ne $key 0 26 26
75  
76 26 1;
77 };
78  
79 32 ▶ return $FACETS{$facet} if $ok && $FACETS{$facet};
Branch: 1 branch
BranchTrueFalseTotal
if $ok and $FACETS{$facet} 26 6 32
Condition66%2/3
$ok and $FACETS{$facet}
!ll&&!rl&&r
6026
MC/DC50%1/2
$ok and $FACETS{$facet}
$ok $FACETS{$facet}
Truth table66%2/3
A and B
A= $okB= $FACETS{$facet}
ABresult
0X0
100
111
80 }
81  
82 3 return $FACETS{$facet} = $FACETS{__GENERIC__};
83 }
84  
85 118 ▶sub init {
Subroutine init: called CC=11 SCAR=24.0
Pod undocumented
86 118 my $self = shift;
87  
88 118 ▶ my $rc = $self->{+RESULT_CLASS} ||= 'Test2::API::InterceptResult';
Condition100%2/2
$self->{"result_class"} ||= "Test2::API::InterceptResult"
l!l
6850
MC/DC100%1/1
$self->{"result_class"} ||= "Test2::API::InterceptResult"
$self->{"result_class"}
Truth table100%2/2
A
A= $self->{"result_class"}
Aresult
11
00
89 118 my $rc_file = pkg_to_file($rc);
90 118 ▶ require($rc_file) unless $INC{$rc_file};
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{$rc_file} 2 116 118
91  
92 118 ▶ my $fd = $self->{+FACET_DATA} ||= {};
Condition100%2/2
$self->{"facet_data"} ||= {}
l!l
10711
MC/DC100%1/1
$self->{"facet_data"} ||= {}
$self->{"facet_data"}
Truth table100%2/2
A
A= $self->{"facet_data"}
Aresult
11
00
93  
94 118 for my $facet (keys %$fd) {
95 355 my $finfo = $self->facet_info($facet);
96 355 my $is_list = $finfo->{list};
97 355 ▶ next unless defined $is_list;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $is_list 6 349 355
98  
99 349 my $type = reftype($fd->{$facet});
100  
101 349 ▶ if ($is_list) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_list) { } 128 221 349
102 128 ▶ confess "Facet '$facet' is a list facet, but got '$type' instead of an arrayref"
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "ARRAY" 1 127 128
103 unless $type eq 'ARRAY';
104  
105 127 for my $item (@{$fd->{$facet}}) {
106 176 my $itype = reftype($item);
107 176 ▶ next if $itype eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if $itype eq "HASH" 175 1 176
108  
109 1 confess "Got item type '$itype' in list-facet '$facet', all items must be hashrefs";
110 }
111 }
112 else {
113 221 ▶ confess "Facet '$facet' is an only-one facet, but got '$type' instead of a hashref"
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "HASH" 1 220 221
114 unless $type eq 'HASH';
115 }
116 }
117 }
118  
119 18 ▶sub clone {
Subroutine clone: called CC=1 SCAR=0.0
Pod documented
120 18 my $self = shift;
121 18 my $class = blessed($self);
122  
123 18 my %data = %$self;
124  
125 18 $data{+FACET_DATA} = dclone($data{+FACET_DATA});
126  
127 18 return bless(\%data, $class);
128 }
129  
130 219 ▶sub _facet_class {
Subroutine _facet_class: called CC=3 SCAR=13.6
131 219 my $self = shift;
132 219 my ($name) = @_;
133  
134 219 my $spec = $self->facet_info($name);
135 219 my $class = $spec->{class};
136 219 ▶ unless ($spec->{loaded}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($spec->{"loaded"}) 0 219 219
137 0 my $file = pkg_to_file($class);
138 0 ▶ require $file unless $INC{$file};
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{$file} 0 0 0
139 0 $spec->{loaded} = 1;
140 }
141  
142 219 return $class;
143 }
144  
145 157 ▶sub the_facet {
Subroutine the_facet: called CC=7 SCAR=19.7
Pod documented
146 157 my $self = shift;
147 157 my ($name) = @_;
148  
149 157 ▶ return undef unless defined $self->{+FACET_DATA}->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"facet_data"}{$name} 24 133 157
150  
151 133 my $data = $self->{+FACET_DATA}->{$name};
152  
153 133 ▶ my $type = reftype($data) or confess "Facet '$name' has a value that is not a reference, this should not happen";
Branch: 1 branch
BranchTrueFalseTotal
my $type = builtin::reftype($data) or confess("Facet '${name}' has a value that is not a reference, this should not happen") 133 0 133
154  
155 133 ▶ return $self->_facet_class($name)->new(%{dclone($data)})
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "HASH" 129 4 133
156 if $type eq 'HASH';
157  
158 4 ▶ if ($type eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "ARRAY") 4 0 4
159 4 ▶ return undef unless @$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 4 4
160 4 ▶ croak "'the_facet' called for facet '$name', but '$name' has '" . @$data . "' items" if @$data != 1;
Branch: 1 branch
BranchTrueFalseTotal
if @$data != 1 1 3 4
161 3 return $self->_facet_class($name)->new(%{dclone($data->[0])});
162 }
163  
164 0 die "Invalid facet data type: $type";
165 }
166  
167 131 ▶sub facet {
Subroutine facet: called CC=5 SCAR=16.1
Pod documented
168 131 my $self = shift;
169 131 my ($name) = @_;
170  
171 131 ▶ return () unless exists $self->{+FACET_DATA}->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"facet_data"}{$name} 44 87 131
172  
173 87 my $data = $self->{+FACET_DATA}->{$name};
174  
175 87 ▶ my $type = reftype($data) or confess "Facet '$name' has a value that is not a reference, this should not happen";
Branch: 1 branch
BranchTrueFalseTotal
my $type = builtin::reftype($data) or confess("Facet '${name}' has a value that is not a reference, this should not happen") 87 0 87
176  
177 87 my @out;
178 87 ▶ @out = ($data) if $type eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "HASH" 10 77 87
179 87 ▶ @out = (@$data) if $type eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "ARRAY" 77 10 87
180  
181 87 my $class = $self->_facet_class($name);
182  
183 87 return map { $class->new(%{dclone($_)}) } @out;
184 }
185  
186 55 ▶sub causes_failure {
Subroutine causes_failure: called CC=3 SCAR=11.0
Pod documented
187 55 my $self = shift;
188  
189 return $self->{+CAUSES_FAILURE}
190 55 ▶ if exists $self->{+CAUSES_FAILURE};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"causes_failure"} 18 37 55
191  
192 37 my $hub = Test2::API::InterceptResult::Hub->new();
193 37 $hub->process($self);
194  
195 37 ▶ return $self->{+CAUSES_FAILURE} = ($hub->is_passing ? 0 : 1);
Branch: 1 branch
BranchTrueFalseTotal
$hub->is_passing ? : 34 3 37
196 }
197  
198 31 ▶sub causes_fail { shift->causes_failure }
Subroutine causes_fail: called CC=1 SCAR=0.0
Pod documented
199  
200 2 ▶sub trace { $_[0]->facet('trace') }
Subroutine trace: called CC=1 SCAR=0.0
Pod documented
201 146 ▶sub the_trace { $_[0]->the_facet('trace') }
Subroutine the_trace: called CC=1 SCAR=0.0
Pod documented
202 82 ▶sub frame { my $t = $_[0]->the_trace or return undef; $t->{frame} || undef }
Subroutine frame: called CC=3 SCAR=11.1
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
my $t = $_[0]->the_trace or return undef 64 18 82
$t->{"frame"} or undef 64 0 64
203 24 ▶sub trace_details { my $t = $_[0]->the_trace or return undef; $t->{details} || undef }
Subroutine trace_details: called CC=3 SCAR=11.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
my $t = $_[0]->the_trace or return undef 19 5 24
$t->{"details"} or undef 7 12 19
204 2 ▶sub trace_stamp { my $f = $_[0]->the_trace or return undef; $f->{stamp} || undef }
Subroutine trace_stamp: called CC=3 SCAR=12.0
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
my $f = $_[0]->the_trace or return undef 2 0 2
$f->{"stamp"} or undef 2 0 2
205 3 ▶sub trace_package { my $f = $_[0]->frame or return undef; $f->[0] || undef }
Subroutine trace_package: called CC=3 SCAR=11.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
my $f = $_[0]->frame or return undef 2 1 3
$f->[0] or undef 1 1 2
206 24 ▶sub trace_file { my $f = $_[0]->frame or return undef; $f->[1] || undef }
Subroutine trace_file: called CC=3 SCAR=11.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
my $f = $_[0]->frame or return undef 19 5 24
$f->[1] or undef 18 1 19
207 25 ▶sub trace_line { my $f = $_[0]->frame or return undef; $f->[2] || undef }
Subroutine trace_line: called CC=3 SCAR=11.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
my $f = $_[0]->frame or return undef 20 5 25
$f->[2] or undef 19 1 20
208 24 ▶sub trace_subname { my $f = $_[0]->frame or return undef; $f->[3] || undef }
Subroutine trace_subname: called CC=3 SCAR=11.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
my $f = $_[0]->frame or return undef 19 5 24
$f->[3] or undef 18 1 19
209 3 ▶sub trace_tool { my $f = $_[0]->frame or return undef; $f->[3] || undef }
Subroutine trace_tool: called CC=3 SCAR=11.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
my $f = $_[0]->frame or return undef 2 1 3
$f->[3] or undef 1 1 2
210  
211 36 ▶sub trace_signature { my $t = $_[0]->the_trace or return undef; Test2::EventFacet::Trace::signature($t) || undef }
Subroutine trace_signature: called CC=3 SCAR=12.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
my $t = $_[0]->the_trace or return undef 36 0 36
Test2::EventFacet::Trace::signature($t) or undef 36 0 36
212  
213 30 ▶sub brief {
Subroutine brief: called CC=3 SCAR=11.0
Pod documented
214 30 my $self = shift;
215  
216 30 my @try = qw{
217 bailout_brief
218 error_brief
219 assert_brief
220 plan_brief
221 };
222  
223 30 for my $meth (@try) {
224 79 ▶ my $got = $self->$meth or next;
Branch: 1 branch
BranchTrueFalseTotal
my $got = $self->$meth or next 27 52 79
225 27 return $got;
226 }
227  
228 3 return;
229 }
230  
231 13 ▶sub flatten {
Subroutine flatten: called CC=37 SCAR=36.9
Pod documented
232 13 my $self = shift;
233 13 my %params = @_;
234  
235 13 my $todo = {%{$self->{+FACET_DATA}}};
236 13 delete $todo->{hubs};
237 13 delete $todo->{meta};
238 13 delete $todo->{trace};
239  
240 13 my $out = $self->summary;
241 13 delete $out->{brief};
242 13 delete $out->{facets};
243 13 delete $out->{trace_tool};
244 13 ▶ delete $out->{trace_details} unless defined($out->{trace_details});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $out->{"trace_details"} 11 2 13
245  
246 13 ▶ for my $tagged (grep { my $finfo = $self->facet_info($_); $finfo->{list} && $finfo->{class}->can('tag') } keys %FACETS, keys %$todo) {
Condition100%3/3
$finfo->{'list'} && $finfo->{'class'}->can('tag')
!ll&&!rl&&r
1511357
MC/DC100%2/2
$finfo->{'list'} && $finfo->{'class'}->can('tag')
$finfo->{'list'} $finfo->{'class'}->can('tag')
Truth table100%3/3
A && B
A= $finfo->{'list'}B= $finfo->{'class'}->can('tag')
ABresult
0X0
100
111
247 57 ▶ my $set = delete $todo->{$tagged} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $set = delete $todo->{$tagged} or next 13 44 57
248  
249 13 my $fd = $self->{+FACET_DATA};
250 13 my $has_assert = $self->has_assert;
251 13 my $has_parent = $self->has_subtest;
252 13 ▶ my $has_fatal_error = $self->has_errors && grep { $_->{fail} } $self->errors;
Condition66%2/3
$self->has_errors && grep({$_->{'fail'};} $self->errors)
!ll&&!rl&&r
1012
MC/DC50%1/2
$self->has_errors && grep({$_->{'fail'};} $self->errors)
$self->has_errors grep({$_->{'fail'};} $self->errors)
Truth table66%2/3
A && B
A= $self->has_errorsB= grep({$_->{'fail'};} $self->errors)
ABresult
0X0
100
111
253  
254 13 ▶ next if $tagged eq 'amnesty' && !($has_assert || $has_parent || $has_fatal_error);
Branch: 1 branch
BranchTrueFalseTotal
if $tagged eq "amnesty" and not $has_assert || $has_parent || $has_fatal_error 1 12 13
Condition88%8/9
$tagged eq "amnesty" and not $has_assert || $has_parent || $has_fatal_error
!ll&&!rl&&r
751
$has_assert || $has_parent || $has_fatal_error
l!l&&r!l&&!r
231
$has_assert or $has_parent
l!l&&r!l&&!r
204
MC/DC75%3/4
$tagged eq "amnesty" and not $has_assert || $has_parent || $has_fatal_error
$tagged eq "amnesty" $has_assert $has_parent $has_fatal_error
Truth table80%4/5
A and not(B or C || D)
A= $tagged eq "amnesty"B= $has_assertC= $has_parentD= $has_fatal_error
ABCDresult
0XXX0
11XX0
101X0
10010
10001
255  
256 12 for my $item (@$set) {
257 34 ▶ push @{$out->{lc($item->{tag})}} => $item->{fail} ? "FATAL: $item->{details}" : $item->{details};
Branch: 1 branch
BranchTrueFalseTotal
$item->{'fail'} ? : 5 29 34
258 }
259 }
260  
261 13 ▶ if (my $assert = delete $todo->{assert}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $assert = delete $todo->{"assert"}) 7 6 13
262 7 $out->{pass} = $assert->{pass};
263 7 $out->{name} = $assert->{details};
264 }
265  
266 13 ▶ if (my $parent = delete $todo->{parent}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = delete $todo->{"parent"}) 2 11 13
267 2 ▶ delete $out->{subtest}->{bailed_out} unless defined $out->{subtest}->{bailed_out};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $out->{"subtest"}{"bailed_out"} 2 0 2
268 2 ▶ delete $out->{subtest}->{skip_reason} unless defined $out->{subtest}->{skip_reason};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $out->{"subtest"}{"skip_reason"} 2 0 2
269  
270 2 ▶ if (my $res = $self->subtest_result) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $res = $self->subtest_result) 2 0 2
271 2 my $state = $res->state;
272 2 delete $state->{$_} for grep { !defined($state->{$_}) } keys %$state;
273 2 $out->{subtest} = $state;
274 $out->{subevents} = $res->flatten(%params)
275 2 ▶ if $params{include_subevents};
Branch: 1 branch
BranchTrueFalseTotal
if $params{"include_subevents"} 1 1 2
276 }
277 }
278  
279 13 ▶ if (my $control = delete $todo->{control}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $control = delete $todo->{"control"}) 3 10 13
280 3 ▶ if ($control->{halt}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($control->{'halt'}) { } 1 2 3
elsif (defined $control->{'details'}) { } 2 0 2
281 1 ▶ $out->{bailed_out} = $control->{details} || 1;
Condition50%1/2
$control->{'details'} || 1
l!l
10
MC/DC0%0/1
$control->{'details'} || 1
$control->{'details'}
Truth table50%1/2
A
A= $control->{'details'}
Aresult
11
00
282 }
283 elsif(defined $control->{details}) {
284 2 $out->{control} = $control->{details};
285 }
286 }
287  
288 13 ▶ if (my $plan = delete $todo->{plan}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $plan = delete $todo->{"plan"}) 1 12 13
289 1 $out->{plan} = $self->plan_brief;
290 1 $out->{plan} =~ s/^PLAN\s*//;
291 }
292  
293 13 for my $other (keys %$todo) {
294 8 ▶ my $data = $todo->{$other} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $data = $todo->{$other} or next 8 0 8
295  
296 8 ▶ if (reftype($data) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::reftype($data) eq 'ARRAY') { } 2 6 8
297 2 ▶ if (!$out->{$other} || reftype($out->{$other}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (not $out->{$other} or builtin::reftype($out->{$other}) eq "ARRAY") 2 0 2
Condition33%1/3
not $out->{$other} or builtin::reftype($out->{$other}) eq "ARRAY"
l!l&&r!l&&!r
200
MC/DC0%0/2
not $out->{$other} or builtin::reftype($out->{$other}) eq "ARRAY"
not $out->{$other} builtin::reftype($out->{$other}) eq "ARRAY"
Truth table33%1/3
not(A) or B
A= not $out->{$other}B= builtin::reftype($out->{$other}) eq "ARRAY"
ABresult
1X1
011
000
298 2 for my $item (@$data) {
299 2 ▶ push @{$out->{$other}} => $item->{details} if defined $item->{details};
Branch: 1 branch
BranchTrueFalseTotal
if defined $item->{"details"} 2 0 2
300 }
301 }
302 }
303 else {
304 6 ▶ $out->{$other} = $data->{details} if defined($data->{details}) && !defined($out->{$other});
Branch: 1 branch
BranchTrueFalseTotal
if defined $data->{"details"} and not defined $out->{$other} 6 0 6
Condition33%1/3
defined $data->{"details"} and not defined $out->{$other}
!ll&&!rl&&r
006
MC/DC0%0/2
defined $data->{"details"} and not defined $out->{$other}
defined $data->{"details"} not defined $out->{$other}
Truth table33%1/3
A and not(B)
A= defined $data->{"details"}B= not defined $out->{$other}
ABresult
0X0
100
111
305 }
306 }
307  
308 13 ▶ if (my $fields = $params{fields}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $fields = $params{"fields"}) 1 12 13
309 1 ▶ $out = { map {exists($out->{$_}) ? ($_ => $out->{$_}) : ()} @$fields };
Branch: 1 branch
BranchTrueFalseTotal
exists $out->{$_} ? : 2 0 2
310 }
311  
312 13 ▶ if (my $remove = $params{remove}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $remove = $params{"remove"}) 1 12 13
313 1 delete $out->{$_} for @$remove;
314 }
315  
316 13 return $out;
317 }
318  
319 21 ▶sub summary {
Subroutine summary: called CC=6 SCAR=17.9
Pod documented
320 21 my $self = shift;
321 21 my %params = @_;
322  
323 my $out = {
324 brief => $self->brief || '',
325  
326 causes_failure => $self->causes_failure,
327  
328 trace_line => $self->trace_line,
329 trace_file => $self->trace_file,
330 trace_tool => $self->trace_subname,
331 trace_details => $self->trace_details,
332  
333 21 ▶ facets => [ sort keys(%{$self->{+FACET_DATA}}) ],
Condition100%2/2
$self->brief || ''
l!l
192
MC/DC100%1/1
$self->brief || ''
$self->brief
Truth table100%2/2
A
A= $self->brief
Aresult
11
00
334 };
335  
336 21 ▶ if (my $fields = $params{fields}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $fields = $params{"fields"}) 1 20 21
337 1 ▶ $out = { map {exists($out->{$_}) ? ($_ => $out->{$_}) : ()} @$fields };
Branch: 1 branch
BranchTrueFalseTotal
exists $out->{$_} ? : 2 0 2
338 }
339  
340 21 ▶ if (my $remove = $params{remove}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $remove = $params{"remove"}) 1 20 21
341 1 delete $out->{$_} for @$remove;
342 }
343  
344 21 return $out;
345 }
346  
347 87 ▶sub has_assert { $_[0]->{+FACET_DATA}->{assert} ? 1 : 0 }
Subroutine has_assert: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'facet_data'}{'assert'} ? : 21 66 87
348 0 ▶sub the_assert { $_[0]->the_facet('assert') }
Subroutine the_assert: not called CC=1 SCAR=6.9
Pod documented
349 4 ▶sub assert { $_[0]->facet('assert') }
Subroutine assert: called CC=1 SCAR=0.0
Pod documented
350  
351 24 ▶sub assert_brief {
Subroutine assert_brief: called CC=4 SCAR=13.9
Pod documented
352 24 my $self = shift;
353  
354 24 my $fd = $self->{+FACET_DATA};
355 24 ▶ my $as = $fd->{assert} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $as = $fd->{"assert"} or return 18 6 24
356 18 my $am = $fd->{amnesty};
357  
358 18 ▶ my $out = $as->{pass} ? "PASS" : "FAIL";
Branch: 1 branch
BranchTrueFalseTotal
$as->{'pass'} ? : 16 2 18
359 18 ▶ $out .= " with amnesty" if $am;
Branch: 1 branch
BranchTrueFalseTotal
if $am 2 16 18
360 18 return $out;
361 }
362  
363 48 ▶sub has_subtest { $_[0]->{+FACET_DATA}->{parent} ? 1 : 0 }
Subroutine has_subtest: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'facet_data'}{'parent'} ? : 8 40 48
364 2 ▶sub the_subtest { $_[0]->the_facet('parent') }
Subroutine the_subtest: called CC=1 SCAR=0.0
Pod documented
365 2 ▶sub subtest { $_[0]->facet('parent') }
Subroutine subtest: called CC=1 SCAR=0.0
Pod documented
366  
367 9 ▶sub subtest_result {
Subroutine subtest_result: called CC=5 SCAR=16.2
Pod documented
368 9 my $self = shift;
369  
370 9 ▶ my $parent = $self->{+FACET_DATA}->{parent} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $parent = $self->{"facet_data"}{"parent"} or return 7 2 9
371 7 ▶ my $children = $parent->{children} || [];
Condition50%1/2
$parent->{'children'} || []
l!l
70
MC/DC0%0/1
$parent->{'children'} || []
$parent->{'children'}
Truth table50%1/2
A
A= $parent->{'children'}
Aresult
11
00
372  
373 $children = $self->{+RESULT_CLASS}->new(@$children)->upgrade
374 7 ▶ unless blessed($children) && $children->isa($self->{+RESULT_CLASS});
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($children) and $children->isa($self->{"result_class"}) 3 4 7
Condition66%2/3
builtin::blessed($children) and $children->isa($self->{"result_class"})
!ll&&!rl&&r
304
MC/DC50%1/2
builtin::blessed($children) and $children->isa($self->{"result_class"})
builtin::blessed($children) $children->isa($self->{"result_class"})
Truth table66%2/3
A and B
A= builtin::blessed($children)B= $children->isa($self->{"result_class"})
ABresult
0X0
100
111
375  
376 7 return $children;
377 }
378  
379 29 ▶sub has_bailout { $_[0]->bailout ? 1 : 0 }
Subroutine has_bailout: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->bailout ? : 1 28 29
380 0 ▶sub the_bailout { my ($b) = $_[0]->bailout; $b }
Subroutine the_bailout: not called CC=1 SCAR=6.9
Pod documented
381  
382 66 ▶sub bailout {
Subroutine bailout: called CC=3 SCAR=11.0
Pod documented
383 66 my $self = shift;
384 66 ▶ my $control = $self->{+FACET_DATA}->{control} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $control = $self->{"facet_data"}{"control"} or return 12 54 66
385 12 ▶ return $control if $control->{halt};
Branch: 1 branch
BranchTrueFalseTotal
if $control->{"halt"} 10 2 12
386 2 return;
387 }
388  
389 33 ▶sub bailout_brief {
Subroutine bailout_brief: called CC=3 SCAR=11.0
Pod documented
390 33 my $self = shift;
391 33 ▶ my $bo = $self->bailout or return;
Branch: 1 branch
BranchTrueFalseTotal
my $bo = $self->bailout or return 7 26 33
392  
393 7 ▶ my $reason = $bo->{details} or return "BAILED OUT";
Branch: 1 branch
BranchTrueFalseTotal
my $reason = $bo->{"details"} or return "BAILED OUT" 7 0 7
394 7 return "BAILED OUT: $reason";
395 }
396  
397 2 ▶sub bailout_reason {
Subroutine bailout_reason: called CC=3 SCAR=11.1
Pod documented
398 2 my $self = shift;
399 2 ▶ my $bo = $self->bailout or return;
Branch: 1 branch
BranchTrueFalseTotal
my $bo = $self->bailout or return 1 1 2
400 1 ▶ return $bo->{details} || '';
Condition50%1/2
$bo->{'details'} || ''
l!l
10
MC/DC0%0/1
$bo->{'details'} || ''
$bo->{'details'}
Truth table50%1/2
A
A= $bo->{'details'}
Aresult
11
00
401 }
402  
403 35 ▶sub has_plan { $_[0]->{+FACET_DATA}->{plan} ? 1 : 0 }
Subroutine has_plan: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'facet_data'}{'plan'} ? : 2 33 35
404 0 ▶sub the_plan { $_[0]->the_facet('plan') }
Subroutine the_plan: not called CC=1 SCAR=6.9
Pod documented
405 2 ▶sub plan { $_[0]->facet('plan') }
Subroutine plan: called CC=1 SCAR=0.0
Pod documented
406  
407 13 ▶sub plan_brief {
Subroutine plan_brief: called CC=3 SCAR=11.0
Pod documented
408 13 my $self = shift;
409  
410 13 ▶ my $plan = $self->{+FACET_DATA}->{plan} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $plan = $self->{"facet_data"}{"plan"} or return 9 4 13
411  
412 9 my $base = $self->_plan_brief($plan);
413  
414 9 ▶ my $reason = $plan->{details} or return $base;
Branch: 1 branch
BranchTrueFalseTotal
my $reason = $plan->{"details"} or return $base 4 5 9
415 4 return "$base: $reason";
416 }
417  
418 9 ▶sub _plan_brief {
Subroutine _plan_brief: called CC=4 SCAR=13.9
419 9 my $self = shift;
420 9 my ($plan) = @_;
421  
422 9 ▶ return 'NO PLAN' if $plan->{none};
Branch: 1 branch
BranchTrueFalseTotal
if $plan->{"none"} 1 8 9
423 8 ▶ return "SKIP ALL" if $plan->{skip} || !$plan->{count};
Branch: 1 branch
BranchTrueFalseTotal
if $plan->{"skip"} or not $plan->{"count"} 2 6 8
Condition100%3/3
$plan->{"skip"} or not $plan->{"count"}
l!l&&r!l&&!r
116
MC/DC100%2/2
$plan->{"skip"} or not $plan->{"count"}
$plan->{"skip"} not $plan->{"count"}
Truth table100%3/3
A or not(B)
A= $plan->{"skip"}B= not $plan->{"count"}
ABresult
1X1
011
000
424 6 return "PLAN $plan->{count}";
425 }
426  
427 2 ▶sub has_amnesty { $_[0]->{+FACET_DATA}->{amnesty} ? 1 : 0 }
Subroutine has_amnesty: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'facet_data'}{'amnesty'} ? : 1 1 2
428 0 ▶sub the_amnesty { $_[0]->the_facet('amnesty') }
Subroutine the_amnesty: not called CC=1 SCAR=6.9
Pod documented
429 22 ▶sub amnesty { $_[0]->facet('amnesty') }
Subroutine amnesty: called CC=1 SCAR=0.0
Pod documented
430 2 ▶sub amnesty_reasons { map { $_->{details} } $_[0]->amnesty }
Subroutine amnesty_reasons: called CC=1 SCAR=0.0
Pod documented
431  
432 1 ▶sub has_todos { &first(sub { uc($_->{tag}) eq 'TODO' }, $_[0]->amnesty) ? 1 : 0 }
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine has_todos: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { uc $_->{'tag'} eq 'TODO'; } , $_[0]->amnesty) ? : 1 1 2
433 4 ▶sub todos { grep { uc($_->{tag}) eq 'TODO' } $_[0]->amnesty }
Subroutine todos: called CC=1 SCAR=0.0
Pod documented
434 2 ▶sub todo_reasons { map { $_->{details} || 'TODO' } $_[0]->todos }
Subroutine todo_reasons: called CC=2 SCAR=7.2
Pod documented
Condition50%1/2
$_->{'details'} || 'TODO'
l!l
20
MC/DC0%0/1
$_->{'details'} || 'TODO'
$_->{'details'}
Truth table50%1/2
A
A= $_->{'details'}
Aresult
11
00
435  
436 3 ▶sub has_skips { &first(sub { uc($_->{tag}) eq 'SKIP' }, $_[0]->amnesty) ? 1 : 0 }
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine has_skips: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { uc $_->{'tag'} eq 'SKIP'; } , $_[0]->amnesty) ? : 1 1 2
437 4 ▶sub skips { grep { uc($_->{tag}) eq 'SKIP' } $_[0]->amnesty }
Subroutine skips: called CC=1 SCAR=0.0
Pod documented
438 2 ▶sub skip_reasons { map { $_->{details} || 'SKIP' } $_[0]->skips }
Subroutine skip_reasons: called CC=2 SCAR=7.2
Pod documented
Condition50%1/2
$_->{'details'} || 'SKIP'
l!l
20
MC/DC0%0/1
$_->{'details'} || 'SKIP'
$_->{'details'}
Truth table50%1/2
A
A= $_->{'details'}
Aresult
11
00
439  
440 98 my %TODO_OR_SKIP = (SKIP => 1, TODO => 1);
441 5 ▶sub has_other_amnesty { &first( sub { !$TODO_OR_SKIP{uc($_->{tag})} }, $_[0]->amnesty) ? 1 : 0 }
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine has_other_amnesty: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { not $TODO_OR_SKIP{uc $_->{'tag'}}; } , $_[0]->amnesty) ? : 1 1 2
442 4 ▶sub other_amnesty { grep { !$TODO_OR_SKIP{uc($_->{tag})} } $_[0]->amnesty }
Subroutine other_amnesty: called CC=1 SCAR=0.0
Pod documented
443 2 ▶sub other_amnesty_reasons { map { $_->{details} || $_->{tag} || 'AMNESTY' } $_[0]->other_amnesty }
Subroutine other_amnesty_reasons: called CC=3 SCAR=13.1
Pod documented
Condition40%2/5
$_->{'details'} || $_->{'tag'} || 'AMNESTY'
l!l
20
$_->{"details"} or $_->{"tag"}
l!l&&r!l&&!r
200
MC/DC0%0/2
$_->{'details'} || $_->{'tag'} || 'AMNESTY'
$_->{"details"} $_->{"tag"}
Truth table33%1/3
A or B
A= $_->{"details"}B= $_->{"tag"}
ABresult
1X1
011
000
444  
445 50 ▶sub has_errors { $_[0]->{+FACET_DATA}->{errors} ? 1 : 0 }
Subroutine has_errors: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'facet_data'}{'errors'} ? : 16 34 50
446 0 ▶sub the_errors { $_[0]->the_facet('errors') }
Subroutine the_errors: not called CC=1 SCAR=6.9
Pod documented
447 26 ▶sub errors { $_[0]->facet('errors') }
Subroutine errors: called CC=1 SCAR=0.0
Pod documented
448 10 ▶sub error_messages { map { $_->{details} || $_->{tag} || 'ERROR' } $_[0]->errors }
Subroutine error_messages: called CC=3 SCAR=13.1
Pod documented
Condition40%2/5
$_->{'details'} || $_->{'tag'} || 'ERROR'
l!l
60
$_->{"details"} or $_->{"tag"}
l!l&&r!l&&!r
600
MC/DC0%0/2
$_->{'details'} || $_->{'tag'} || 'ERROR'
$_->{"details"} $_->{"tag"}
Truth table33%1/3
A or B
A= $_->{"details"}B= $_->{"tag"}
ABresult
1X1
011
000
449  
450 30 ▶sub error_brief {
Subroutine error_brief: called CC=6 SCAR=17.9
Pod documented
451 30 my $self = shift;
452  
453 30 ▶ my $errors = $self->{+FACET_DATA}->{errors} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $errors = $self->{"facet_data"}{"errors"} or return 10 20 30
454  
455 10 ▶ my $base = @$errors > 1 ? "ERRORS" : "ERROR";
Branch: 1 branch
BranchTrueFalseTotal
@$errors > 1 ? : 3 7 10
456  
457 10 ▶ return $base unless @$errors;
Branch: 1 branch
BranchTrueFalseTotal
unless @$errors 0 10 10
458  
459 10 my ($msg, @extra) = split /[\n\r]+/, $errors->[0]->{details};
460  
461 10 my $out = "$base: $msg";
462  
463 10 ▶ $out .= " [...]" if @extra || @$errors > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @extra or @$errors > 1 4 6 10
Condition100%3/3
@extra or @$errors > 1
l!l&&r!l&&!r
136
MC/DC100%2/2
@extra or @$errors > 1
@extra @$errors > 1
Truth table100%3/3
A or B
A= @extraB= @$errors > 1
ABresult
1X1
011
000
464  
465 10 return $out;
466 }
467  
468 34 ▶sub has_info { $_[0]->{+FACET_DATA}->{info} ? 1 : 0 }
Subroutine has_info: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'facet_data'}{'info'} ? : 29 5 34
469 0 ▶sub the_info { $_[0]->the_facet('info') }
Subroutine the_info: not called CC=1 SCAR=6.9
Pod documented
470 64 ▶sub info { $_[0]->facet('info') }
Subroutine info: called CC=1 SCAR=0.0
Pod documented
471 7 ▶sub info_messages { map { $_->{details} } $_[0]->info }
Subroutine info_messages: called CC=1 SCAR=0.0
Pod documented
472  
473 3 ▶sub has_diags { &first(sub { uc($_->{tag}) eq 'DIAG' }, $_[0]->info) ? 1 : 0 }
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine has_diags: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { uc $_->{'tag'} eq 'DIAG'; } , $_[0]->info) ? : 2 6 8
474 10 ▶sub diags { grep { uc($_->{tag}) eq 'DIAG' } $_[0]->info }
Subroutine diags: called CC=1 SCAR=0.0
Pod documented
475 8 ▶sub diag_messages { map { $_->{details} || 'DIAG' } $_[0]->diags }
Subroutine diag_messages: called CC=2 SCAR=7.2
Pod documented
Condition50%1/2
$_->{'details'} || 'DIAG'
l!l
60
MC/DC0%0/1
$_->{'details'} || 'DIAG'
$_->{'details'}
Truth table50%1/2
A
A= $_->{'details'}
Aresult
11
00
476  
477 5 ▶sub has_notes { &first(sub { uc($_->{tag}) eq 'NOTE' }, $_[0]->info) ? 1 : 0 }
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine has_notes: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { uc $_->{'tag'} eq 'NOTE'; } , $_[0]->info) ? : 2 6 8
478 10 ▶sub notes { grep { uc($_->{tag}) eq 'NOTE' } $_[0]->info }
Subroutine notes: called CC=1 SCAR=0.0
Pod documented
479 8 ▶sub note_messages { map { $_->{details} || 'NOTE' } $_[0]->notes }
Subroutine note_messages: called CC=2 SCAR=7.2
Pod documented
Condition50%1/2
$_->{'details'} || 'NOTE'
l!l
60
MC/DC0%0/1
$_->{'details'} || 'NOTE'
$_->{'details'}
Truth table50%1/2
A
A= $_->{'details'}
Aresult
11
00
480  
481 98 my %NOTE_OR_DIAG = (NOTE => 1, DIAG => 1);
482 5 ▶sub has_other_info { &first(sub { !$NOTE_OR_DIAG{uc($_->{tag})} }, $_[0]->info) ? 1 : 0 }
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine has_other_info: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { not $NOTE_OR_DIAG{uc $_->{'tag'}}; } , $_[0]->info) ? : 1 1 2
483 4 ▶sub other_info { grep { !$NOTE_OR_DIAG{uc($_->{tag})} } $_[0]->info }
Subroutine other_info: called CC=1 SCAR=0.0
Pod documented
484 2 ▶sub other_info_messages { map { $_->{details} || $_->{tag} || 'INFO' } $_[0]->other_info }
Subroutine other_info_messages: called CC=3 SCAR=13.1
Pod documented
Condition40%2/5
$_->{'details'} || $_->{'tag'} || 'INFO'
l!l
20
$_->{"details"} or $_->{"tag"}
l!l&&r!l&&!r
200
MC/DC0%0/2
$_->{'details'} || $_->{'tag'} || 'INFO'
$_->{"details"} $_->{"tag"}
Truth table33%1/3
A or B
A= $_->{"details"}B= $_->{"tag"}
ABresult
1X1
011
000
485  
486 98 1;
487  
488 __END__
« blib/lib/Test2/Event/Subtest.pm ↑ Summary blib/lib/Test2/Event.pm »