| 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])
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])
| |||||||||||||||||||||||||||||
| 37 | 2 | ▶ | my $state = $self->{+STATE} ||= {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"state"} ||= {}
MC/DC0%0/1
$self->{"state"} ||= {}
$self->{"state"}
Truth table50%1/2
A
A= $self->{"state"}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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])
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])
| |||||||||||||||||||||||||||||
| 73 | 2 | ▶ | my $state = $self->{+STATE} ||= {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"state"} ||= {}
MC/DC0%0/1
$self->{"state"} ||= {}
$self->{"state"}
Truth table50%1/2
A
A= $self->{"state"}
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
$hub->no_ending or $hub->state->ended
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 89 | 0 | test2_stack->pop($self->{+HUB}); | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 2 | 1; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | __END__ | ||||||||||||||||||||||||||||