blib/lib/Test2/Event/V2.pm

filter: Statementstmt 100% 52 / 52 Branchbran 93.7% 15 / 16 Conditioncond 80.0% 8 / 10 MC/DCmcdc 66.6% 4 / 6 Subroutinesub 100% 11 / 11 Podpod 50.0% 2 / 4 totaltotal 92.9% 92 / 99 CC 15 SCAR 17.2
CC
15
Cov
96%
facet_data
9.1
init
7.0
BEGIN
1.0
CRAP 5.6
« blib/lib/Test2/Util/Ref.pm ↑ Summary blib/lib/Test2/Tools/Tester.pm »
1 package Test2::Event::V2;
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/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 ▶BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) }
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 455 ▶use Test2::Util::Facets2Legacy qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
13 causes_fail diagnostics global increments_count no_display sets_plan
14 subtest_id summary terminate
15 455 };
16  
17 455 ▶use Test2::Util::HashBase qw/-about/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 417 ▶sub non_facet_keys {
Subroutine non_facet_keys: called CC=1 SCAR=0.0
Pod undocumented
20 return (
21 417 +UUID,
22 Test2::Util::ExternalMeta::META_KEY(),
23 );
24 }
25  
26 374 ▶sub init {
Subroutine init: called CC=7 SCAR=19.5
Pod undocumented
27 374 my $self = shift;
28  
29 374 my $uuid;
30 374 ▶ if ($uuid = $self->{+UUID}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($uuid = $self->{'uuid'}) { } 4 370 374
elsif ($self->{'about'} and $self->{'about'}{'uuid'}) { } 1 734 735
31 croak "uuid '$uuid' passed to constructor, but uuid '$self->{+ABOUT}->{uuid}' is already set in the 'about' facet"
32 4 ▶ if $self->{+ABOUT}->{uuid} && $self->{+ABOUT}->{uuid} ne $uuid;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"about"}{"uuid"} and $self->{"about"}{"uuid"} ne $uuid 1 3 4
Condition100%3/3
$self->{"about"}{"uuid"} and $self->{"about"}{"uuid"} ne $uuid
!ll&&!rl&&r
211
MC/DC100%2/2
$self->{"about"}{"uuid"} and $self->{"about"}{"uuid"} ne $uuid
$self->{"about"}{"uuid"} $self->{"about"}{"uuid"} ne $uuid
Truth table100%3/3
A and B
A= $self->{"about"}{"uuid"}B= $self->{"about"}{"uuid"} ne $uuid
ABresult
0X0
100
111
33  
34 3 $self->{+ABOUT}->{uuid} = $uuid;
35 }
36 ▶ elsif ($self->{+ABOUT} && $self->{+ABOUT}->{uuid}) {
Condition100%3/3
$self->{"about"} and $self->{"about"}{"uuid"}
!ll&&!rl&&r
36541
MC/DC100%2/2
$self->{"about"} and $self->{"about"}{"uuid"}
$self->{"about"} $self->{"about"}{"uuid"}
Truth table100%3/3
A and B
A= $self->{"about"}B= $self->{"about"}{"uuid"}
ABresult
0X0
100
111
37 1 $uuid = $self->{+ABOUT}->{uuid};
38 1 $self->SUPER::set_uuid($uuid);
39 }
40  
41 # Clone the trace, make sure it is blessed
42 373 ▶ if (my $trace = $self->{+TRACE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $trace = $self->{"trace"}) 367 6 373
43 367 $self->{+TRACE} = Test2::EventFacet::Trace->new(%$trace);
44 }
45 }
46  
47 3 ▶sub set_uuid {
Subroutine set_uuid: called CC=1 SCAR=0.0
Pod documented
48 3 my $self = shift;
49 3 my ($uuid) = @_;
50 3 $self->{+ABOUT}->{uuid} = $uuid;
51 3 $self->SUPER::set_uuid($uuid);
52 }
53  
54 416 ▶sub facet_data {
Subroutine facet_data: called CC=9 SCAR=22.1
Pod documented
55 416 my $self = shift;
56 416 my $f = { %{$self} };
57  
58 416 delete $f->{$_} for $self->non_facet_keys;
59  
60 416 my %out;
61 416 for my $k (keys %$f) {
62 1663 ▶ next if substr($k, 0, 1) eq '_';
Branch: 1 branch
BranchTrueFalseTotal
if substr($k, 0, 1) eq "_" 401 1262 1663
63  
64 1262 ▶ my $data = $f->{$k} or next; # Key is there, but no facet
Branch: 1 branch
BranchTrueFalseTotal
my $data = $f->{$k} or next 1262 0 1262
65 1262 ▶ my $is_list = 'ARRAY' eq (reftype($data) || '');
Condition50%1/2
builtin::reftype($data) || ''
l!l
12620
MC/DC0%0/1
builtin::reftype($data) || ''
builtin::reftype($data)
Truth table50%1/2
A
A= builtin::reftype($data)
Aresult
11
00
66 1262 ▶ $out{$k} = $is_list ? [ map { {%{$_}} } @$data ] : {%$data};
Branch: 1 branch
BranchTrueFalseTotal
$is_list ? : 435 827 1262
67 }
68  
69 416 ▶ if (my $meta = $self->meta_facet_data) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $meta = $self->meta_facet_data) 1 415 416
70 1 ▶ $out{meta} = {%$meta, %{$out{meta} || {}}};
Condition50%1/2
$out{'meta'} || {}
l!l
01
MC/DC0%0/1
$out{'meta'} || {}
$out{'meta'}
Truth table50%1/2
A
A= $out{'meta'}
Aresult
11
00
71 }
72  
73 416 return \%out;
74 }
75  
76 455 1;
77  
78 __END__
« blib/lib/Test2/Util/Ref.pm ↑ Summary blib/lib/Test2/Tools/Tester.pm »