Stream/Iterator/Consolidate/AdjacentAsc.pm

filter: Statementstmt 100% 38 / 38 Branchbran 93.7% 15 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 50.0% 1 / 2 totaltotal 96.7% 59 / 61 CC 9 SCAR 15.5
CC
9
Cov
98%
get_next
7.0
has_next
3.0
BEGIN
1.0
CRAP 4.7
« Stream/Iterator/File/MergeSortAsc.pm ↑ Summary Stream/Iterator/Consolidate/FillMissing.pm »
1 package Data::Range::Compare::Stream::Iterator::Consolidate::AdjacentAsc;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use base qw(Data::Range::Compare::Stream::Iterator::Consolidate);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 28 ▶sub has_next {
Subroutine has_next: called CC=3 SCAR=11.0
Pod undocumented
9 28 my ($self)=@_;
10 28 ▶ return 1 if $self->SUPER::has_next;
Branch: 1 branch
BranchTrueFalseTotal
if $self->SUPER::has_next 19 9 28
11 9 ▶ return 1 if defined($self->{last_result});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"last_result"} 2 7 9
12 7 return 0;
13 }
14  
15 8 ▶sub get_next {
Subroutine get_next: called CC=7 SCAR=19.5
Pod documented
16 8 my ($self)=@_;
17 8 ▶ return undef unless $self->has_next;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_next 1 7 8
18
19 7 my $result;
20 7 ▶ if(defined($self->{last_result})) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'last_result'}) { } 3 4 7
elsif ($self->SUPER::has_next) { } 4 0 4
21 3 $result=$self->{last_result};
22 } elsif($self->SUPER::has_next) {
23 4 $result=$self->SUPER::get_next;
24 }
25  
26 7 ▶ while($self->has_next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_next) 12 3 15
27 12 my $last_result;
28 12 ▶ if($self->SUPER::has_next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->SUPER::has_next) { } 11 1 12
29 11 $last_result=$self->SUPER::get_next;
30 } else {
31 1 $self->{last_result}=undef;
32 1 return $result;
33 }
34  
35
36 # get our common result range
37 11 my $common=$result->get_common;
38 11 my $next=$last_result->get_common;
39  
40 # stop here if the contiguous check turns up nothing
41
42 11 ▶ unless($common->contiguous_check($next)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($common->contiguous_check($next)) 3 8 11
43 3 $self->{last_result}=$last_result;
44 3 return $result
45 }
46  
47 # if we got here then we need to get the starting range
48  
49 # compute the overlap
50 8 my $overlap=$common->get_overlapping_range([$common,$next]);
51 8 $self->on_consolidate($overlap,$common,$next);
52  
53 8 my ($start,$end)=$common->find_smallest_outer_ranges([$result->get_start->get_common,$result->get_end->get_common,$last_result->get_start->get_common,$last_result->get_end->get_common]);
54  
55 # get our new result
56 8 $result=$self->RESULT_CLASS->new($overlap,$start->get_common,$end->get_common,0,1);
57  
58 # update the internals
59 8 $self->{last_result}=undef;
60  
61  
62 }
63
64 3 $self->{last_result}=undef;
65 3 return $result;
66 }
67  
68 3 1;
« Stream/Iterator/File/MergeSortAsc.pm ↑ Summary Stream/Iterator/Consolidate/FillMissing.pm »