| 1 | package Test2::API::InterceptResult; | ||||||||||||||||||||||||||||||||||||||||||
| 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 Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 98 | ▶ | use Test2::Util qw/pkg_to_file/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 98 | ▶ | use Storable qw/dclone/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 98 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 98 | ▶ | use Test2::API::InterceptResult::Squasher; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 98 | ▶ | use Test2::API::InterceptResult::Event; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 98 | ▶ | use Test2::API::InterceptResult::Hub; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 7 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 7 | ▶ | croak "Called a method that creates a new instance in void context" unless defined wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 7 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 7 | bless([@_], $class); | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 425 | ▶ | sub new_from_ref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_from_ref: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 425 | ▶ | croak "Called a method that creates a new instance in void context" unless defined wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 424 | bless($_[1], $_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | sub clone { blessed($_[0])->new(@{dclone($_[0])}) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | sub event_list { @{$_[0]} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
event_list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 122 | ▶ | sub _upgrade { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_upgrade: called CC=10 SCAR=23.1
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 122 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 122 | my ($event, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 122 | my $blessed = blessed($event); | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 122 | ▶ | my $upgrade_class = $params{upgrade_class} ||= 'Test2::API::InterceptResult::Event'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params{"upgrade_class"} ||= "Test2::API::InterceptResult::Event"
MC/DC100%1/1
$params{"upgrade_class"} ||= "Test2::API::InterceptResult::Event"
$params{"upgrade_class"}
Truth table100%2/2
A
A= $params{"upgrade_class"}
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 122 | ▶ | return $event if $blessed && $event->isa($upgrade_class) && !$params{_upgrade_clone}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$blessed and $event->isa($upgrade_class) and not $params{"_upgrade_clone"}
$blessed and $event->isa($upgrade_class)
MC/DC100%3/3
$blessed and $event->isa($upgrade_class) and not $params{"_upgrade_clone"}
$blessed
$event->isa($upgrade_class)
not $params{"_upgrade_clone"}
Truth table100%4/4
A and B and not(C)
A= $blessedB= $event->isa($upgrade_class)C= not $params{"_upgrade_clone"}
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 68 | ▶ | my $fd = dclone($blessed ? $event->facet_data : $event); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 68 | ▶ | my $class = $params{result_class} ||= blessed($self); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$params{"result_class"} ||= builtin::blessed($self)
MC/DC0%0/2
$params{"result_class"} ||= builtin::blessed($self)
$params{"result_class"}
builtin::blessed($self)
Truth table66%2/3
A ||= B
A= $params{"result_class"}B= builtin::blessed($self)
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 68 | ▶ | if (my $parent = $fd->{parent}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | ▶ | $parent->{children} = $class->new_from_ref($parent->{children} || [])->upgrade(%params); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$parent->{'children'} || []
MC/DC0%0/1
$parent->{'children'} || []
$parent->{'children'}
Truth table50%1/2
A
A= $parent->{'children'}
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 68 | my $uc_file = pkg_to_file($upgrade_class); | |||||||||||||||||||||||||||||||||||||||||
| 50 | 68 | ▶ | require($uc_file) unless $INC{$uc_file}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 68 | return $upgrade_class->new(facet_data => $fd, result_class => $class); | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | ▶ | sub hub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hub: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | my $hub = Test2::API::InterceptResult::Hub->new(); | |||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | $hub->process($_) for @$self; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | $hub->set_ended(1); | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | return $hub; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | ▶ | sub state { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | my $hub = $self->hub; | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | my $out = { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | map {($_ => scalar $hub->$_)} qw/count failed is_passing plan bailed_out skip_reason/ | |||||||||||||||||||||||||||||||||||||||||
| 72 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | $out->{bailed_out} = $self->_upgrade($out->{bailed_out}, %params)->bailout_reason || 1 | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 3 | ▶ | if $out->{bailed_out}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->_upgrade($out->{'bailed_out'}, %params)->bailout_reason || 1
MC/DC0%0/1
$self->_upgrade($out->{'bailed_out'}, %params)->bailout_reason || 1
$self->_upgrade($out->{'bailed_out'}, %params)->bailout_reason
Truth table0%0/2
A
A= $self->_upgrade($out->{'bailed_out'}, %params)->bailout_reason
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 3 | $out->{follows_plan} = $hub->check_plan; | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 14 | ▶ | sub upgrade { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upgrade: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 14 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 14 | my @out = map { $self->_upgrade($_, %params, _upgrade_clone => 1) } @$self; | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | return blessed($self)->new_from_ref(\@out) | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 14 | ▶ | unless $params{in_place}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 4 | @$self = @out; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | sub squash_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
squash_info: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | my @out; | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | my $squasher = Test2::API::InterceptResult::Squasher->new(events => \@out); | |||||||||||||||||||||||||||||||||||||||||
| 103 | # Clone to make sure we do not indirectly modify an existing one if it | ||||||||||||||||||||||||||||||||||||||||||
| 104 | # is already upgraded | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | $squasher->process($self->_upgrade($_, %params)->clone) for @$self; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | $squasher->flush_down(); | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | return blessed($self)->new_from_ref(\@out) | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 2 | ▶ | unless $params{in_place}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | @$self = @out; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | sub asserts { shift->grep(has_assert => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
asserts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | sub subtests { shift->grep(has_subtest => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subtests: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | sub diags { shift->grep(has_diags => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diags: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | sub notes { shift->grep(has_notes => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | ▶ | sub errors { shift->grep(has_errors => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
errors: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | ▶ | sub plans { shift->grep(has_plan => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plans: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub causes_fail { shift->grep(causes_fail => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
causes_fail: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub causes_failure { shift->grep(causes_failure => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
causes_failure: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | ▶ | sub flatten { shift->map(flatten => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flatten: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | ▶ | sub briefs { shift->map(brief => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
briefs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | ▶ | sub summaries { shift->map(summary => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
summaries: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | ▶ | sub subtest_results { shift->map(subtest_result => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subtest_results: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | ▶ | sub diag_messages { shift->map(diag_messages => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_messages: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | ▶ | sub note_messages { shift->map(note_messages => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
note_messages: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | ▶ | sub error_messages { shift->map(error_messages => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_messages: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 98 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 8 | ▶ | *map = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 8 | my ($call, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 8 | ▶ | my $args = $params{args} ||= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$params{"args"} ||= []
MC/DC0%0/1
$params{"args"} ||= []
$params{"args"}
Truth table50%1/2
A
A= $params{"args"}
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 8 | return [map { local $_ = $self->_upgrade($_, %params); $_->$call(@$args) } @$self]; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 98 | }; | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 7 | ▶ | *grep = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 7 | my ($call, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 7 | ▶ | my $args = $params{args} ||= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$params{"args"} ||= []
MC/DC0%0/1
$params{"args"} ||= []
$params{"args"}
Truth table50%1/2
A
A= $params{"args"}
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 7 | my @out = grep { local $_ = $self->_upgrade($_, %params); $_->$call(@$args) } @$self; | |||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | return blessed($self)->new_from_ref(\@out) | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 7 | ▶ | unless $params{in_place}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | @$self = @out; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 98 | }; | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 98 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | __END__ | ||||||||||||||||||||||||||||||||||||||||||