blib/lib/Test2/Hub/Interceptor.pm

filter: Statementstmt 91.0% 61 / 67 Branchbran 75.0% 18 / 24 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 5 totaltotal 80.1% 93 / 116 CC 19 SCAR 17.6
CC
19
Cov
85%
inherit
8.8
clean_inherited
7.1
restore_inherited
7.1
CRAP 5.8
« blib/lib/Test2/Compare/Delta.pm ↑ Summary blib/lib/Test2/Tools/AsyncSubtest.pm »
1 package Test2::Hub::Interceptor;
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::Interceptor::Terminator();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 455 ▶BEGIN { require Test2::Hub; our @ISA = qw(Test2::Hub) }
Subroutine BEGIN: called CC=1 SCAR=0.0
11 455 ▶use Test2::Util::HashBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 412 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
14 412 my $self = shift;
15 412 $self->SUPER::init();
16 412 $self->{+NESTED} = 0;
17 }
18  
19 411 ▶sub inherit {
Subroutine inherit: called CC=7 SCAR=21.8
Pod undocumented
20 411 my $self = shift;
21 411 my ($from, %params) = @_;
22  
23 411 $self->{+NESTED} = 0;
24  
25 411 ▶ if ($from->{+IPC} && !$self->{+IPC} && !exists($params{ipc})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($from->{"ipc"} and not $self->{"ipc"} and not exists $params{"ipc"}) 0 411 411
Condition50%3/6
$from->{"ipc"} and not $self->{"ipc"} and not exists $params{"ipc"}
!ll&&!rl&&r
41100
$from->{"ipc"} and not $self->{"ipc"}
!ll&&!rl&&r
2821290
MC/DC0%0/3
$from->{"ipc"} and not $self->{"ipc"} and not exists $params{"ipc"}
$from->{"ipc"} not $self->{"ipc"} not exists $params{"ipc"}
Truth table50%2/4
A and not(B) and not(C)
A= $from->{"ipc"}B= not $self->{"ipc"}C= not exists $params{"ipc"}
ABCresult
0XX0
10X0
1100
1111
26 0 my $ipc = $from->{+IPC};
27 0 $self->{+IPC} = $ipc;
28 0 $ipc->add_hub($self->{+HID});
29 }
30  
31 411 ▶ if (my $ls = $from->{+_LISTENERS}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ls = $from->{"_listeners"}) 244 167 411
32 244 push @{$self->{+_LISTENERS}} => grep { $_->{intercept_inherit} } @$ls;
33 }
34  
35 411 ▶ if (my $pfs = $from->{+_PRE_FILTERS}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pfs = $from->{"_pre_filters"}) 28 383 411
36 28 push @{$self->{+_PRE_FILTERS}} => grep { $_->{intercept_inherit} } @$pfs;
37 }
38  
39 411 ▶ if (my $fs = $from->{+_FILTERS}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $fs = $from->{"_filters"}) 0 411 411
40 0 push @{$self->{+_FILTERS}} => grep { $_->{intercept_inherit} } @$fs;
41 }
42 }
43  
44 413 ▶sub clean_inherited {
Subroutine clean_inherited: called CC=7 SCAR=19.6
Pod undocumented
45 413 my $self = shift;
46 413 my %params = @_;
47  
48 my @sets = (
49 $self->{+_LISTENERS},
50 $self->{+_PRE_FILTERS},
51 413 $self->{+_FILTERS},
52 );
53  
54 413 for my $set (@sets) {
55 1239 ▶ next unless $set;
Branch: 1 branch
BranchTrueFalseTotal
unless $set 798 441 1239
56  
57 441 for my $i (@$set) {
58 440 ▶ my $cbs = $i->{intercept_inherit} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $cbs = $i->{"intercept_inherit"} or next 27 413 440
59 27 ▶ next unless ref($cbs) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cbs eq "HASH" 0 27 27
60 27 ▶ my $cb = $cbs->{clean} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $cb = $cbs->{"clean"} or next 27 0 27
61 27 $cb->(%params);
62 }
63 }
64 }
65  
66 404 ▶sub restore_inherited {
Subroutine restore_inherited: called CC=7 SCAR=19.6
Pod undocumented
67 404 my $self = shift;
68 404 my %params = @_;
69  
70 my @sets = (
71 $self->{+_FILTERS},
72 $self->{+_PRE_FILTERS},
73 404 $self->{+_LISTENERS},
74 );
75  
76 404 for my $set (@sets) {
77 1212 ▶ next unless $set;
Branch: 1 branch
BranchTrueFalseTotal
unless $set 777 435 1212
78  
79 435 for my $i (@$set) {
80 434 ▶ my $cbs = $i->{intercept_inherit} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $cbs = $i->{"intercept_inherit"} or next 29 405 434
81 29 ▶ next unless ref($cbs) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cbs eq "HASH" 0 29 29
82 29 ▶ my $cb = $cbs->{restore} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $cb = $cbs->{"restore"} or next 29 0 29
83 29 $cb->(%params);
84 }
85 }
86 }
87  
88 17 ▶sub terminate {
Subroutine terminate: called CC=1 SCAR=0.0
Pod undocumented
89 17 my $self = shift;
90 17 my ($code) = @_;
91  
92 17 eval {
93 455 ▶ no warnings 'exiting';
Subroutine BEGIN: called CC=1 SCAR=0.0
94 17 last T2_SUBTEST_WRAPPER;
95 };
96 1 my $err = $@;
97  
98 # Fallback
99 1 die bless(\$err, 'Test2::Hub::Interceptor::Terminator');
100 }
101  
102 455 1;
103  
104 __END__
« blib/lib/Test2/Compare/Delta.pm ↑ Summary blib/lib/Test2/Tools/AsyncSubtest.pm »