| 1 | package Test2::Event; | ||||||||||||||||||||||||||||||||||||||||||
| 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 | ▶ | use Scalar::Util qw/blessed reftype/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 455 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 455 | ▶ | use Test2::Util::HashBase qw/trace -amnesty uuid -_eid -hubs/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 455 | ▶ | use Test2::Util::ExternalMeta qw/meta get_meta set_meta delete_meta/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 455 | ▶ | use Test2::Util qw/pkg_to_file gen_uid/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 455 | ▶ | use Test2::EventFacet::About(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 455 | ▶ | use Test2::EventFacet::Amnesty(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 455 | ▶ | use Test2::EventFacet::Assert(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 455 | ▶ | use Test2::EventFacet::Control(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 455 | ▶ | use Test2::EventFacet::Error(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 455 | ▶ | use Test2::EventFacet::Info(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 455 | ▶ | use Test2::EventFacet::Meta(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 455 | ▶ | use Test2::EventFacet::Parent(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 455 | ▶ | use Test2::EventFacet::Plan(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 455 | ▶ | use Test2::EventFacet::Trace(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 455 | ▶ | use Test2::EventFacet::Hub(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | # Legacy tools will expect this to be loaded now | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 455 | require Test2::Util::Trace; | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 455 | my %LOADED_FACETS = ( | |||||||||||||||||||||||||||||||||||||||||
| 30 | 'about' => 'Test2::EventFacet::About', | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 'amnesty' => 'Test2::EventFacet::Amnesty', | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 'assert' => 'Test2::EventFacet::Assert', | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 'control' => 'Test2::EventFacet::Control', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 'errors' => 'Test2::EventFacet::Error', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 'info' => 'Test2::EventFacet::Info', | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 'meta' => 'Test2::EventFacet::Meta', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 'parent' => 'Test2::EventFacet::Parent', | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 'plan' => 'Test2::EventFacet::Plan', | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 'trace' => 'Test2::EventFacet::Trace', | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 'hubs' => 'Test2::EventFacet::Hub', | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub FACET_TYPES { sort values %LOADED_FACETS } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FACET_TYPES: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 242 | ▶ | sub load_facet { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_facet: called CC=6 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 242 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 242 | my ($facet) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 242 | ▶ | return $LOADED_FACETS{$facet} if exists $LOADED_FACETS{$facet}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | my @check = ($facet); | |||||||||||||||||||||||||||||||||||||||||
| 52 | 6 | ▶ | if ('s' eq substr($facet, -1, 1)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | push @check => substr($facet, 0, -1); | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 6 | push @check => $facet . 's'; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | my $found; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 6 | for my $check (@check) { | |||||||||||||||||||||||||||||||||||||||||
| 61 | 12 | my $mod = "Test2::EventFacet::" . ucfirst($facet); | |||||||||||||||||||||||||||||||||||||||||
| 62 | 12 | my $file = pkg_to_file($mod); | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | next unless eval { require $file; 1 }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $found = $mod; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 6 | ▶ | return undef unless $found; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $LOADED_FACETS{$facet} = $found; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 1359 | ▶ | sub causes_fail { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
causes_fail: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 1360 | ▶ | sub increments_count { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
increments_count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | ▶ | sub diagnostics { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diagnostics: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 13 | ▶ | sub no_display { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
no_display: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 1377 | ▶ | sub subtest_id { undef } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subtest_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub callback { } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
callback: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 3166 | ▶ | sub terminate { () } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
terminate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 3381 | ▶ | sub global { () } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
global: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 1359 | ▶ | sub sets_plan { () } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sets_plan: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 1392 | ▶ | sub summary { ref($_[0]) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
summary: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 9 | ▶ | sub related { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
related: called CC=9 SCAR=22.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 9 | my ($event) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 9 | ▶ | my $tracea = $self->trace or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 8 | ▶ | my $traceb = $event->trace or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 8 | my $uuida = $tracea->uuid; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 8 | my $uuidb = $traceb->uuid; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 8 | ▶ | if ($uuida && $uuidb) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$uuida and $uuidb
MC/DC50%1/2
$uuida and $uuidb
$uuida
$uuidb
Truth table66%2/3
A and B
A= $uuidaB= $uuidb
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | ▶ | return 1 if $uuida eq $uuidb; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 6 | ▶ | my $siga = $tracea->signature or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 4 | ▶ | my $sigb = $traceb->signature or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 4 | ▶ | return 1 if $siga eq $sigb; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 11563 | ▶ | sub add_hub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_hub: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 11563 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 11563 | unshift @{$self->{+HUBS}} => @_; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 320 | ▶ | sub add_amnesty { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_amnesty: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 320 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 320 | for my $am (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 116 | 320 | ▶ | $am = {%$am} if ref($am) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 320 | $am = Test2::EventFacet::Amnesty->new($am); | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 320 | push @{$self->{+AMNESTY}} => $am; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 13874 | ▶ | sub eid { $_[0]->{+_EID} ||= gen_uid() } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eid: called CC=2 SCAR=7.2
Pod
undocumented
Condition66%2/3
$_[0]{"_eid"} ||= &gen_uid()
MC/DC0%0/2
$_[0]{"_eid"} ||= &gen_uid()
$_[0]{"_eid"}
&gen_uid()
Truth table66%2/3
A ||= B
A= $_[0]{"_eid"}B= &gen_uid()
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 23729 | ▶ | sub common_facet_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
common_facet_data: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 23729 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 23729 | my %out; | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 23729 | ▶ | $out{about} = {package => ref($self) || undef}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
ref $self || undef
MC/DC0%0/1
ref $self || undef
ref $self
Truth table50%1/2
A
A= ref $self
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 23729 | ▶ | if (my $uuid = $self->uuid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 73 | $out{about}->{uuid} = $uuid; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 23729 | ▶ | $out{about}->{eid} = $self->{+_EID} || $self->eid; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'_eid'} || $self->eid
MC/DC0%0/2
$self->{'_eid'} || $self->eid
$self->{'_eid'}
$self->eid
Truth table66%2/3
A || B
A= $self->{'_eid'}B= $self->eid
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 23729 | ▶ | if (my $trace = $self->trace) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 23715 | $out{trace} = { %$trace }; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 23729 | ▶ | if (my $hubs = $self->hubs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 21398 | $out{hubs} = $hubs; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 537 | $out{amnesty} = [map {{ %{$_} }} @{$self->{+AMNESTY}}] | |||||||||||||||||||||||||||||||||||||||||
| 146 | 23729 | ▶ | if $self->{+AMNESTY}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 23729 | ▶ | if (my $meta = $self->meta_facet_data) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 1014 | $out{meta} = $meta; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 23729 | return \%out; | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 24145 | ▶ | sub meta_facet_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
meta_facet_data: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 24145 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 24145 | my $key = Test2::Util::ExternalMeta::META_KEY(); | |||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 24145 | ▶ | my $hash = $self->{$key} or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 1015 | return {%$hash}; | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 1378 | ▶ | sub facet_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
facet_data: called CC=21 SCAR=30.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 1378 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 1378 | my $out = $self->common_facet_data; | |||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 1378 | ▶ | $out->{about}->{details} = $self->summary || undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->summary || undef
MC/DC0%0/1
$self->summary || undef
$self->summary
Truth table50%1/2
A
A= $self->summary
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 1378 | ▶ | $out->{about}->{no_display} = $self->no_display || undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->no_display || undef
MC/DC100%1/1
$self->no_display || undef
$self->no_display
Truth table100%2/2
A
A= $self->no_display
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | # Might be undef, we want to preserve that | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 1378 | my $terminate = $self->terminate; | |||||||||||||||||||||||||||||||||||||||||
| 174 | $out->{control} = { | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 1378 | ▶ | global => $self->global || 0, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->global || 0
MC/DC100%1/1
$self->global || 0
$self->global
Truth table100%2/2
A
A= $self->global
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | terminate => $terminate, | ||||||||||||||||||||||||||||||||||||||||||
| 177 | has_callback => $self->can('callback') == \&callback ? 0 : 1, | ||||||||||||||||||||||||||||||||||||||||||
| 178 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | $out->{assert} = { | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 1378 | ▶ | no_debug => 1, # Legacy behavior | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | pass => $self->causes_fail ? 0 : 1, | ||||||||||||||||||||||||||||||||||||||||||
| 183 | details => $self->summary, | ||||||||||||||||||||||||||||||||||||||||||
| 184 | } if $self->increments_count; | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 1378 | ▶ | $out->{parent} = {hid => $self->subtest_id} if $self->subtest_id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 1378 | ▶ | if (my @plan = $self->sets_plan) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 4 | $out->{plan} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 4 | ▶ | $out->{plan}->{count} = $plan[0] if defined $plan[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 4 | ▶ | $out->{plan}->{details} = $plan[2] if defined $plan[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 4 | ▶ | if ($plan[1]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | ▶ | $out->{plan}->{skip} = 1 if $plan[1] eq 'SKIP'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | ▶ | $out->{plan}->{none} = 1 if $plan[1] eq 'NO PLAN'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 4 | ▶ | $out->{control}->{terminate} ||= 0 if $out->{plan}->{skip}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$out->{"control"}{"terminate"} ||= 0
MC/DC0%0/1
$out->{"control"}{"terminate"} ||= 0
$out->{"control"}{"terminate"}
Truth table50%1/2
A
A= $out->{"control"}{"terminate"}
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 1378 | ▶ | if ($self->causes_fail && !$out->{assert}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->causes_fail and not $out->{"assert"}
MC/DC100%2/2
$self->causes_fail and not $out->{"assert"}
$self->causes_fail
not $out->{"assert"}
Truth table100%3/3
A and not(B)
A= $self->causes_failB= not $out->{"assert"}
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | $out->{errors} = [ | ||||||||||||||||||||||||||||||||||||||||||
| 204 | { | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | tag => 'FAIL', | |||||||||||||||||||||||||||||||||||||||||
| 206 | fail => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 207 | details => $self->summary, | ||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 1377 | my %IGNORE = (trace => 1, about => 1, control => 1); | |||||||||||||||||||||||||||||||||||||||||
| 213 | 1377 | my $do_info = !grep { !$IGNORE{$_} } keys %$out; | |||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 1377 | ▶ | if ($do_info && !$self->no_display && $self->diagnostics) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$do_info and not $self->no_display and $self->diagnostics
$do_info and not $self->no_display
MC/DC100%3/3
$do_info and not $self->no_display and $self->diagnostics
$do_info
not $self->no_display
$self->diagnostics
Truth table100%4/4
A and not(B) and C
A= $do_infoB= not $self->no_displayC= $self->diagnostics
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | $out->{info} = [ | ||||||||||||||||||||||||||||||||||||||||||
| 217 | { | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 2 | tag => 'DIAG', | |||||||||||||||||||||||||||||||||||||||||
| 219 | debug => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 220 | details => $self->summary, | ||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 1377 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 23 | ▶ | sub facets { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
facets: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 23 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 23 | my %out; | |||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 23 | my $data = $self->facet_data; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 23 | my @errors = $self->validate_facet_data($data); | |||||||||||||||||||||||||||||||||||||||||
| 234 | 23 | ▶ | die join "\n" => @errors if @errors; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 23 | for my $facet (keys %$data) { | |||||||||||||||||||||||||||||||||||||||||
| 237 | 112 | my $class = $self->load_facet($facet); | |||||||||||||||||||||||||||||||||||||||||
| 238 | 112 | my $val = $data->{$facet}; | |||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 112 | ▶ | unless($class) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $out{$facet} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 112 | ▶ | my $is_list = reftype($val) eq 'ARRAY' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 112 | ▶ | if ($is_list) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 34 | $out{$facet} = [map { $class->new($_) } @$val]; | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 78 | $out{$facet} = $class->new($val); | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 23 | return \%out; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 29 | ▶ | sub validate_facet_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_facet_data: called CC=17 SCAR=28.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 29 | my $class_or_self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 29 | my ($f, %params); | |||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 29 | ▶ | $f = shift if @_ && (reftype($_[0]) || '') eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%5/5
@_ and (builtin::reftype($_[0]) || "") eq "HASH"
builtin::reftype($_[0]) || ''
MC/DC100%2/2
@_ and (builtin::reftype($_[0]) || "") eq "HASH"
@_
builtin::reftype($_[0])
Truth table100%3/3
A and B
A= @_B= builtin::reftype($_[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 29 | %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 29 | ▶ | $f ||= $class_or_self->facet_data if blessed($class_or_self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$f ||= $class_or_self->facet_data
MC/DC0%0/2
$f ||= $class_or_self->facet_data
$f
$class_or_self->facet_data
Truth table66%2/3
A ||= B
A= $fB= $class_or_self->facet_data
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 29 | ▶ | croak "No facet data" unless $f; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 29 | my @errors; | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 29 | for my $k (sort keys %$f) { | |||||||||||||||||||||||||||||||||||||||||
| 270 | 130 | my $fclass = $class_or_self->load_facet($k); | |||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | push @errors => "Could not find a facet class for facet '$k'" | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 130 | ▶ | if $params{require_facet_class} && !$fclass; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$params{"require_facet_class"} and not $fclass
MC/DC100%2/2
$params{"require_facet_class"} and not $fclass
$params{"require_facet_class"}
not $fclass
Truth table100%3/3
A and not(B)
A= $params{"require_facet_class"}B= not $fclass
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 130 | ▶ | next unless $fclass; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 124 | my $v = $f->{$k}; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 124 | ▶ | next unless defined($v); # undef is always fine | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 124 | my $is_list = $fclass->is_list(); | |||||||||||||||||||||||||||||||||||||||||
| 281 | 124 | ▶ | my $got_list = reftype($v) eq 'ARRAY' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 124 | ▶ | push @errors => "Facet '$k' should be a list, but got a single item ($v)" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$is_list and not $got_list
MC/DC100%2/2
$is_list and not $got_list
$is_list
not $got_list
Truth table100%3/3
A and not(B)
A= $is_listB= not $got_list
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | if $is_list && !$got_list; | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 124 | ▶ | push @errors => "Facet '$k' should not be a list, but got a a list ($v)" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$got_list and not $is_list
MC/DC100%2/2
$got_list and not $is_list
$got_list
not $is_list
Truth table100%3/3
A and not(B)
A= $got_listB= not $is_list
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | if $got_list && !$is_list; | ||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 29 | return @errors; | |||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 2 | ▶ | sub nested { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nested: called CC=5 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | Carp::cluck("Use of Test2::Event->nested() is deprecated, use Test2::Event->trace->nested instead") | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | ▶ | if $ENV{AUTHOR_TESTING}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 2 | ▶ | if (my $hubs = $self->{+HUBS}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | return $hubs->[0]->{nested} if @$hubs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 2 | ▶ | my $trace = $self->{+TRACE} or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | return $trace->{nested}; | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 2 | ▶ | sub in_subtest { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
in_subtest: called CC=7 SCAR=22.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | Carp::cluck("Use of Test2::Event->in_subtest() is deprecated, use Test2::Event->trace->hid instead") | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 2 | ▶ | if $ENV{AUTHOR_TESTING}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 2 | my $hubs = $self->{+HUBS}; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 2 | ▶ | if ($hubs && @$hubs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$hubs and @$hubs
MC/DC0%0/2
$hubs and @$hubs
$hubs
@$hubs
Truth table33%1/3
A and B
A= $hubsB= @$hubs
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | return undef unless $hubs->[0]->{nested}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | return $hubs->[0]->{hid} | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 2 | ▶ | my $trace = $self->{+TRACE} or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 2 | ▶ | return undef unless $trace->{nested}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 1 | return $trace->{hid}; | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 455 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | __END__ | ||||||||||||||||||||||||||||||||||||||||||