blib/lib/NgxQueue/PP.pm

filter: Statementstmt 45.4% 30 / 66 Branchbran 33.3% 2 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 41.1% 7 / 17 Podpod 0.0% 0 / 11 totaltotal 37.1% 39 / 105 CC 5 SCAR 11.9
CC
5
Cov
43%
foreach
12.0
__ANON__
3.0
data
2.0
CRAP 3.3
↑ Summary blib/lib/NgxQueue.pm »
1 package NgxQueue::PP;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
8 1 my ($class, $data) = @_;
9 1 my $self = bless {data => $data}, $class;
10  
11 1 $self->prev($self);
12 1 $self->next($self);
13  
14 1 $self;
15 }
16  
17 0 ▶sub data { shift->{data} }
Subroutine data: not called CC=1 SCAR=6.9
Pod undocumented
18  
19 1 for my $accessor (qw/next prev/) {
20 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶ *{__PACKAGE__."::$accessor"} = sub {
Subroutine __ANON__: called CC=3 SCAR=11.1
22 1 ▶ use strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 my ($self, $arg) = @_;
24 2 ▶ if ($arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg) 2 0 2
25 2 $self->{$accessor} = $arg;
26 2 ▶ Scalar::Util::weaken($self->{$accessor}) if $self eq $arg;
Branch: 1 branch
BranchTrueFalseTotal
if $self eq $arg 2 0 2
27 }
28 2 $self->{$accessor};
29 2 };
30 }
31  
32 0 ▶sub empty {
Subroutine empty: not called CC=1 SCAR=6.9
Pod undocumented
33 0 my $self = shift;
34 0 $self->prev eq $self;
35 }
36  
37 0 ▶sub insert_head {
Subroutine insert_head: not called CC=1 SCAR=6.9
Pod undocumented
38 0 my ($self, $queue) = @_;
39  
40 0 $queue->next($self->next);
41 0 $queue->next->prev($queue);
42 0 $queue->prev($self);
43 0 $self->next($queue);
44 }
45 1 *insert_after = \&insert_head;
46  
47 0 ▶sub insert_tail {
Subroutine insert_tail: not called CC=1 SCAR=6.9
Pod undocumented
48 0 my ($self, $queue) = @_;
49  
50 0 $queue->prev($self->prev);
51 0 $queue->prev->next($queue);
52 0 $queue->next($self);
53 0 $self->prev($queue);
54 }
55  
56 0 ▶sub head {
Subroutine head: not called CC=1 SCAR=6.9
Pod undocumented
57 0 shift->next;
58 }
59  
60 0 ▶sub last {
Subroutine last: not called CC=1 SCAR=6.9
Pod undocumented
61 0 shift->prev;
62 }
63  
64 0 ▶sub remove {
Subroutine remove: not called CC=1 SCAR=6.9
Pod undocumented
65 0 my $self = shift;
66  
67 0 $self->next->prev($self->prev);
68 0 $self->prev->next($self->next);
69 0 $self->next(undef);
70 0 $self->prev(undef);
71 }
72  
73 0 ▶sub split {
Subroutine split: not called CC=1 SCAR=6.9
Pod undocumented
74 0 my ($self, $splitter, $new) = @_;
75  
76 0 $new->prev($self->prev);
77 0 $new->prev->next($new);
78  
79 0 $new->next($splitter);
80 0 $self->prev($splitter->prev);
81 0 $self->prev->next($self);
82  
83 0 $splitter->prev($new);
84 }
85  
86 0 ▶sub add {
Subroutine add: not called CC=1 SCAR=6.9
Pod undocumented
87 0 my ($self, $queue) = @_;
88  
89 0 $self->prev->next($queue->next);
90 0 $queue->next->prev($self->prev);
91 0 $self->prev($queue->prev);
92 0 $self->prev->next($self);
93 }
94  
95 0 ▶sub foreach {
Subroutine foreach: not called CC=3 SCAR=24.8
Pod undocumented
96 0 my ($self, $cb) = @_;
97  
98 0 ▶ for (my $q = $self->head; $q ne $self && !$self->empty; $q = $q->next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($q ne $self and not $self->empty) 0 0 0
Condition0%0/3
$q ne $self and not $self->empty
!ll&&!rl&&r
000
MC/DC0%0/2
$q ne $self and not $self->empty
$q ne $self not $self->empty
Truth table0%0/3
A and not(B)
A= $q ne $selfB= not $self->empty
ABresult
0X0
100
111
99 0 local $_ = $q;
100 0 $cb->();
101 }
102 }
103  
104 1 1;
105  
106 __END__
↑ Summary blib/lib/NgxQueue.pm »