| 1 | package Test2::API::InterceptResult::Squasher; | ||||||||||||||||||||||||||||
| 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 Carp qw/croak/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 98 | ▶ | use List::Util qw/first/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 98 | ▶ | use Test2::Util::HashBase qw{ | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | <events | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | +down_sig +down_buffer | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | +up_into +up_sig +up_clear | ||||||||||||||||||||||||||||
| 16 | 98 | }; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 3 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 3 | ▶ | croak "'events' is a required attribute" unless $self->{+EVENTS}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 32 | ▶ | sub can_squash { | ||||||||||||||||||||||||||
|
Subroutine
can_squash: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 32 | my $self = shift; | |||||||||||||||||||||||||||
| 26 | 32 | my ($event) = @_; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # No info, no squash | ||||||||||||||||||||||||||||
| 29 | 32 | ▶ | return unless $event->has_info; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # Do not merge up if one of these is true | ||||||||||||||||||||||||||||
| 32 | 28 | ▶ | return if first { $event->$_ } 'causes_fail', 'has_assert', 'has_bailout', 'has_errors', 'has_plan', 'has_subtest'; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # Signature if we can squash | ||||||||||||||||||||||||||||
| 35 | 27 | return $event->trace_signature; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 28 | ▶ | sub process { | ||||||||||||||||||||||||||
|
Subroutine
process: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | 28 | my $self = shift; | |||||||||||||||||||||||||||
| 40 | 28 | my ($event) = @_; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 28 | ▶ | return if $self->squash_up($event); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 21 | ▶ | return if $self->squash_down($event); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 5 | $self->flush_down($event); | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 5 | push @{$self->{+EVENTS}} => $event; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 5 | return; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 21 | ▶ | sub squash_down { | ||||||||||||||||||||||||||
|
Subroutine
squash_down: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | 21 | my $self = shift; | |||||||||||||||||||||||||||
| 54 | 21 | my ($event) = @_; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 21 | ▶ | my $sig = $self->can_squash($event) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | or return; | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | $self->flush_down() | ||||||||||||||||||||||||||||
| 60 | 16 | ▶ | if $self->{+DOWN_SIG} && $self->{+DOWN_SIG} ne $sig; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"down_sig"} and $self->{"down_sig"} ne $sig
MC/DC100%2/2
$self->{"down_sig"} and $self->{"down_sig"} ne $sig
$self->{"down_sig"}
$self->{"down_sig"} ne $sig
Truth table100%3/3
A and B
A= $self->{"down_sig"}B= $self->{"down_sig"} ne $sig
| |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 16 | ▶ | $self->{+DOWN_SIG} ||= $sig; | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"down_sig"} ||= $sig
MC/DC0%0/2
$self->{"down_sig"} ||= $sig
$self->{"down_sig"}
$sig
Truth table66%2/3
A ||= B
A= $self->{"down_sig"}B= $sig
| |||||||||||||||||||||||||||||
| 63 | 16 | push @{$self->{+DOWN_BUFFER}} => $event; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 16 | return 1; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 17 | ▶ | sub flush_down { | ||||||||||||||||||||||||||
|
Subroutine
flush_down: called CC=7 SCAR=19.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 17 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | 17 | my ($into) = @_; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 17 | my $sig = delete $self->{+DOWN_SIG}; | |||||||||||||||||||||||||||
| 73 | 17 | my $buffer = delete $self->{+DOWN_BUFFER}; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 17 | ▶ | return unless $buffer && @$buffer; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$buffer and @$buffer
MC/DC50%1/2
$buffer and @$buffer
$buffer
@$buffer
Truth table66%2/3
A and B
A= $bufferB= @$buffer
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 14 | ▶ | my $fsig = $into ? $into->trace_signature : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 14 | ▶ | if ($fsig && $fsig eq $sig) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$fsig and $fsig eq $sig
MC/DC50%1/2
$fsig and $fsig eq $sig
$fsig
$fsig eq $sig
Truth table66%2/3
A and B
A= $fsigB= $fsig eq $sig
| |||||||||||||||||||||||||||||
| 80 | 4 | $self->squash($into, @$buffer); | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | else { | ||||||||||||||||||||||||||||
| 83 | 10 | ▶ | push @{$self->{+EVENTS}} => @$buffer if $buffer; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 28 | ▶ | sub clear_up { | ||||||||||||||||||||||||||
|
Subroutine
clear_up: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 88 | 28 | my $self = shift; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 28 | ▶ | return unless $self->{+UP_CLEAR}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 3 | delete $self->{+UP_INTO}; | |||||||||||||||||||||||||||
| 93 | 3 | delete $self->{+UP_SIG}; | |||||||||||||||||||||||||||
| 94 | 3 | delete $self->{+UP_CLEAR}; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 28 | ▶ | sub squash_up { | ||||||||||||||||||||||||||
|
Subroutine
squash_up: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 98 | 28 | my $self = shift; | |||||||||||||||||||||||||||
| 99 | 28 | my ($event) = @_; | |||||||||||||||||||||||||||
| 100 | 98 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 28 | $self->clear_up; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 28 | ▶ | if ($event->has_assert) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 5 | ▶ | if(my $sig = $event->trace_signature) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 5 | $self->{+UP_INTO} = $event; | |||||||||||||||||||||||||||
| 107 | 5 | $self->{+UP_SIG} = $sig; | |||||||||||||||||||||||||||
| 108 | 5 | $self->{+UP_CLEAR} = 0; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | else { | ||||||||||||||||||||||||||||
| 111 | 0 | $self->{+UP_CLEAR} = 1; | |||||||||||||||||||||||||||
| 112 | 0 | $self->clear_up; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 5 | return; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 23 | ▶ | my $into = $self->{+UP_INTO} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | # Next iteration should clear unless something below changes that | ||||||||||||||||||||||||||||
| 121 | 11 | $self->{+UP_CLEAR} = 1; | |||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | # Only merge into matching trace signatres | ||||||||||||||||||||||||||||
| 124 | 11 | my $sig = $self->can_squash($event); | |||||||||||||||||||||||||||
| 125 | 11 | ▶ | return unless $sig eq $self->{+UP_SIG}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | # OK Merge! Do not clear merge in case the return event is also a matching sig diag-only | ||||||||||||||||||||||||||||
| 128 | 7 | $self->{+UP_CLEAR} = 0; | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 7 | $self->squash($into, $event); | |||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 7 | return 1; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 11 | ▶ | sub squash { | ||||||||||||||||||||||||||
|
Subroutine
squash: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 136 | 11 | my $self = shift; | |||||||||||||||||||||||||||
| 137 | 11 | my ($into, @from) = @_; | |||||||||||||||||||||||||||
| 138 | 11 | push @{$into->facet_data->{info}} => $_->info for @from; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 3 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 142 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 3 | ▶ | return unless $self->{+EVENTS}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | 3 | $self->flush_down(); | |||||||||||||||||||||||||||
| 146 | 3 | return; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 98 | 1; | |||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | __END__ | ||||||||||||||||||||||||||||