blib/lib/PMLTQ/Relation/OrderIterator.pm

filter: Statementstmt 47.9% 35 / 73 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 17 Subroutinesub 78.5% 11 / 14 Podpod 0.0% 0 / 3 totaltotal 27.7% 46 / 166 CC 24 SCAR 48.5
CC
24
Cov
27%
get_node_list
240.0
new
110.0
clone
2.0
CRAP 127.4
« blib/lib/PMLTQ/Relation/PDT.pm ↑ Summary blib/lib/PMLTQ/Relation/CurrentFilelistIterator.pm »
1 package PMLTQ::Relation::OrderIterator;
2 12 our $AUTHORITY = 'cpan:MATY';
3 12 $PMLTQ::Relation::OrderIterator::VERSION = '1.5.0';
4 # ABSTRACT: Interates nodes based on their order
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::SimpleListIterator);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use constant SOURCE_ORD_ATTR => PMLTQ::Relation::SimpleListIterator::FIRST_FREE;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use constant TARGET_ORD_ATTR => PMLTQ::Relation::SimpleListIterator::FIRST_FREE+1;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 12 ▶use constant DIR => PMLTQ::Relation::SimpleListIterator::FIRST_FREE+2;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 12 ▶use constant MIN => PMLTQ::Relation::SimpleListIterator::FIRST_FREE+3;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 12 ▶use constant MAX => PMLTQ::Relation::SimpleListIterator::FIRST_FREE+4;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 12 ▶use constant SPAN_INIT => PMLTQ::Relation::SimpleListIterator::FIRST_FREE+5;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 12 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 sub new {
20 0 ▶ my ($class,$conditions,$s_ord_attr,$t_ord_attr,$dir,$min,$max,$span_init)=@_;
Subroutine new: not called CC=10 SCAR=47.0
Pod undocumented
21 0 ▶ croak "usage: $class->new(sub{...},\$source_ord_attr,\$target_ord_attr)"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $conditions eq "CODE" and defined $s_ord_attr and defined $t_ord_attr 0 0 0
Condition0%0/6
ref $conditions eq "CODE" and defined $s_ord_attr and defined $t_ord_attr
!ll&&!rl&&r
000
ref $conditions eq "CODE" and defined $s_ord_attr
!ll&&!rl&&r
000
MC/DC0%0/3
ref $conditions eq "CODE" and defined $s_ord_attr and defined $t_ord_attr
ref $conditions eq "CODE" defined $s_ord_attr defined $t_ord_attr
Truth table0%0/4
A and B and C
A= ref $conditions eq "CODE"B= defined $s_ord_attrC= defined $t_ord_attr
ABCresult
0XX0
10X0
1100
1111
22 unless (ref($conditions) eq 'CODE' and defined($s_ord_attr) and defined($t_ord_attr));
23 0 my $self = PMLTQ::Relation::SimpleListIterator->new($conditions);
24 0 $self->[SOURCE_ORD_ATTR]=$s_ord_attr;
25 0 $self->[TARGET_ORD_ATTR]=$t_ord_attr;
26 0 $self->[DIR]=$dir; # dir should be 1 or -1
27 0 ▶ $self->[MIN]=$min if defined($min) and length($min);
Branch: 1 branch
BranchTrueFalseTotal
if defined $min and length $min 0 0 0
Condition0%0/3
defined $min and length $min
!ll&&!rl&&r
000
MC/DC0%0/2
defined $min and length $min
defined $min length $min
Truth table0%0/3
A and B
A= defined $minB= length $min
ABresult
0X0
100
111
28 0 ▶ $self->[MAX]=$max if defined($max) and length($max);
Branch: 1 branch
BranchTrueFalseTotal
if defined $max and length $max 0 0 0
Condition0%0/3
defined $max and length $max
!ll&&!rl&&r
000
MC/DC0%0/2
defined $max and length $max
defined $max length $max
Truth table0%0/3
A and B
A= defined $maxB= length $max
ABresult
0X0
100
111
29 0 ▶ $self->[SPAN_INIT]=$span_init if defined($span_init) and ref($span_init);
Branch: 1 branch
BranchTrueFalseTotal
if defined $span_init and ref $span_init 0 0 0
Condition0%0/3
defined $span_init and ref $span_init
!ll&&!rl&&r
000
MC/DC0%0/2
defined $span_init and ref $span_init
defined $span_init ref $span_init
Truth table0%0/3
A and B
A= defined $span_initB= ref $span_init
ABresult
0X0
100
111
30 0 bless $self, $class; # reblessing
31 0 return $self;
32 }
33 sub clone {
34 0 ▶ my ($self)=@_;
Subroutine clone: not called CC=1 SCAR=6.9
Pod undocumented
35 0 my $clone = $self->PMLTQ::Relation::SimpleListIterator::clone();
36 0 $clone->[SOURCE_ORD_ATTR]=$self->[SOURCE_ORD_ATTR];
37 0 $clone->[TARGET_ORD_ATTR]=$self->[TARGET_ORD_ATTR];
38 0 $clone->[DIR]=$self->[DIR];
39 0 $clone->[MIN]=$self->[MIN];
40 0 $clone->[MAX]=$self->[MAX];
41 0 $clone->[SPAN_INIT]=$self->[SPAN_INIT];
42 0 return $clone;
43 }
44 sub get_node_list {
45 0 ▶ my ($self,$node)=@_;
Subroutine get_node_list: not called CC=15 SCAR=54.8
Pod undocumented
46 0 my $fsfile = $self->[PMLTQ::Relation::SimpleListIterator::FILE];
47 0 my $dir = $self->[DIR];
48 0 my $s_ord_attr = $self->[SOURCE_ORD_ATTR];
49 0 my $t_ord_attr = $self->[TARGET_ORD_ATTR];
50 0 my $min = $self->[MIN];
51 0 my $max = $self->[MAX];
52 0 ▶ $min = 0 if !defined($min);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $min 0 0 0
53 0 my $root = $node->root;
54 0 ▶ if ((!$s_ord_attr or !$t_ord_attr) and $self->[SPAN_INIT]) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $s_ord_attr && $t_ord_attr and $self->[8]) 0 0 0
Condition0%0/6
not $s_ord_attr && $t_ord_attr and $self->[8]
!ll&&!rl&&r
000
$s_ord_attr && $t_ord_attr
!ll&&!rl&&r
000
MC/DC0%0/3
not $s_ord_attr && $t_ord_attr and $self->[8]
$s_ord_attr $t_ord_attr $self->[8]
Truth table0%0/5
not(A && B) and C
A= $s_ord_attrB= $t_ord_attrC= $self->[8]
ABCresult
11X0
0X00
1000
0X11
1011
55 0 $self->[SPAN_INIT]->($root)
56 }
57 my $s_ord = $s_ord_attr ?
58 0 ▶ $node->{$s_ord_attr} :
Branch: 2 branches
BranchTrueFalseTotal
$s_ord_attr ? : 0 0 0
$dir > 0 ? : 0 0 0
59 $self->[SPAN_INIT]->($node)->[ ($dir>0) ? 0 : 1 ];
60 0 ▶ return [] unless defined $s_ord;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $s_ord 0 0 0
61 return [map [$_,$fsfile],
62 grep {
63 0 ▶ my $t_ord = $t_ord_attr ? $_->{$t_ord_attr} : $self->[SPAN_INIT]->($_)->[ ($dir>0) ? 1 : 0 ];
Branch: 2 branches
BranchTrueFalseTotal
$t_ord_attr ? : 0 0 0
$dir > 0 ? : 0 0 0
64 0 ▶ if (defined $t_ord) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $t_ord) 0 0 0
65 0 my $dist = $dir*($s_ord - $t_ord);
66 0 ▶ $_!=$node and (!defined($min) or $dist>=$min) and (!defined($max) or $dist<=$max)
Branch: 1 branch
BranchTrueFalseTotal
$_ != $node and !defined($min) || $dist >= $min and !defined($max) || $dist <= $max 0 0 0
Condition0%0/12
$_ != $node && (!defined($min) || $dist >= $min) && (!defined($max) || $dist <= $max)
!ll&&!rl&&r
000
$_ != $node and !defined($min) || $dist >= $min
!ll&&!rl&&r
000
not defined $min or $dist >= $min
l!l&&r!l&&!r
000
not defined $max or $dist <= $max
l!l&&r!l&&!r
000
MC/DC0%0/5
$_ != $node && (!defined($min) || $dist >= $min) && (!defined($max) || $dist <= $max)
$_ != $node not defined $min $dist >= $min not defined $max $dist <= $max
Truth table0%0/8
A and not(B) or C && not(D) or E
A= $_ != $nodeB= not defined $minC= $dist >= $minD= not defined $maxE= $dist <= $max
ABCDEresult
0XXXX0
100XX0
11X000
101000
11X1X1
11X011
1011X1
101011
67 }
68 }
69 $root->descendants];
70 }
71  
72 12 1; # End of PMLTQ::Relation::OrderIterator
73  
74 __END__
« blib/lib/PMLTQ/Relation/PDT.pm ↑ Summary blib/lib/PMLTQ/Relation/CurrentFilelistIterator.pm »