GrowthBook/Eval.pm

filter: Statementstmt 92.6% 190 / 205 Branchbran 93.7% 135 / 144 Conditioncond 61.1% 22 / 36 MC/DCmcdc 45.4% 10 / 22 Subroutinesub 100% 20 / 20 Podpod 0.0% 0 / 12 totaltotal 85.8% 377 / 439 CC 97 SCAR 27.6
CC
97
Cov
90%
eval_operator_condition
31.2
eval_condition_value
20.1
get_type
15.5
CRAP 15.7
« GrowthBook.pm ↑ Summary GrowthBook/Experiment.pm »
1 package WebService::GrowthBook::Eval;
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶no indirect;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Scalar::Util qw(looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Syntax::Keyword::Try;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use JSON::MaybeXS qw(is_bool);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 our $VERSION = '0.003'; ## VERSION
12  
13 4 our @EXPORT_OK = qw(eval_condition);
14  
15 179 ▶sub eval_condition {
Subroutine eval_condition: called CC=7 SCAR=19.5
Pod undocumented
16 179 my ($attributes, $condition) = @_;
17 179 ▶ if (exists $condition->{"\$or"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $condition->{"\$or"}) 5 174 179
18 5 my $r = eval_or($attributes, $condition->{"\$or"});
19 5 return $r;
20 }
21 174 ▶ if (exists $condition->{"\$nor"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $condition->{"\$nor"}) 4 170 174
22 4 return !eval_or($attributes, $condition->{"\$nor"});
23 }
24 170 ▶ if (exists $condition->{"\$and"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $condition->{"\$and"}) 7 163 170
25 7 my $r = eval_and($attributes, $condition->{"\$and"});
26 7 return $r;
27 }
28 163 ▶ if (exists $condition->{"\$not"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $condition->{"\$not"}) 2 161 163
29 2 return !eval_condition($attributes, $condition->{"\$not"});
30 }
31  
32 161 for my $key (keys %$condition){
33 164 my $value = $condition->{$key};
34 164 ▶ if (!eval_condition_value($value, get_path($attributes, $key))) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval_condition_value($value, get_path($attributes, $key))) 91 73 164
35 91 return 0;
36 }
37 }
38  
39 70 return 1;
40 }
41  
42 164 ▶sub get_path {
Subroutine get_path: called CC=4 SCAR=13.9
Pod undocumented
43 164 my ($attributes, $path) = @_;
44 164 my $current = $attributes;
45  
46 164 foreach my $segment (split /\./, $path) {
47 176 ▶ if (ref($current) eq 'HASH' && exists $current->{$segment}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $current eq 'HASH' and exists $current->{$segment}) { } 169 7 176
Condition100%3/3
ref $current eq "HASH" and exists $current->{$segment}
!ll&&!rl&&r
25169
MC/DC100%2/2
ref $current eq "HASH" and exists $current->{$segment}
ref $current eq "HASH" exists $current->{$segment}
Truth table100%3/3
A and B
A= ref $current eq "HASH"B= exists $current->{$segment}
ABresult
0X0
100
111
48 169 $current = $current->{$segment};
49 } else {
50 7 return undef;
51 }
52 }
53 157 return $current;
54 }
55  
56 9 ▶sub eval_or {
Subroutine eval_or: called CC=4 SCAR=13.9
Pod undocumented
57 9 my ($attributes, $conditions) = @_;
58  
59 9 ▶ if (scalar @$conditions == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$conditions == 0) 1 8 9
60 1 return 1; # True
61 }
62  
63 8 foreach my $condition (@$conditions) {
64 12 ▶ if (eval_condition($attributes, $condition)) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval_condition($attributes, $condition)) 6 6 12
65 6 return 1; # True
66 }
67 }
68 2 return 0; # False
69 }
70 7 ▶sub eval_and {
Subroutine eval_and: called CC=3 SCAR=11.0
Pod undocumented
71 7 my ($attributes, $conditions) = @_;
72  
73 7 foreach my $condition (@$conditions) {
74 10 ▶ if (!eval_condition($attributes, $condition)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval_condition($attributes, $condition)) 3 7 10
75 3 return 0; # False
76 }
77 }
78 4 return 1; # True
79 }
80  
81  
82 210 ▶sub eval_condition_value {
Subroutine eval_condition_value: called CC=20 SCAR=30.0
Pod undocumented
83 210 my ($condition_value, $attribute_value) = @_;
84 210 ▶ if (ref($condition_value) eq 'HASH' && is_operator_object($condition_value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $condition_value eq "HASH" and is_operator_object($condition_value)) 153 57 210
Condition100%3/3
ref $condition_value eq "HASH" and is_operator_object($condition_value)
!ll&&!rl&&r
534153
MC/DC100%2/2
ref $condition_value eq "HASH" and is_operator_object($condition_value)
ref $condition_value eq "HASH" is_operator_object($condition_value)
Truth table100%3/3
A and B
A= ref $condition_value eq "HASH"B= is_operator_object($condition_value)
ABresult
0X0
100
111
85 153 for my $key (keys %$condition_value){
86 184 my $value = $condition_value->{$key};
87 184 ▶ if (!eval_operator_condition($key, $attribute_value, $value)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval_operator_condition($key, $attribute_value, $value)) 89 95 184
88 89 return 0; # False
89 }
90 }
91 64 return 1; # True
92 }
93 57 ▶ if (ref($condition_value) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $condition_value eq "ARRAY") 5 52 57
94 5 ▶ if(ref($attribute_value) ne 'ARRAY'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $attribute_value ne "ARRAY") 1 4 5
95 1 return 0;
96 }
97 4 ▶ if(scalar @$condition_value != scalar @$attribute_value){
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$condition_value != scalar @$attribute_value) 2 2 4
98 2 return 0;
99 }
100 2 for my $i (0..$#$condition_value){
101 3 ▶ if(!eval_condition_value($condition_value->[$i], $attribute_value->[$i])){
Branch: 1 branch
BranchTrueFalseTotal
unless (eval_condition_value($condition_value->[$i], $attribute_value->[$i])) 1 2 3
102 1 return 0;
103 }
104 }
105 1 return 1;
106 }
107  
108 52 ▶ if(ref($condition_value) eq 'HASH'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $condition_value eq "HASH") 4 48 52
109 4 ▶ if(ref($attribute_value) ne 'HASH'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $attribute_value ne "HASH") 1 3 4
110 1 return 0;
111 }
112 3 ▶ if(scalar keys %$condition_value != scalar keys %$attribute_value){
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %$condition_value != scalar keys %$attribute_value) 2 1 3
113 2 return 0;
114 }
115 1 for my $key (keys %$condition_value){
116 1 ▶ if(!exists $attribute_value->{$key}){
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $attribute_value->{$key}) 0 1 1
117 0 return 0;
118 }
119 1 ▶ if(!eval_condition_value($condition_value->{$key}, $attribute_value->{$key})){
Branch: 1 branch
BranchTrueFalseTotal
unless (eval_condition_value($condition_value->{$key}, $attribute_value->{$key})) 0 1 1
120 0 return 0;
121 }
122 }
123 1 return 1;
124  
125 }
126 48 ▶ if(!defined($condition_value) && !defined($attribute_value)){
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $condition_value || defined $attribute_value) { } 2 46 48
elsif (not defined $condition_value && defined $attribute_value) { } 5 41 46
Condition100%3/3
defined $condition_value || defined $attribute_value
l!l&&r!l&&!r
4332
MC/DC100%2/2
defined $condition_value || defined $attribute_value
defined $condition_value defined $attribute_value
Truth table100%3/3
A || B
A= defined $condition_valueB= defined $attribute_value
ABresult
1X1
011
000
127 2 return 1;
128 }
129 ▶ elsif(!defined($condition_value) || !defined($attribute_value)){
Condition100%3/3
defined $condition_value && defined $attribute_value
!ll&&!rl&&r
3241
MC/DC100%2/2
defined $condition_value && defined $attribute_value
defined $condition_value defined $attribute_value
Truth table100%3/3
A && B
A= defined $condition_valueB= defined $attribute_value
ABresult
0X0
100
111
130 5 return 0;
131 }
132 41 return $condition_value eq $attribute_value;
133 }
134  
135 183 ▶sub is_operator_object {
Subroutine is_operator_object: called CC=3 SCAR=11.0
Pod undocumented
136 183 my ($obj) = @_;
137  
138 183 foreach my $key (keys %$obj) {
139 218 ▶ if (substr($key, 0, 1) ne '$') {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($key, 0, 1) ne "\$") 8 210 218
140 8 return 0; # False
141 }
142 }
143 175 return 1; # True
144 }
145  
146 55 ▶sub compare {
Subroutine compare: called CC=7 SCAR=21.3
Pod undocumented
147 55 my ($va, $vb) = @_;
148 55 ▶ if(looks_like_number($va) && ! defined($vb)){
Branch: 1 branch
BranchTrueFalseTotal
if (&looks_like_number($va) and not defined $vb) 0 55 55
Condition66%2/3
&looks_like_number($va) and not defined $vb
!ll&&!rl&&r
20350
MC/DC0%0/2
&looks_like_number($va) and not defined $vb
&looks_like_number($va) not defined $vb
Truth table66%2/3
A and not(B)
A= &looks_like_number($va)B= not defined $vb
ABresult
0X0
100
111
149 0 $vb = 0;
150 }
151 55 ▶ if(looks_like_number($vb) && ! defined($va)){
Branch: 1 branch
BranchTrueFalseTotal
if (&looks_like_number($vb) and not defined $va) 0 55 55
Condition66%2/3
&looks_like_number($vb) and not defined $va
!ll&&!rl&&r
20350
MC/DC0%0/2
&looks_like_number($vb) and not defined $va
&looks_like_number($vb) not defined $va
Truth table66%2/3
A and not(B)
A= &looks_like_number($vb)B= not defined $va
ABresult
0X0
100
111
152 0 $va = 0;
153 }
154 55 ▶ if(looks_like_number($va) && looks_like_number($vb)){
Branch: 1 branch
BranchTrueFalseTotal
if (&looks_like_number($va) and &looks_like_number($vb)) { } 35 20 55
Condition66%2/3
&looks_like_number($va) and &looks_like_number($vb)
!ll&&!rl&&r
20035
MC/DC50%1/2
&looks_like_number($va) and &looks_like_number($vb)
&looks_like_number($va) &looks_like_number($vb)
Truth table66%2/3
A and B
A= &looks_like_number($va)B= &looks_like_number($vb)
ABresult
0X0
100
111
155 35 return $va <=> $vb;
156 }
157 else {
158 20 return $va cmp $vb;
159 }
160 }
161 184 ▶sub eval_operator_condition {
Subroutine eval_operator_condition: called CC=31 SCAR=34.4
Pod undocumented
162 184 my ($operator, $attribute_value, $condition_value) = @_;
163 184 ▶ if ($operator eq '$eq') {
Branch: 21 branches
BranchTrueFalseTotal
if ($operator eq '$eq') { } 10 174 184
elsif ($operator eq '$ne') { } 2 172 174
elsif ($operator eq '$lt') { } 10 162 172
elsif ($operator eq '$lte') { } 4 158 162
elsif ($operator eq '$gt') { } 25 133 158
elsif ($operator eq '$gte') { } 4 129 133
elsif ($operator eq '$veq') { } 2 127 129
elsif ($operator eq '$vne') { } 2 125 127
elsif ($operator eq '$vlt') { } 13 112 125
elsif ($operator eq '$vlte') { } 8 104 112
elsif ($operator eq '$vgt') { } 13 91 104
elsif ($operator eq '$vgte') { } 8 83 91
elsif ($operator eq '$regex') { } 14 69 83
elsif ($operator eq '$in') { } 17 52 69
elsif ($operator eq '$nin') { } 8 44 52
elsif ($operator eq '$elemMatch') { } 11 33 44
elsif ($operator eq '$size') { } 9 24 33
elsif ($operator eq '$all') { } 3 21 24
elsif ($operator eq '$exists') { } 4 17 21
elsif ($operator eq '$type') { } 12 5 17
elsif ($operator eq '$not') { } 4 1 5
164 try {
165 10 return compare($attribute_value, $condition_value) == 0;
166 }
167 10 catch {
168 0 return 0;
169 }
170 } elsif ($operator eq '$ne') {
171 try {
172 2 return compare($attribute_value, $condition_value) != 0;
173 }
174 2 catch {
175 0 return 0;
176 }
177 } elsif ($operator eq '$lt') {
178 try {
179 10 return compare($attribute_value, $condition_value) < 0;
180 }
181 10 catch {
182 0 return 0;
183 }
184 } elsif ($operator eq '$lte') {
185 try {
186 4 return compare($attribute_value, $condition_value) <= 0;
187 }
188 4 catch {
189 0 return 0;
190 }
191 } elsif ($operator eq '$gt') {
192 try {
193 25 my $r = compare($attribute_value, $condition_value);
194 25 return $r > 0;
195 }
196 25 catch {
197 0 return 0;
198 }
199 } elsif ($operator eq '$gte') {
200 try {
201 4 return compare($attribute_value, $condition_value) >= 0;
202 }
203 4 catch {
204 0 return 0;
205 }
206 } elsif ($operator eq '$veq') {
207 2 return padded_version_string($attribute_value) eq padded_version_string($condition_value);
208 } elsif ($operator eq '$vne') {
209 2 return padded_version_string($attribute_value) ne padded_version_string($condition_value);
210 } elsif ($operator eq '$vlt') {
211 13 return padded_version_string($attribute_value) lt padded_version_string($condition_value);
212 } elsif ($operator eq '$vlte') {
213 8 return padded_version_string($attribute_value) le padded_version_string($condition_value);
214 } elsif ($operator eq '$vgt') {
215 13 return padded_version_string($attribute_value) gt padded_version_string($condition_value);
216 } elsif ($operator eq '$vgte') {
217 8 return padded_version_string($attribute_value) ge padded_version_string($condition_value);
218 } elsif ($operator eq '$regex') {
219 try {
220 14 my $r = qr/$condition_value/;
221 12 return $attribute_value =~ $r;
222 }
223 14 catch {
224 2 return 0;
225 }
226 } elsif ($operator eq '$in') {
227 17 ▶ return 0 unless ref($condition_value) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $condition_value eq "ARRAY" 1 16 17
228 16 return is_in($condition_value, $attribute_value);
229 } elsif ($operator eq '$nin') {
230 8 ▶ return 0 unless ref($condition_value) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $condition_value eq "ARRAY" 1 7 8
231 7 return !is_in($condition_value, $attribute_value);
232 } elsif ($operator eq '$elemMatch') {
233 11 return elem_match($condition_value, $attribute_value);
234 } elsif ($operator eq '$size') {
235 9 ▶ return 0 unless ref($attribute_value) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $attribute_value eq "ARRAY" 1 8 9
236 8 return eval_condition_value($condition_value, scalar @$attribute_value);
237 } elsif ($operator eq '$all') {
238 3 ▶ return 0 unless ref($attribute_value) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $attribute_value eq "ARRAY" 1 2 3
239 2 foreach my $cond (@$condition_value) {
240 4 my $passing = 0;
241 4 foreach my $attr (@$attribute_value) {
242 8 ▶ if (eval_condition_value($cond, $attr)) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval_condition_value($cond, $attr)) 3 5 8
243 3 $passing = 1;
244 3 last;
245 }
246 }
247 4 ▶ return 0 unless $passing;
Branch: 1 branch
BranchTrueFalseTotal
unless $passing 1 3 4
248 }
249 1 return 1;
250 } elsif ($operator eq '$exists') {
251 4 ▶ return !$condition_value ? !defined $attribute_value : defined $attribute_value;
Branch: 1 branch
BranchTrueFalseTotal
!$condition_value ? : 2 2 4
252 } elsif ($operator eq '$type') {
253 12 my $r = get_type($attribute_value);
254 12 return $r eq $condition_value;
255 } elsif ($operator eq '$not') {
256 4 return !eval_condition_value($condition_value, $attribute_value);
257 }
258 1 return 0;
259 }
260  
261  
262 218 ▶sub padded_version_string {
Subroutine padded_version_string: called CC=7 SCAR=21.3
Pod undocumented
263 218 my ($input) = @_;
264  
265 # If input is a number, convert to a string
266 218 ▶ if (looks_like_number($input)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&looks_like_number($input)) 0 218 218
267 0 $input = "$input";
268 }
269  
270 218 ▶ if (!defined $input || ref($input) || $input eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $input or ref $input or $input eq "") 0 218 218
Condition33%2/6
not defined $input or ref $input or $input eq ""
l!l&&r!l&&!r
00218
not defined $input or ref $input
l!l&&r!l&&!r
00218
MC/DC0%0/3
not defined $input or ref $input or $input eq ""
not defined $input ref $input $input eq ""
Truth table25%1/4
not(A) or B or C
A= not defined $inputB= ref $inputC= $input eq ""
ABCresult
1XX1
01X1
0011
0000
271 0 $input = "0";
272 }
273  
274 # Remove build info and leading `v` if any
275 218 $input =~ s/^v|\+.*$//g;
276  
277 # Split version into parts (both core version numbers and pre-release tags)
278 218 my @parts = split(/[-.]/, $input);
279  
280 # If it's SemVer without a pre-release, add `~` to the end
281 218 ▶ if (scalar(@parts) == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @parts == 3) 134 84 218
282 134 push @parts, "~";
283 }
284  
285 # Left pad each numeric part with spaces so string comparisons will work ("9">"10", but " 9"<"10")
286 218 ▶ @parts = map { /^\d+$/ ? sprintf("%5s", $_) : $_ } @parts;
Branch: 1 branch
BranchTrueFalseTotal
/^\d+$/ ? : 704 217 921
287  
288 # Join back together into a single string
289 218 return join("-", @parts);
290 }
291 23 ▶sub is_in {
Subroutine is_in: called CC=5 SCAR=16.1
Pod undocumented
292 23 my ($condition_value, $attribute_value) = @_;
293 23 ▶ return 0 unless defined($attribute_value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $attribute_value 1 22 23
294 22 ▶ if (ref($attribute_value) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $attribute_value eq "ARRAY") 10 12 22
295 10 my %condition_hash = map { $_ => 1 } @$condition_value;
296 10 foreach my $item (@$attribute_value) {
297 20 ▶ return 1 if exists $condition_hash{$item};
Branch: 1 branch
BranchTrueFalseTotal
if exists $condition_hash{$item} 6 14 20
298 }
299 4 return 0;
300 }
301 12 return grep { $_ eq $attribute_value } @$condition_value;
302 }
303  
304 11 ▶sub elem_match {
Subroutine elem_match: called CC=6 SCAR=17.9
Pod undocumented
305 11 my ($condition, $attribute_value) = @_;
306  
307 # Check if $attribute_value is an array reference
308 11 ▶ return 0 unless ref($attribute_value) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $attribute_value eq "ARRAY" 1 10 11
309  
310 10 foreach my $item (@$attribute_value) {
311 26 ▶ if (is_operator_object($condition)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_operator_object($condition)) { } 22 4 26
312 22 ▶ if (eval_condition_value($condition, $item)) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval_condition_value($condition, $item)) 4 18 22
313 4 return 1;
314 }
315 } else {
316 4 ▶ if (eval_condition($item, $condition)) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval_condition($item, $condition)) 1 3 4
317 1 return 1;
318 }
319 }
320 }
321  
322 5 return 0;
323 }
324  
325 12 ▶sub get_type {
Subroutine get_type: called CC=11 SCAR=27.4
Pod undocumented
326 12 my ($attribute_value) = @_;
327 12 ▶ if (!defined $attribute_value) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $attribute_value) 1 11 12
328 1 return "null";
329 }
330 11 ▶ if (ref($attribute_value) eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $attribute_value eq "") 8 3 11
331 8 ▶ if ($attribute_value =~ /^[+-]?\d+$/ || $attribute_value =~ /^[+-]?\d*\.\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attribute_value =~ /^[+-]?\d+$/ or $attribute_value =~ /^[+-]?\d*\.\d+$/) 6 2 8
Condition66%2/3
$attribute_value =~ /^[+-]?\d+$/ or $attribute_value =~ /^[+-]?\d*\.\d+$/
l!l&&r!l&&!r
602
MC/DC50%1/2
$attribute_value =~ /^[+-]?\d+$/ or $attribute_value =~ /^[+-]?\d*\.\d+$/
$attribute_value =~ /^[+-]?\d+$/ $attribute_value =~ /^[+-]?\d*\.\d+$/
Truth table66%2/3
A or B
A= $attribute_value =~ /^[+-]?\d+$/B= $attribute_value =~ /^[+-]?\d*\.\d+$/
ABresult
1X1
011
000
332 6 return "number";
333 }
334 2 return "string";
335 }
336 3 ▶ if (is_bool($attribute_value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_bool($attribute_value)) 1 2 3
337 1 return "boolean";
338 }
339 2 ▶ if (ref($attribute_value) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $attribute_value eq "ARRAY") 1 1 2
340 1 return "array";
341 }
342 1 ▶ if (ref($attribute_value) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $attribute_value eq "HASH") 1 0 1
343 1 return "object";
344 }
345 0 ▶ if (ref($attribute_value) eq 'SCALAR' && ($$attribute_value eq '0' || $$attribute_value eq '1')) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $attribute_value eq "SCALAR" and $$attribute_value eq 0 || $$attribute_value eq 1) 0 0 0
Condition0%0/6
ref $attribute_value eq "SCALAR" and $$attribute_value eq 0 || $$attribute_value eq 1
!ll&&!rl&&r
000
$$attribute_value eq 0 or $$attribute_value eq 1
l!l&&r!l&&!r
000
MC/DC0%0/3
ref $attribute_value eq "SCALAR" and $$attribute_value eq 0 || $$attribute_value eq 1
ref $attribute_value eq "SCALAR" $$attribute_value eq 0 $$attribute_value eq 1
Truth table0%0/4
A and B or C
A= ref $attribute_value eq "SCALAR"B= $$attribute_value eq 0C= $$attribute_value eq 1
ABCresult
0XX0
1000
11X1
1011
346 0 return "boolean";
347 }
348 0 return "unknown";
349 }
350  
351 4 1;
« GrowthBook.pm ↑ Summary GrowthBook/Experiment.pm »