Stream/Iterator/Compare/LayerCake.pm

filter: Statementstmt 96.7% 59 / 61 Branchbran 88.8% 32 / 36 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 7 / 7 Podpod 25.0% 1 / 4 totaltotal 88.9% 105 / 118 CC 21 SCAR 20.0
CC
21
Cov
92%
has_next
11.0
get_next
7.0
prepare
5.2
CRAP 7.4
« Stream/Iterator/Compare/Asc.pm ↑ Summary Stream/Iterator/File/MergeSortAsc.pm »
1 package Data::Range::Compare::Stream::Iterator::Compare::LayerCake;
2  
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use base qw(Data::Range::Compare::Stream::Iterator::Compare::Asc);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 18 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
10 18 my ($class,%args)=@_;
11 18 %args=(ignore_empty=>0,,%args);
12 18 my $self=$class->SUPER::new(%args);
13  
14 18 return $self;
15 }
16  
17 94 ▶sub get_next {
Subroutine get_next: called CC=7 SCAR=19.5
Pod documented
18 94 my ($self)=@_;
19  
20 94 ▶ if(defined($self->{filter})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"filter"}) 2 92 94
21 2 my $result=$self->{next_result};
22 2 delete $self->{next_result};
23 2 return $result;
24 }
25  
26 92 ▶ if($self->{ignore_full}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ignore_full"}) 4 88 92
27 4 my $result=$self->{next_result};
28 4 delete $self->{next_result};
29 4 return $result;
30 }
31  
32 88 ▶ return $self->SUPER::get_next unless $self->{ignore_empty} or $self->{empty_only};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"ignore_empty"} or $self->{"empty_only"} 76 12 88
Condition66%2/3
$self->{"ignore_empty"} or $self->{"empty_only"}
l!l&&r!l&&!r
12076
MC/DC50%1/2
$self->{"ignore_empty"} or $self->{"empty_only"}
$self->{"ignore_empty"} $self->{"empty_only"}
Truth table66%2/3
A or B
A= $self->{"ignore_empty"}B= $self->{"empty_only"}
ABresult
1X1
011
000
33  
34  
35  
36 12 my $result=$self->SUPER::get_next;
37  
38 12 ▶ while($result->is_empty and $self->has_next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_empty and $self->has_next) 2 12 14
Condition66%2/3
$result->is_empty and $self->has_next
!ll&&!rl&&r
1202
MC/DC50%1/2
$result->is_empty and $self->has_next
$result->is_empty $self->has_next
Truth table66%2/3
A and B
A= $result->is_emptyB= $self->has_next
ABresult
0X0
100
111
39 2 $result=$self->SUPER::get_next;
40 }
41  
42 12 return $result;
43  
44 }
45  
46 44 ▶sub prepare {
Subroutine prepare: called CC=5 SCAR=16.5
Pod undocumented
47 44 my ($self)=@_;
48  
49 44 ▶ return if $self->prepared;
Branch: 1 branch
BranchTrueFalseTotal
if $self->prepared 27 17 44
50  
51 17 $self->SUPER::prepare;
52 17 ▶ if(defined($self->{filter})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"filter"}) 1 16 17
53 1 my $filter=$self->{filter};
54  
55  
56 1 ▶ while($self->SUPER::has_next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->SUPER::has_next) 1 0 1
57 1 my $result=$self->SUPER::get_next;
58 1 ▶ if($filter->($result)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$filter($result)) 1 0 1
59 1 $self->{next_result}=$result;
60 1 return 1;
61 }
62 }
63 0 delete $self->{next_result};
64 0 return 0;
65  
66 }
67  
68 }
69  
70 43 ▶sub has_next {
Subroutine has_next: called CC=11 SCAR=24.0
Pod undocumented
71 43 my ($self)=@_;
72  
73 43 $self->prepare;
74
75 43 ▶ if(defined($self->{filter})) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'filter'}) { } 3 40 43
elsif ($self->{'ignore_full'}) { } 6 34 40
76 3 my $filter=$self->{filter};
77  
78 3 ▶ return 1 if defined($self->{next_result});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"next_result"} 1 2 3
79  
80  
81 2 ▶ while($self->SUPER::has_next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->SUPER::has_next) 4 1 5
82 4 my $result=$self->SUPER::get_next;
83 4 ▶ if($filter->($result)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$filter($result)) 1 3 4
84 1 $self->{next_result}=$result;
85 1 return 1;
86 }
87 }
88 1 delete $self->{next_result};
89 1 return 0;
90  
91 } elsif($self->{ignore_full}) {
92 6 ▶ return 1 if defined($self->{next_result});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"next_result"} 0 6 6
93  
94 6 ▶ return 0 unless $self->SUPER::has_next;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->SUPER::has_next 1 5 6
95  
96 5 my $result=$self->SUPER::get_next;
97 5 ▶ while($result->is_full) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_full) 4 4 8
98  
99 4 ▶ return 0 unless $self->SUPER::has_next;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->SUPER::has_next 1 3 4
100 3 $result=$self->SUPER::get_next;
101  
102 }
103  
104 4 $self->{next_result}=$result;
105 4 ▶ return defined($result) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $result ? : 4 0 4
106  
107 } else {
108
109 # back off and use the parrent class internals
110 34 return $self->SUPER::has_next;
111 }
112  
113  
114 }
115  
116 1 1;
« Stream/Iterator/Compare/Asc.pm ↑ Summary Stream/Iterator/File/MergeSortAsc.pm »