STR/Node.pm

filter: Statementstmt 46.7% 29 / 62 Branchbran 36.3% 8 / 22 Conditioncond 5.2% 2 / 38 MC/DCmcdc 5.8% 1 / 17 Subroutinesub 69.2% 9 / 13 Podpod 0.0% 0 / 10 totaltotal 30.2% 49 / 162 CC 28 SCAR 40.4
CC
28
Cov
32%
query_completely_within_rect
132.0
query_point
56.0
query_partly_within_rect
56.0
CRAP 56.9
↑ Summary STR.pm »
1 package Tree::STR::Node;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 1 our $VERSION = '0.06';
7
8 126 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
9 126 my ($class, %args) = @_;
10 my $self = bless {
11 bbox => $args{bbox},
12 children => $args{children},
13 tip => $args{tip},
14 126 }, $class;
15
16 126 return $self;
17 }
18
19 184 ▶sub is_tip_node {
Subroutine is_tip_node: called CC=1 SCAR=0.0
Pod undocumented
20 184 !!$_[0]{tip};
21 }
22
23 0 ▶sub is_inner_node {
Subroutine is_inner_node: not called CC=1 SCAR=6.9
Pod undocumented
24 0 !!$_[0]{children};
25 }
26
27 129 ▶sub children {
Subroutine children: called CC=2 SCAR=6.9
Pod undocumented
28 129 ▶ $_[0]{children} // [];
Condition100%2/2
$_[0]{"children"} // []
l!l
10722
MC/DC100%1/1
$_[0]{"children"} // []
$_[0]{"children"}
Truth table100%2/2
A
A= $_[0]{"children"}
Aresult
11
00
29 }
30
31 97 ▶sub tip {
Subroutine tip: called CC=1 SCAR=0.0
Pod undocumented
32 97 $_[0]{tip};
33 }
34
35 17 ▶sub tips {
Subroutine tips: called CC=5 SCAR=16.1
Pod undocumented
36 17 my ($self) = @_;
37
38 17 ▶ return $self->{_tip_array} if $self->{_tip_array};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_tip_array"} 1 16 17
39
40 16 ▶ return [$self->tip] if $self->is_tip_node;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_tip_node 14 2 16
41 2 my @tips;
42 2 my @children = @{$self->children};
43 2 ▶ while (my $child = shift @children) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $child = shift @children) 122 2 124
44 122 ▶ if ($child->is_tip_node) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child->is_tip_node) { } 83 39 122
45 83 push @tips, $child->tip;
46 }
47 else {
48 39 push @children, @{$child->children};
49 }
50 }
51 2 return $self->{_tip_array} = \@tips;
52 }
53
54 205 ▶sub bbox {
Subroutine bbox: called CC=1 SCAR=0.0
Pod undocumented
55 205 $_[0]{bbox};
56 }
57
58 0 ▶sub query_point {
Subroutine query_point: not called CC=7 SCAR=40.3
Pod undocumented
59 0 my ($self, $x, $y) = @_;
60 0 my $bbox = $self->bbox;
61
62 0 ▶ return [] if $x < $bbox->[0] || $x > $bbox->[2] || $y < $bbox->[1] || $y > $bbox->[3];
Branch: 1 branch
BranchTrueFalseTotal
if $x < $bbox->[0] or $x > $bbox->[2] or $y < $bbox->[1] or $y > $bbox->[3] 0 0 0
Condition0%0/9
$x < $bbox->[0] or $x > $bbox->[2] or $y < $bbox->[1] or $y > $bbox->[3]
l!l&&r!l&&!r
000
$x < $bbox->[0] or $x > $bbox->[2] or $y < $bbox->[1]
l!l&&r!l&&!r
000
$x < $bbox->[0] or $x > $bbox->[2]
l!l&&r!l&&!r
000
MC/DC0%0/4
$x < $bbox->[0] or $x > $bbox->[2] or $y < $bbox->[1] or $y > $bbox->[3]
$x < $bbox->[0] $x > $bbox->[2] $y < $bbox->[1] $y > $bbox->[3]
Truth table0%0/5
A or B or C or D
A= $x < $bbox->[0]B= $x > $bbox->[2]C= $y < $bbox->[1]D= $y > $bbox->[3]
ABCDresult
1XXX1
01XX1
001X1
00011
00000
63
64 0 ▶ return [$self->{tip}] if $self->is_tip_node;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_tip_node 0 0 0
65
66 0 my @collated;
67 0 foreach my $child (@{ $self->children }) {
68 0 my $res = $child->query_point ($x, $y);
69 0 push @collated, @$res;
70 }
71 0 return \@collated;
72 }
73
74 0 ▶sub query_partly_within_rect {
Subroutine query_partly_within_rect: not called CC=7 SCAR=40.3
Pod undocumented
75 0 my ($self, $x1, $y1, $x2, $y2) = @_;
76 0 my $bbox = $self->bbox;
77
78 0 ▶ return []
Branch: 1 branch
BranchTrueFalseTotal
if $x2 < $bbox->[0] or $x1 > $bbox->[2] or $y2 < $bbox->[1] or $y1 > $bbox->[3] 0 0 0
Condition0%0/9
$x2 < $bbox->[0] or $x1 > $bbox->[2] or $y2 < $bbox->[1] or $y1 > $bbox->[3]
l!l&&r!l&&!r
000
$x2 < $bbox->[0] or $x1 > $bbox->[2] or $y2 < $bbox->[1]
l!l&&r!l&&!r
000
$x2 < $bbox->[0] or $x1 > $bbox->[2]
l!l&&r!l&&!r
000
MC/DC0%0/4
$x2 < $bbox->[0] or $x1 > $bbox->[2] or $y2 < $bbox->[1] or $y1 > $bbox->[3]
$x2 < $bbox->[0] $x1 > $bbox->[2] $y2 < $bbox->[1] $y1 > $bbox->[3]
Truth table0%0/5
A or B or C or D
A= $x2 < $bbox->[0]B= $x1 > $bbox->[2]C= $y2 < $bbox->[1]D= $y1 > $bbox->[3]
ABCDresult
1XXX1
01XX1
001X1
00011
00000
79 if $x2 < $bbox->[0] || $x1 > $bbox->[2]
80 || $y2 < $bbox->[1] || $y1 > $bbox->[3];
81
82 0 ▶ return [$self->{tip}] if $self->is_tip_node;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_tip_node 0 0 0
83
84 0 my @collated;
85 0 foreach my $child (@{ $self->children }) {
86 0 my $res = $child->query_partly_within_rect ($x1, $y1, $x2, $y2);
87 0 push @collated, @$res;
88 }
89 0 return \@collated;
90 }
91
92 0 ▶sub query_completely_within_rect {
Subroutine query_completely_within_rect: not called CC=11 SCAR=48.8
Pod undocumented
93 0 my ($self, $x1, $y1, $x2, $y2) = @_;
94 0 my $bbox = $self->bbox;
95
96 # no overlap
97 0 ▶ return []
Branch: 1 branch
BranchTrueFalseTotal
if $x2 < $bbox->[0] or $x1 > $bbox->[2] or $y2 < $bbox->[1] or $y1 > $bbox->[3] 0 0 0
Condition0%0/9
$x2 < $bbox->[0] or $x1 > $bbox->[2] or $y2 < $bbox->[1] or $y1 > $bbox->[3]
l!l&&r!l&&!r
000
$x2 < $bbox->[0] or $x1 > $bbox->[2] or $y2 < $bbox->[1]
l!l&&r!l&&!r
000
$x2 < $bbox->[0] or $x1 > $bbox->[2]
l!l&&r!l&&!r
000
MC/DC0%0/4
$x2 < $bbox->[0] or $x1 > $bbox->[2] or $y2 < $bbox->[1] or $y1 > $bbox->[3]
$x2 < $bbox->[0] $x1 > $bbox->[2] $y2 < $bbox->[1] $y1 > $bbox->[3]
Truth table0%0/5
A or B or C or D
A= $x2 < $bbox->[0]B= $x1 > $bbox->[2]C= $y2 < $bbox->[1]D= $y1 > $bbox->[3]
ABCDresult
1XXX1
01XX1
001X1
00011
00000
98 if $x2 < $bbox->[0] || $x1 > $bbox->[2]
99 || $y2 < $bbox->[1] || $y1 > $bbox->[3];
100
101 0 ▶ if ($self->is_tip_node) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_tip_node) 0 0 0
102 # not fully contained
103 0 ▶ return []
Branch: 1 branch
BranchTrueFalseTotal
unless $x1 < $bbox->[0] and $x2 > $bbox->[2] and $y1 < $bbox->[1] and $y2 > $bbox->[3] 0 0 0
Condition0%0/9
$x1 < $bbox->[0] and $x2 > $bbox->[2] and $y1 < $bbox->[1] and $y2 > $bbox->[3]
!ll&&!rl&&r
000
$x1 < $bbox->[0] and $x2 > $bbox->[2] and $y1 < $bbox->[1]
!ll&&!rl&&r
000
$x1 < $bbox->[0] and $x2 > $bbox->[2]
!ll&&!rl&&r
000
MC/DC0%0/4
$x1 < $bbox->[0] and $x2 > $bbox->[2] and $y1 < $bbox->[1] and $y2 > $bbox->[3]
$x1 < $bbox->[0] $x2 > $bbox->[2] $y1 < $bbox->[1] $y2 > $bbox->[3]
Truth table0%0/5
A and B and C and D
A= $x1 < $bbox->[0]B= $x2 > $bbox->[2]C= $y1 < $bbox->[1]D= $y2 > $bbox->[3]
ABCDresult
0XXX0
10XX0
110X0
11100
11111
104 if !($x1 < $bbox->[0] && $x2 > $bbox->[2]
105 && $y1 < $bbox->[1] && $y2 > $bbox->[3]
106 );
107
108 0 return [ $self->{tip} ];
109 }
110
111 0 my @collated;
112 0 foreach my $child (@{ $self->children }) {
113 0 my $res = $child->query_completely_within_rect ($x1, $y1, $x2, $y2);
114 0 push @collated, @$res;
115 }
116 0 return \@collated;
117 }
118
119 1 1;
120
121 =head1 NAME
122
123 Tree::STR::Node - Internal helper class for Tree::STR
124
125 =head1 VERSION
126
127 Version 0.01
128
129 =cut
↑ Summary STR.pm »