blib/lib/Test2/Util/Grabber.pm

filter: Statementstmt 96.6% 58 / 60 Branchbran 50.0% 3 / 6 Conditioncond 46.1% 6 / 13 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 100% 12 / 12 Podpod 75.0% 3 / 4 totaltotal 79.6% 82 / 103 CC 9 SCAR 11.8
CC
9
Cov
85%
finish
7.0
init
3.0
DESTROY
2.3
CRAP 3.2
« blib/lib/Test2/Tools/Compare.pm ↑ Summary blib/lib/Test2/EventFacet/Trace.pm »
1 package Test2::Util::Grabber;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 our $VERSION = '1.302226';
6  
7 2 ▶use Test2::Hub::Interceptor();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Test2::EventFacet::Trace();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Test2::API qw/test2_stack test2_ipc/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use Test2::Util::HashBase qw/hub finished _events term_size <state <trace/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶sub init {
Subroutine init: called CC=3 SCAR=11.0
Pod undocumented
15 2 my $self = shift;
16  
17 # Make sure we have a hub on the stack
18 2 test2_stack->top();
19  
20 2 my $hub = test2_stack->new_hub(
21 class => 'Test2::Hub::Interceptor',
22 formatter => undef,
23 no_ending => 1,
24 );
25  
26 2 $self->{+HUB} = $hub;
27  
28 2 my @events;
29 2 ▶ $hub->listen(sub { push @events => $_[1] });
Subroutine __ANON__: called CC=1 SCAR=0.0
30  
31 2 $self->{+_EVENTS} = \@events;
32  
33 2 $self->{+TERM_SIZE} = $ENV{TS_TERM_SIZE};
34 2 $ENV{TS_TERM_SIZE} = 80;
35  
36 2 ▶ my $trace = $self->{+TRACE} ||= Test2::EventFacet::Trace->new(frame => [caller(1)]);
Condition66%2/3
$self->{"trace"} ||= "Test2::EventFacet::Trace"->new("frame", [caller 1])
l!l&&r!l&&!r
110
MC/DC0%0/2
$self->{"trace"} ||= "Test2::EventFacet::Trace"->new("frame", [caller 1])
$self->{"trace"} "Test2::EventFacet::Trace"->new("frame", [caller 1])
Truth table66%2/3
A ||= B
A= $self->{"trace"}B= "Test2::EventFacet::Trace"->new("frame", [caller 1])
ABresult
1X1
011
000
37 2 ▶ my $state = $self->{+STATE} ||= {};
Condition50%1/2
$self->{"state"} ||= {}
l!l
02
MC/DC0%0/1
$self->{"state"} ||= {}
$self->{"state"}
Truth table50%1/2
A
A= $self->{"state"}
Aresult
11
00
38 2 $hub->clean_inherited(trace => $trace, state => $state);
39  
40 2 return;
41 }
42  
43 2 ▶sub flush {
Subroutine flush: called CC=1 SCAR=0.0
Pod documented
44 2 my $self = shift;
45 2 my $out = [@{$self->{+_EVENTS}}];
46 2 @{$self->{+_EVENTS}} = ();
47 2 return $out;
48 }
49  
50 2 ▶sub events {
Subroutine events: called CC=1 SCAR=0.0
Pod documented
51 2 my $self = shift;
52 # Copy
53 2 return [@{$self->{+_EVENTS}}];
54 }
55  
56 2 ▶sub finish {
Subroutine finish: called CC=6 SCAR=19.5
Pod documented
57 2 my ($self) = @_; # Do not shift;
58 2 $_[0] = undef;
59  
60 2 ▶ if (defined $self->{+TERM_SIZE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'term_size'}) { } 0 2 2
61 0 $ENV{TS_TERM_SIZE} = $self->{+TERM_SIZE};
62 }
63 else {
64 2 delete $ENV{TS_TERM_SIZE};
65 }
66  
67 2 my $hub = $self->{+HUB};
68  
69 2 $self->{+FINISHED} = 1;
70 2 test2_stack()->pop($hub);
71  
72 2 ▶ my $trace = $self->{+TRACE} ||= Test2::EventFacet::Trace->new(frame => [caller(1)]);
Condition33%1/3
$self->{"trace"} ||= "Test2::EventFacet::Trace"->new("frame", [caller 1])
l!l&&r!l&&!r
200
MC/DC0%0/2
$self->{"trace"} ||= "Test2::EventFacet::Trace"->new("frame", [caller 1])
$self->{"trace"} "Test2::EventFacet::Trace"->new("frame", [caller 1])
Truth table33%1/3
A ||= B
A= $self->{"trace"}B= "Test2::EventFacet::Trace"->new("frame", [caller 1])
ABresult
1X1
011
000
73 2 ▶ my $state = $self->{+STATE} ||= {};
Condition50%1/2
$self->{"state"} ||= {}
l!l
20
MC/DC0%0/1
$self->{"state"} ||= {}
$self->{"state"}
Truth table50%1/2
A
A= $self->{"state"}
Aresult
11
00
74 2 $hub->clean_inherited(trace => $trace, state => $state);
75  
76 2 my $dbg = Test2::EventFacet::Trace->new(
77 frame => [caller(0)],
78 );
79 2 ▶ $hub->finalize($dbg, 1)
Branch: 1 branch
BranchTrueFalseTotal
unless $hub->no_ending or $hub->state->ended 0 2 2
Condition33%1/3
$hub->no_ending or $hub->state->ended
l!l&&r!l&&!r
200
MC/DC0%0/2
$hub->no_ending or $hub->state->ended
$hub->no_ending $hub->state->ended
Truth table33%1/3
A or B
A= $hub->no_endingB= $hub->state->ended
ABresult
1X1
011
000
80 if !$hub->no_ending
81 && !$hub->state->ended;
82  
83 2 return $self->flush;
84 }
85  
86 2 ▶sub DESTROY {
Subroutine DESTROY: called CC=2 SCAR=8.1
87 2 my $self = shift;
88 2 ▶ return if $self->{+FINISHED};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"finished"} 2 0 2
89 0 test2_stack->pop($self->{+HUB});
90 }
91  
92 2 1;
93  
94 __END__
« blib/lib/Test2/Tools/Compare.pm ↑ Summary blib/lib/Test2/EventFacet/Trace.pm »