| 1 | package Test2::API::Stack; | ||||||||||||||||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 455 | ▶ | use Test2::Hub(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 455 | ▶ | use Carp qw/confess/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 612 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 612 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 612 | return bless [], $class; | |||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1061 | ▶ | sub new_hub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_hub: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1061 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 1061 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1061 | ▶ | my $class = delete $params{class} || 'Test2::Hub'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $params{'class'} || 'Test2::Hub'
MC/DC100%1/1
delete $params{'class'} || 'Test2::Hub'
delete $params{'class'}
Truth table100%2/2
A
A= delete $params{'class'}
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1061 | my $hub = $class->new(%params); | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1061 | ▶ | if (@$self) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 541 | $hub->inherit($self->[-1], %params); | |||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 520 | require Test2::API; | |||||||||||||||||||||||||||||||||||||||||
| 30 | $hub->format(Test2::API::test2_formatter()->new_root) | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 520 | ▶ | unless $hub->format || exists($params{formatter}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$hub->format or exists $params{"formatter"}
MC/DC50%1/2
$hub->format or exists $params{"formatter"}
$hub->format
exists $params{"formatter"}
Truth table66%2/3
A or B
A= $hub->formatB= exists $params{"formatter"}
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 520 | my $ipc = Test2::API::test2_ipc(); | |||||||||||||||||||||||||||||||||||||||||
| 34 | 520 | ▶ | if ($ipc && !$hub->ipc && !exists($params{ipc})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$ipc and not $hub->ipc and not exists $params{"ipc"}
$ipc and not $hub->ipc
MC/DC33%1/3
$ipc and not $hub->ipc and not exists $params{"ipc"}
$ipc
not $hub->ipc
not exists $params{"ipc"}
Truth table50%2/4
A and not(B) and not(C)
A= $ipcB= not $hub->ipcC= not exists $params{"ipc"}
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 116 | $hub->set_ipc($ipc); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 116 | $ipc->add_hub($hub->hid); | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 1061 | push @$self => $hub; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 1061 | $hub; | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 4339 | ▶ | sub top { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 4339 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 4339 | ▶ | return $self->new_hub unless @$self; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 3866 | return $self->[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | ▶ | sub peek { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peek: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | return @$self ? $self->[-1] : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | sub cull { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cull: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | $_->cull for reverse @$self; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 618 | ▶ | sub all { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 618 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 618 | return @$self; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 456 | ▶ | sub root { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
root: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 456 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 456 | ▶ | return unless @$self; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 454 | return $self->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | sub clear { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | @$self = (); | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | # Do these last without keywords in order to prevent them from getting used | ||||||||||||||||||||||||||||||||||||||||||
| 78 | # when we want the real push/pop. | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 455 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 663 | ▶ | *push = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 663 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 663 | my ($hub) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 663 | ▶ | $hub->inherit($self->[-1]) if @$self; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 663 | push @$self => $hub; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 455 | }; | |||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 1150 | ▶ | *pop = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1150 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 1150 | my ($hub) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 1150 | ▶ | confess "No hubs on the stack" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | unless @$self; | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 1149 | ▶ | confess "You cannot pop the root hub" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | if 1 == @$self; | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 1148 | ▶ | confess "Hub stack mismatch, attempted to pop incorrect hub" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | unless $self->[-1] == $hub; | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 1147 | pop @$self; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 455 | }; | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 455 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | __END__ | ||||||||||||||||||||||||||||||||||||||||||