| 1 | package PMLTQ::Relation::OptionalIterator; | ||||||||||||||||||||
| 2 | 12 | our $AUTHORITY = 'cpan:MATY'; | |||||||||||||||||||
| 3 | 12 | $PMLTQ::Relation::OptionalIterator::VERSION = '1.2.2'; | |||||||||||||||||||
| 4 | # ABSTRACT: Creates optional interator branch | ||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 12 | ▶ | use 5.006; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 12 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 12 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 12 | ▶ | use base qw(PMLTQ::Relation::Iterator); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 12 | ▶ | use constant CONDITIONS=>0; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 12 | ▶ | use constant ITERATOR=>1; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 12 | ▶ | use constant NODE=>2; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 12 | ▶ | use constant FILE=>3; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 12 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | sub new { | ||||||||||||||||||||
| 18 | 0 | ▶ | my ($class,$iterator)=@_; | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 19 | 0 | ▶ | croak "usage: $class->new(\$iterator)" unless UNIVERSAL::DOES::does($iterator,'PMLTQ::Relation::Iterator'); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 20 | 0 | return bless [$iterator->conditions,$iterator],$class; | |||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | sub clone { | ||||||||||||||||||||
| 23 | 0 | ▶ | my ($self)=@_; | ||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 24 | 0 | return bless [$self->[CONDITIONS],$self->[ITERATOR]], ref($self); | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | sub start { | ||||||||||||||||||||
| 27 | 0 | ▶ | my ($self,$parent,$fsfile)=@_; | ||||||||||||||||||
|
Subroutine
start: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 28 | 0 | $self->[NODE]=$parent; | |||||||||||||||||||
| 29 | 0 | $self->[FILE]=$fsfile; | |||||||||||||||||||
| 30 | 0 | ▶ | return $parent ? ($self->[CONDITIONS]->($parent,$fsfile) ? $parent : $self->next) : undef; | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | sub next { | ||||||||||||||||||||
| 33 | 0 | ▶ | my ($self)=@_; | ||||||||||||||||||
|
Subroutine
next: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 34 | 0 | my $n = $self->[NODE]; | |||||||||||||||||||
| 35 | 0 | ▶ | if ($n) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | 0 | $self->[NODE]=undef; | |||||||||||||||||||
| 37 | 0 | return $self->[ITERATOR]->start($n,$self->[FILE]); | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | 0 | return $self->[ITERATOR]->next; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | sub node { | ||||||||||||||||||||
| 42 | 0 | ▶ | my ($self)=@_; | ||||||||||||||||||
|
Subroutine
node: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 43 | 0 | ▶ | return $self->[NODE] || $self->[ITERATOR]->node; | ||||||||||||||||||
|
Condition0%0/3
$self->[2] || $self->[1]->node
MC/DC0%0/2
$self->[2] || $self->[1]->node
$self->[2]
$self->[1]->node
Truth table0%0/3
A || B
A= $self->[2]B= $self->[1]->node
| |||||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | sub file { | ||||||||||||||||||||
| 46 | 0 | ▶ | return $_[0]->[FILE]; | ||||||||||||||||||
|
Subroutine
file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | sub reset { | ||||||||||||||||||||
| 49 | 0 | ▶ | my ($self)=@_; | ||||||||||||||||||
|
Subroutine
reset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 50 | 0 | $self->[NODE]=undef; | |||||||||||||||||||
| 51 | 0 | $self->[FILE]=undef; | |||||||||||||||||||
| 52 | 0 | $self->[ITERATOR]->reset; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 12 | 1; # End of PMLTQ::Relation::OptionalIterator | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | __END__ | ||||||||||||||||||||