blib/lib/PMLTQ/Relation/CurrentFileIterator.pm

filter: Statementstmt 50.0% 40 / 80 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 24 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 63.1% 12 / 19 Podpod 0.0% 0 / 6 totaltotal 33.1% 52 / 157 CC 17 SCAR 37.0
CC
17
Cov
33%
next
90.0
_next_file
72.0
new
6.0
CRAP 40.5
« blib/lib/PMLTQ/Command/init.pm ↑ Summary blib/lib/PMLTQ/Relation/AncestorIteratorWithBoundedDepth.pm »
1 package PMLTQ::Relation::CurrentFileIterator;
2 15 our $AUTHORITY = 'cpan:MATY';
3 15 $PMLTQ::Relation::CurrentFileIterator::VERSION = '1.2.2';
4 # ABSTRACT: Iterates nodes of TredMacro::CurrentFile()
5  
6 15 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 15 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 ▶use base qw(PMLTQ::Relation::Iterator);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 15 ▶use constant CONDITIONS=>0;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 15 ▶use constant NODE=>1;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 15 ▶use constant FILE=>2;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 15 ▶use constant TREE_NO=>3;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 15 ▶use constant SCHEMA_ROOT_NAME=>4;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 15 ▶use constant FILE_QUEUE=>5;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 15 ▶use constant FIRST_FREE=>6;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 15 our $PROGRESS; ### newly added
21 15 our $STOP; ### newly added
22  
23 sub new {
24 0 ▶ my ($class,$conditions,$schema_root_name)=@_;
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
25 0 ▶ croak "usage: $class->new(sub{...})" unless ref($conditions) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $conditions eq "CODE" 0 0 0
26 0 return bless [$conditions,undef,undef,0,$schema_root_name,[]],$class;
27 }
28 sub _next_file {
29 0 ▶ my ($self)=@_;
Subroutine _next_file: not called CC=8 SCAR=42.8
30 0 my $f;
31 0 my $schema_name = $self->[SCHEMA_ROOT_NAME];
32 0 ▶ while (@{$self->[FILE_QUEUE]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->[5];}) 0 0 0
33 0 $f = shift @{$self->[FILE_QUEUE]};
34 0 ▶ if ($f) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f) 0 0 0
35 0 push @{$self->[FILE_QUEUE]}, TredMacro::GetSecondaryFiles($f);
36 0 ▶ if (!defined($schema_name) or $schema_name eq PML::SchemaName($f)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $schema_name or $schema_name eq PML::SchemaName($f)) 0 0 0
Condition0%0/3
not defined $schema_name or $schema_name eq PML::SchemaName($f)
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $schema_name or $schema_name eq PML::SchemaName($f)
not defined $schema_name $schema_name eq PML::SchemaName($f)
Truth table0%0/3
not(A) or B
A= not defined $schema_nameB= $schema_name eq PML::SchemaName($f)
ABresult
1X1
011
000
37 0 $self->[FILE]=$f;
38 0 $self->[TREE_NO]=0;
39 0 my $n = $self->[NODE] = $f->tree(0);
40 0 ▶ return ($n && $self->[CONDITIONS]->($n,$f)) ? $n : ($n && $self->next)
Branch: 1 branch
BranchTrueFalseTotal
$n && $self->[0]->($n, $f) ? : 0 0 0
Condition0%0/6
$n and $self->[0]->($n, $f)
!ll&&!rl&&r
000
$n and $self->next
!ll&&!rl&&r
000
MC/DC0%0/2
$n and $self->[0]->($n, $f)
$n $self->[0]->($n, $f)
MC/DC0%0/2
$n and $self->next
$n $self->next
Truth table0%0/3
A and B
A= $nB= $self->[0]->($n, $f)
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $nB= $self->next
ABresult
0X0
100
111
41 }
42 }
43 }
44 0 return;
45 }
46 sub start {
47 0 ▶ my ($self)=@_;
Subroutine start: not called CC=1 SCAR=6.9
Pod undocumented
48 0 $self->[TREE_NO]=0;
49 0 $self->[FILE_QUEUE] = [ TredMacro::CurrentFile() ];
50 0 return $self->_next_file();
51 }
52 sub next {
53 0 ▶ my ($self)=@_;
Subroutine next: not called CC=9 SCAR=45.0
Pod undocumented
54 0 my $conditions=$self->[CONDITIONS];
55 0 my $n=$self->[NODE];
56 0 my $f=$self->[FILE];
57 0 ▶ while ($n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n) 0 0 0
58 0 ▶ $n = $n->following || (($PROGRESS ? $PROGRESS->() : 1) && $STOP && do { $n = undef; last }) || $f->tree(++$self->[TREE_NO]) || $self->_next_file();
Branch: 1 branch
BranchTrueFalseTotal
$PMLTQ::Relation::CurrentFileIterator::PROGRESS ? : 0 0 0
Condition0%0/15
$n->following || ($PMLTQ::Relation::CurrentFileIterator::PROGRESS ? &$PMLTQ::Relation::CurrentFileIterator::PROGRESS() : 1) && $PMLTQ::Relation::CurrentFileIterator::STOP && do { $n = undef; last } || $f->tree(++$self->[3]) || $self->_next_file
l!l&&r!l&&!r
000
$n->following or $PMLTQ::Relation::CurrentFileIterator::PROGRESS ? &$PMLTQ::Relation::CurrentFileIterator::PROGRESS() : 1 and $PMLTQ::Relation::CurrentFileIterator::STOP and do { $n = undef; last } or $f->tree(++$self->[3])
l!l&&r!l&&!r
000
$n->following or $PMLTQ::Relation::CurrentFileIterator::PROGRESS ? &$PMLTQ::Relation::CurrentFileIterator::PROGRESS() : 1 and $PMLTQ::Relation::CurrentFileIterator::STOP and do { $n = undef; last }
l!l&&r!l&&!r
000
$PMLTQ::Relation::CurrentFileIterator::PROGRESS ? &$PMLTQ::Relation::CurrentFileIterator::PROGRESS() : 1 and $PMLTQ::Relation::CurrentFileIterator::STOP and do { $n = undef; last }
!ll&&!rl&&r
000
$PMLTQ::Relation::CurrentFileIterator::PROGRESS ? &$PMLTQ::Relation::CurrentFileIterator::PROGRESS() : 1 and $PMLTQ::Relation::CurrentFileIterator::STOP
!ll&&!rl&&r
000
MC/DC0%0/6
$n->following || ($PMLTQ::Relation::CurrentFileIterator::PROGRESS ? &$PMLTQ::Relation::CurrentFileIterator::PROGRESS() : 1) && $PMLTQ::Relation::CurrentFileIterator::STOP && do { $n = undef; last } || $f->tree(++$self->[3]) || $self->_next_file
$n->following $PMLTQ::Relation::CurrentFileIterator::PROGRESS ? &$PMLTQ::Relation::CurrentFileIterator::PROGRESS() : 1 $PMLTQ::Relation::CurrentFileIterator::STOP do { $n = undef; last } $f->tree(++$self->[3]) $self->_next_file
Truth table0%0/11
A or B and C and D or E || F
A= $n->followingB= $PMLTQ::Relation::CurrentFileIterator::PROGRESS ? &$PMLTQ::Relation::CurrentFileIterator::PROGRESS() : 1C= $PMLTQ::Relation::CurrentFileIterator::STOPD= do { $n = undef; last }E= $f->tree(++$self->[3])F= $self->_next_file
ABCDEFresult
1XXXXX1
0111XX1
00XX1X1
010X1X1
01101X1
00XX011
010X011
0110011
00XX000
010X000
0110000
59 0 ▶ last if $conditions->($n,$f);
Branch: 1 branch
BranchTrueFalseTotal
if &$conditions($n, $f) 0 0 0
60 }
61 0 return $self->[NODE]=$n;
62 }
63 sub file {
64 0 ▶ return $_[0]->[FILE];
Subroutine file: not called CC=1 SCAR=6.9
Pod undocumented
65 }
66 sub node {
67 0 ▶ return $_[0]->[NODE];
Subroutine node: not called CC=1 SCAR=6.9
Pod undocumented
68 }
69 sub reset {
70 0 ▶ my ($self)=@_;
Subroutine reset: not called CC=1 SCAR=6.9
Pod undocumented
71 0 $self->[NODE]=undef;
72 0 $self->[FILE]=undef;
73 0 $self->[FILE_QUEUE]=undef;
74 0 $self->[TREE_NO]=undef;
75 }
76  
77 15 1; # End of PMLTQ::Relation::CurrentFileIterator
78  
79 __END__
« blib/lib/PMLTQ/Command/init.pm ↑ Summary blib/lib/PMLTQ/Relation/AncestorIteratorWithBoundedDepth.pm »