DSL/Context/Range.pm

filter: Statementstmt 4.6% 4 / 87 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 23 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 25.0% 1 / 4 Podpod 0.0% 0 / 3 totaltotal 3.4% 5 / 146 CC 26 SCAR 49.6
CC
26
Cov
3%
change_context
210.0
update_stream
110.0
new
20.0
CRAP 142.1
« DSL/Context/TextBlock.pm ↑ Summary DSL/Context/Default.pm »
1 package Outthentic::DSL::Context::Range;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 0 ▶sub new {
Subroutine new: not called CC=4 SCAR=30.0
Pod undocumented
6  
7 0 my $class = shift;
8 0 my $expr = shift;
9  
10 0 my ($a, $b) = split /\s+/, $expr;
11  
12 0 s{\s+}[] for $a, $b;
13  
14 0 ▶ $a ||= '.*';
Condition0%0/2
$a ||= ".*"
l!l
00
MC/DC0%0/1
$a ||= ".*"
$a
Truth table0%0/2
A
A= $a
Aresult
11
00
15 0 ▶ $b ||= '.*';
Condition0%0/2
$b ||= ".*"
l!l
00
MC/DC0%0/1
$b ||= ".*"
$b
Truth table0%0/2
A
A= $b
Aresult
11
00
16  
17 0 my $self = bless {}, $class;
18  
19 0 $self->{bound_l} = qr/$a/;
20 0 $self->{bound_r} = qr/$b/;
21  
22 0 $self;
23 }
24  
25 0 ▶sub change_context {
Subroutine change_context: not called CC=14 SCAR=53.5
Pod undocumented
26  
27 0 my $self = shift;
28 0 my $cur_ctx = shift; # current search context
29 0 my $orig_ctx = shift; # original search context
30 0 my $succ = shift; # latest succeeded items
31  
32 0 my $bound_l = $self->{bound_l};
33 0 my $bound_r = $self->{bound_r};
34  
35 0 my @new_ctx = (); # new context
36 0 my @chunk;
37  
38 0 my $inside = 0;
39  
40 0 ▶ $self->{chains} ||= {};
Condition0%0/2
$self->{"chains"} ||= {}
l!l
00
MC/DC0%0/1
$self->{"chains"} ||= {}
$self->{"chains"}
Truth table0%0/2
A
A= $self->{"chains"}
Aresult
11
00
41 0 ▶ $self->{ranges} ||= []; # this is initial ranges object
Condition0%0/2
$self->{"ranges"} ||= []
l!l
00
MC/DC0%0/1
$self->{"ranges"} ||= []
$self->{"ranges"}
Truth table0%0/2
A
A= $self->{"ranges"}
Aresult
11
00
42 0 ▶ $self->{bad_ranges} ||={};
Condition0%0/2
$self->{"bad_ranges"} ||= {}
l!l
00
MC/DC0%0/1
$self->{"bad_ranges"} ||= {}
$self->{"bad_ranges"}
Truth table0%0/2
A
A= $self->{"bad_ranges"}
Aresult
11
00
43  
44 0 my $a_index;
45 my $b_index;
46  
47 0 SUCC: for my $c (@{$cur_ctx}){
48  
49 0 ▶ if ( $inside and $c->[0] =~ $bound_r ){
Branch: 1 branch
BranchTrueFalseTotal
if ($inside and $c->[0] =~ /$bound_r/) 0 0 0
Condition0%0/3
$inside and $c->[0] =~ /$bound_r/
!ll&&!rl&&r
000
MC/DC0%0/2
$inside and $c->[0] =~ /$bound_r/
$inside $c->[0] =~ /$bound_r/
Truth table0%0/3
A and B
A= $insideB= $c->[0] =~ /$bound_r/
ABresult
0X0
100
111
50  
51  
52 0 push @new_ctx, @chunk;
53
54 0 push @new_ctx, ["#dsl_note: end range"];
55
56 0 @chunk = ();
57
58 0 $inside = 0;
59
60 0 $b_index = $c->[1];
61
62 0 ▶ unless ($self->{chains}->{$a_index}){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"chains"}{$a_index}) 0 0 0
63 0 $self->{chains}->{$a_index} = [];
64 0 push @{$self->{ranges}}, [$a_index, $b_index];
65 }
66
67 0 for my $j (@chunk) {
68 0 push @new_ctx, $j;
69 }
70
71 0 @chunk = ();
72
73 0 next SUCC;
74 }
75  
76 0 ▶ if ($inside){
Branch: 2 branches
BranchTrueFalseTotal
if ($inside) { } 0 0 0
elsif ($c->[0] =~ /$bound_l/ and not defined $self->{'bad_ranges'}{$c->[1]}) { } 0 0 0
77  
78 0 push @chunk, $c;
79  
80 ▶ } elsif ( $c->[0] =~ $bound_l and ! defined($self->{bad_ranges}->{$c->[1]})){
Condition0%0/3
$c->[0] =~ /$bound_l/ and not defined $self->{"bad_ranges"}{$c->[1]}
!ll&&!rl&&r
000
MC/DC0%0/2
$c->[0] =~ /$bound_l/ and not defined $self->{"bad_ranges"}{$c->[1]}
$c->[0] =~ /$bound_l/ not defined $self->{"bad_ranges"}{$c->[1]}
Truth table0%0/3
A and not(B)
A= $c->[0] =~ /$bound_l/B= not defined $self->{"bad_ranges"}{$c->[1]}
ABresult
0X0
100
111
81  
82 0 $inside = 1;
83 0 $a_index = $c->[1];
84  
85 0 push @chunk, ["#dsl_note: start range"];
86  
87 0 next SUCC;
88 }
89  
90 }
91  
92 0 ▶ if ($ENV{OUTH_DBG}){
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"OUTH_DBG"}) 0 0 0
93 0 for my $c (@new_ctx){
94 0 print "[OTX_DEBUG] @{$c}"
95 }
96 }
97 0 return [@new_ctx];
98 }
99  
100  
101  
102 0 ▶sub update_stream {
Subroutine update_stream: not called CC=10 SCAR=47.0
Pod undocumented
103  
104 0 my $self = shift;
105 0 my $cur_ctx = shift; # current search context
106 0 my $orig_ctx = shift; # original search context
107 0 my $succ = shift; # latest succeeded items
108 0 my $stream_ref = shift; # reference to stream object to update
109  
110 0 my %live_ranges;
111
112 0 my $inside = 0;
113  
114 0 ▶ $self->{chains} ||= {}; # this is initial chains object
Condition0%0/2
$self->{"chains"} ||= {}
l!l
00
MC/DC0%0/1
$self->{"chains"} ||= {}
$self->{"chains"}
Truth table0%0/2
A
A= $self->{"chains"}
Aresult
11
00
115 0 ▶ $self->{seen} ||= {};
Condition0%0/2
$self->{"seen"} ||= {}
l!l
00
MC/DC0%0/1
$self->{"seen"} ||= {}
$self->{"seen"}
Truth table0%0/2
A
A= $self->{"seen"}
Aresult
11
00
116  
117  
118 0 for my $c (@{$succ}){
119  
120 0 for my $r (@{$self->{ranges}}){
121  
122 0 my $a_index = $r->[0];
123  
124 0 my $b_index = $r->[1];
125  
126 0 ▶ if ($c->[1] > $a_index and $c->[1] < $b_index ){
Branch: 1 branch
BranchTrueFalseTotal
if ($c->[1] > $a_index and $c->[1] < $b_index) 0 0 0
Condition0%0/3
$c->[1] > $a_index and $c->[1] < $b_index
!ll&&!rl&&r
000
MC/DC0%0/2
$c->[1] > $a_index and $c->[1] < $b_index
$c->[1] > $a_index $c->[1] < $b_index
Truth table0%0/3
A and B
A= $c->[1] > $a_indexB= $c->[1] < $b_index
ABresult
0X0
100
111
127 0 ▶ push @{$self->{chains}->{$a_index}}, $c unless $self->{seen}->{$c->[1]}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"seen"}{$c->[1]}++ 0 0 0
128 0 $live_ranges{$a_index} = 1;
129 }
130  
131 }
132  
133 }
134  
135 0 ${$stream_ref} = {};
136  
137 0 my @k = sort { $b <=> $b } keys %{$self->{chains}};
138  
139 0 for my $cid ( @k ) {
140  
141 0 ▶ if ( exists $live_ranges{$cid} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $live_ranges{$cid}) { } 0 0 0
142 0 ${$stream_ref}->{$cid} = [ sort { $a->[1] <=> $b->[1] } @{$self->{chains}->{$cid}} ];
143 } else {
144 0 delete ${$self->{chains}}{$cid};
145 0 $self->{bad_ranges}->{$cid} = 1;
146 }
147  
148 }
149  
150 }
151  
152 2 1;
153  
« DSL/Context/TextBlock.pm ↑ Summary DSL/Context/Default.pm »