Jmespath/TreeInterpreter.pm

filter: Statementstmt 97.2% 249 / 256 Branchbran 89.8% 88 / 98 Conditioncond 81.8% 27 / 33 MC/DCmcdc 72.7% 16 / 22 Subroutinesub 95.7% 45 / 47 Podpod 8.0% 2 / 25 totaltotal 88.7% 427 / 481 CC 71 SCAR 20.7
CC
71
Cov
94%
visit_slice
23.1
_is_false
13.2
visit_filter_projection
6.0
CRAP 7.9
« Jmespath/Lexer.pm ↑ Summary Jmespath/ArityException.pm »
1 package Jmespath::TreeInterpreter;
2 2 ▶use parent 'Jmespath::Visitor';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use List::Util qw(unpairs);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Scalar::Util qw(looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Jmespath::Expression;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Jmespath::Functions qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Jmespath::AttributeException;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Jmespath::IndexException;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Jmespath::UnknownFunctionException;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 2 my $COMPARATOR_FUNC = { 'le' => 'le',
17 'ne' => 'ne',
18 'lt' => 'lt',
19 'lte' => 'lte',
20 'eq' => 'eq',
21 'gt' => 'gt',
22 'gte' => 'gte' };
23  
24 2 my $MAP_TYPE = 'HASH';
25  
26 2 my $OPTIONS_DEFAULT = { hash_cls => undef,
27 custom_functions => undef };
28  
29 760 ▶sub new {
Subroutine new: called CC=4 SCAR=14.8
Pod undocumented
30 760 my ($class, $options) = @_;
31 760 my $self = $class->SUPER::new($options);
32 760 ▶ if ( not defined $options) { $options = $OPTIONS_DEFAULT; }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $options) 760 0 760
33 $self->{_hash_cls} = $options->{ hash_cls }
34 760 ▶ if defined $options->{hash_cls};
Branch: 1 branch
BranchTrueFalseTotal
if defined $options->{"hash_cls"} 0 760 760
35 0 $self->{_functions} = eval { 'use ' . $options->{custom_functions} }
36 760 ▶ if defined $options->{custom_functions};
Branch: 1 branch
BranchTrueFalseTotal
if defined $options->{"custom_functions"} 0 760 760
37  
38 760 return $self;
39 }
40  
41 5359 ▶sub visit {
Subroutine visit: called CC=1 SCAR=0.0
Pod undocumented
42 5359 my ($self, $node, $args) = @_;
43 5359 my $node_type = $node->{type};
44 5359 my $result;
45 5359 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
46 5359 my $method = \&{'visit_' . $node->{type}};
47 5359 $result = &$method( $self, $node, $args );
48 47 ▶ } catch {
Subroutine __ANON__: called CC=1 SCAR=0.0
49 47 $_->throw;
50 5359 };
51 5312 return $result;
52 }
53  
54 0 ▶sub default_visit {
Subroutine default_visit: not called CC=1 SCAR=6.9
Pod undocumented
55 0 my ($self, $node, @args) = @_;
56 0 Jmespath::NotImplementedException->new($node->{type})->throw;
57 0 return;
58 }
59  
60 =item visit_subexpression(node, value)
61  
62 Drills down into a subexpression in the AST graph.
63  
64 =cut
65  
66 172 ▶sub visit_subexpression {
Subroutine visit_subexpression: called CC=2 SCAR=6.9
Pod documented
67 172 my ($self, $node, $value) = @_;
68 172 my $result = $value;
69 172 foreach my $node (@{$node->{children}}) {
70 364 $result = $self->visit($node, $result);
71 }
72 172 return $result;
73 }
74  
75 =item visit_field(node, value)
76  
77 Returns the value of a field in the JSON data.
78  
79 value : the JSON data
80 node : the AST node being evaluated.
81  
82 =cut
83  
84 2024 ▶sub visit_field {
Subroutine visit_field: called CC=1 SCAR=0.0
Pod documented
85 2024 my ($self, $node, $value) = @_;
86 2024 my $result;
87 2024 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
88 2024 $result = $value->{$node->{value}};
89 19 ▶ } catch {
Subroutine __ANON__: called CC=1 SCAR=0.0
90 # when the field cannot be looked up, then the spec defines the
91 # return value as undef.
92 19 return;
93 2024 };
94 2024 return $result;
95 }
96  
97 466 ▶sub visit_comparator {
Subroutine visit_comparator: called CC=2 SCAR=7.1
Pod undocumented
98 466 my ($self, $node, $value) = @_;
99  
100 466 my $comparator_func = \&{'jp_' . $node->{value}};
101 466 ▶ if ( not defined &$comparator_func ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined &$comparator_func) 0 466 466
102 0 Jmespath::UnknownFunctionException
103 ->new({ message => 'unknown-function: Unknown function: ' . $comparator_func })
104 ->throw;
105 }
106  
107 466 return &$comparator_func( $self->visit( @{$node->{children}}[0], $value ),
108 466 $self->visit( @{$node->{children}}[1], $value ) );
109 }
110  
111 66 ▶sub visit_current {
Subroutine visit_current: called CC=1 SCAR=0.0
Pod undocumented
112 66 my ( $self, $node, $value ) = @_;
113 66 return $value;
114 }
115  
116 28 ▶sub visit_expref {
Subroutine visit_expref: called CC=1 SCAR=0.0
Pod undocumented
117 28 my ( $self, $node, $value ) = @_;
118 28 return Jmespath::Expression->new($node->{children}[0], $self);
119 }
120  
121 208 ▶sub visit_function_expression {
Subroutine visit_function_expression: called CC=3 SCAR=11.0
Pod undocumented
122 208 my ($self, $node, $value) = @_;
123 208 my $function = \&{'jp_' . $node->{value}};
124 208 ▶ if ( not defined &$function ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined &$function) 1 207 208
125 1 Jmespath::UnknownFunctionException
126 ->new({ message => 'unknown-function: Unknown function: ' . $function })
127 ->throw;
128 }
129  
130 207 my $resolved_args = [];
131 207 foreach my $child ( @{$node->{ children}} ) {
132 301 my $current = $self->visit($child, $value);
133 301 push @{$resolved_args}, $current;
134 }
135  
136 207 return &$function(@$resolved_args);
137 }
138  
139 82 ▶sub visit_filter_projection {
Subroutine visit_filter_projection: called CC=6 SCAR=17.9
Pod undocumented
140 82 my ($self, $node, $value) = @_;
141 82 my $base = $self->visit( @{$node->{children}}[0], $value);
142 82 ▶ return if ref($base) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $base ne "ARRAY" 8 74 82
143 74 ▶ return if scalar @$base == 0;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @$base == 0 0 74 74
144  
145 74 my $comparator_node = @{ $node->{children} }[2];
146 74 my $collected = [];
147 # use Data::Dumper;
148 74 foreach my $element (@$base) {
149 # print Dumper $comparator_node;
150 # print Dumper $element;
151 447 my $cnode_result = $self->visit($comparator_node, $element);
152 # print "cnode_result: $cnode_result\n";
153 447 ▶ if ( $self->_is_true($cnode_result) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_true($cnode_result)) 206 241 447
154 206 my $current = $self->visit(@{$node->{children}}[1], $element);
155 206 ▶ if (defined $current) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $current) 203 3 206
156 203 push @{$collected}, $current;
157 }
158 }
159 }
160 74 return $collected;
161 }
162  
163 93 ▶sub visit_flatten {
Subroutine visit_flatten: called CC=4 SCAR=13.9
Pod undocumented
164 93 my ($self, $node, $value) = @_;
165 93 my $base = $self->visit(@{$node->{'children'}}[0], $value);
166  
167 93 ▶ return if ref($base) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $base ne "ARRAY" 12 81 93
168  
169 81 my $merged_list = [];
170 81 foreach my $element (@$base) {
171 186 ▶ if (ref($element) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $element eq 'ARRAY') { } 87 99 186
172 87 push @$merged_list, @$element;
173 }
174 else {
175 99 push @$merged_list, $element;
176 }
177 }
178 81 return $merged_list;
179 }
180  
181 624 ▶sub visit_identity {
Subroutine visit_identity: called CC=3 SCAR=11.0
Pod undocumented
182 624 my ($self, $node, $value) = @_;
183 624 ▶ return if not defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 9 615 624
184 # SHEER NEGATIVE ENERGY HACKERY - FORCE NUMBERS TO BE NUMBERS
185 # THANK YOU JSON.PM
186 615 ▶ $value = 1 * $value if $value =~ /^[-][0-9]+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^[-][0-9]+$/ 0 615 615
187 615 return $value;
188 }
189  
190 222 ▶sub visit_index {
Subroutine visit_index: called CC=2 SCAR=7.0
Pod undocumented
191 222 my ($self, $node, $value) = @_;
192 222 ▶ return if ref($value) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $value ne "ARRAY" 53 169 222
193 169 my $result;
194 169 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
195 169 $result = $value->[ $node->{value} ];
196 0 ▶ } catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
197 0 Jmespath::IndexException->new({ message => 'Invalid index' })->throw;
198 169 };
199 169 return $result;
200 }
201  
202 213 ▶sub visit_index_expression {
Subroutine visit_index_expression: called CC=2 SCAR=6.9
Pod undocumented
203 213 my ($self, $node, $value) = @_;
204 213 my $result = $value;
205 213 foreach my $node (@{$node->{children}}) {
206 473 $result = $self->visit($node, $result);
207 }
208 212 return $result;
209 }
210  
211  
212 # Rules:
213 #
214  
215 38 ▶sub visit_slice {
Subroutine visit_slice: called CC=23 SCAR=31.4
Pod undocumented
216 38 my ($self, $node, $value) = @_;
217  
218 # Rule 08: If the element being sliced is an array and yields no
219 # results, the result MUST be an empty array.
220 38 my $selected = [];
221 38 my ($start, $stop);
222  
223 # Rule 05: If the given step is omitted, it it assumed to be 1.
224 38 ▶ my $step = defined $node->{children}->[2] ? $node->{children}->[2] : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $node->{'children'}[2] ? : 17 21 38
225  
226 # Rule 07: If the element being sliced is not an array, the result is null.
227 38 ▶ return if ref($value) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $value ne "ARRAY" 2 36 38
228  
229 # Rule 06: If the given step is 0, an error MUST be raised.
230 36 ▶ if ($step == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($step == 0) 1 35 36
231 1 Jmespath::ValueException->new(message => 'Invalid slice expression')->throw;
232 }
233 35 ▶ if (scalar @{$node->{children}} > 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$node->{"children"};} > 3) 0 35 35
234 0 Jmespath::ValueException->new(message => 'Invalid slice expression')->throw;
235 }
236  
237 # Rule 02: If no start position is given, it is assumed to be 0 if
238 # the given step is greater than 0 or the end of the array
239 # if the given step is less than 0.
240 35 ▶ if (not defined $node->{children}->[0] and $step > 0) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $node->{'children'}[0] and $step > 0) { } 13 22 35
elsif (not defined $node->{'children'}[0] and $step < 0) { } 4 18 22
elsif ($node->{'children'}[0] < 0) { } 1 17 18
Condition100%3/3
not defined $node->{"children"}[0] and $step > 0
!ll&&!rl&&r
18413
MC/DC100%2/2
not defined $node->{"children"}[0] and $step > 0
not defined $node->{"children"}[0] $step > 0
Truth table100%3/3
not(A) and B
A= not defined $node->{"children"}[0]B= $step > 0
ABresult
0X0
100
111
241 13 $start = 0;
242 }
243 ▶ elsif (not defined $node->{children}->[0] and $step < 0) {
Condition66%2/3
not defined $node->{"children"}[0] and $step < 0
!ll&&!rl&&r
1804
MC/DC50%1/2
not defined $node->{"children"}[0] and $step < 0
not defined $node->{"children"}[0] $step < 0
Truth table66%2/3
not(A) and B
A= not defined $node->{"children"}[0]B= $step < 0
ABresult
0X0
100
111
244 4 $start = scalar(@$value);
245 }
246 elsif ( $node->{children}->[0] < 0) {
247 1 $start = scalar(@$value) + $node->{children}->[0];
248 }
249 else {
250 17 $start = $node->{children}->[0];
251 }
252  
253 # Rule 01: If a negative start position is given, it is calculated as the
254 # total length of the array plus the given start position.
255 # if ($start < 0) {
256 # $start = scalar(@$value) + $start;
257 # }
258  
259 # Rule 04: If no stop position is given, it is assumed to be the
260 # length of the array if the given step is greater than 0
261 # or 0 if the given step is less than 0.
262 35 ▶ if (not defined $node->{children}->[1] and $step > 0) {
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $node->{'children'}[1] and $step > 0) { } 11 24 35
elsif (not defined $node->{'children'}[1] and $step < 0) { } 3 21 24
elsif ($node->{'children'}[1] < 0 and $step < 0) { } 2 19 21
elsif ($node->{'children'}[1] < 0 and $step > 0) { } 2 17 19
Condition100%3/3
not defined $node->{"children"}[1] and $step > 0
!ll&&!rl&&r
21311
MC/DC100%2/2
not defined $node->{"children"}[1] and $step > 0
not defined $node->{"children"}[1] $step > 0
Truth table100%3/3
not(A) and B
A= not defined $node->{"children"}[1]B= $step > 0
ABresult
0X0
100
111
263 11 $stop = scalar(@$value);
264 }
265 ▶ elsif (not defined $node->{children}->[1] and $step < 0) {
Condition66%2/3
not defined $node->{"children"}[1] and $step < 0
!ll&&!rl&&r
2103
MC/DC50%1/2
not defined $node->{"children"}[1] and $step < 0
not defined $node->{"children"}[1] $step < 0
Truth table66%2/3
not(A) and B
A= not defined $node->{"children"}[1]B= $step < 0
ABresult
0X0
100
111
266 3 $stop = -1;
267 }
268 # Rule 03: If a negative stop position is given, it is calculated as
269 # the total length of the array plus the given stop
270 # position.
271 ▶ elsif ($node->{children}->[1] < 0 and $step < 0) {
Condition100%3/3
$node->{"children"}[1] < 0 and $step < 0
!ll&&!rl&&r
1722
MC/DC100%2/2
$node->{"children"}[1] < 0 and $step < 0
$node->{"children"}[1] < 0 $step < 0
Truth table100%3/3
A and B
A= $node->{"children"}[1] < 0B= $step < 0
ABresult
0X0
100
111
272 2 $stop = scalar(@$value) + $node->{children}->[1];
273 }
274 ▶ elsif ($node->{children}->[1] < 0 and $step > 0) {
Condition66%2/3
$node->{"children"}[1] < 0 and $step > 0
!ll&&!rl&&r
1702
MC/DC50%1/2
$node->{"children"}[1] < 0 and $step > 0
$node->{"children"}[1] < 0 $step > 0
Truth table66%2/3
A and B
A= $node->{"children"}[1] < 0B= $step > 0
ABresult
0X0
100
111
275 2 $stop = scalar(@$value) + $node->{children}->[1];
276 }
277 else {
278 17 $stop = $node->{children}->[1];
279 }
280  
281 35 ▶ if ($step > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($step > 0) { } 27 8 35
282 27 ▶ for ( my $idx = $start; $idx < $stop; $idx += $step ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx < $stop) 169 11 180
283 169 push @$selected, @{$value}[$idx];
284 169 ▶ last if $idx == scalar(@$value) - 1
Branch: 1 branch
BranchTrueFalseTotal
if $idx == scalar(@$value) - 1 16 153 169
285 }
286 }
287 else {
288 8 ▶ for ( my $idx = $start; $idx > $stop; $idx += $step ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx > $stop) 53 4 57
289 53 push @$selected, @{$value}[$idx];
290 53 ▶ last if $idx == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $idx == 0 4 49 53
291 }
292 }
293 35 return $selected;
294 }
295  
296 68 ▶sub visit_key_val_pair {
Subroutine visit_key_val_pair: called CC=1 SCAR=0.0
Pod undocumented
297 68 my ($self, $node, $value) = @_;
298 68 return $self->visit(@{$node->{children}}[0], $value);
299 }
300  
301 559 ▶sub visit_literal {
Subroutine visit_literal: called CC=1 SCAR=0.0
Pod undocumented
302 559 my ($self, $node, $value) = @_;
303 559 return $node->{value};
304 }
305  
306 42 ▶sub visit_multi_select_hash {
Subroutine visit_multi_select_hash: called CC=4 SCAR=13.9
Pod undocumented
307 42 my ($self, $node, $value) = @_;
308 42 ▶ return if not defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 4 38 42
309 38 my %merged;
310 38 foreach my $child (@{$node->{children}}) {
311 68 my $result = $self->visit($child, $value);
312 68 ▶ return if not defined $child->{value};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $child->{"value"} 0 68 68
313 68 %merged = (%merged,( $child->{value} , $result ));
314 }
315 38 return \%merged;
316 }
317  
318 46 ▶sub visit_multi_select_list {
Subroutine visit_multi_select_list: called CC=5 SCAR=16.1
Pod undocumented
319 46 my ($self, $node, $value) = @_;
320 46 ▶ return if not defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 4 42 46
321 42 ▶ return if scalar @{$node->{children}} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$node->{"children"};} == 0 0 42 42
322  
323 42 my $collected = [];
324 42 foreach my $child ( @{$node->{children}}) {
325 76 my $result = $self->visit($child, $value);
326 76 ▶ my $to_collect = defined $result ? $self->visit($child, $value) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $result ? : 67 9 76
327 76 push @$collected, $to_collect;
328 }
329 42 return $collected;
330 }
331  
332 64 ▶sub visit_or_expression {
Subroutine visit_or_expression: called CC=2 SCAR=6.9
Pod undocumented
333 64 my ($self, $node, $value) = @_;
334 64 my $matched = $self->visit( @{$node->{children}}[0], $value );
335 64 ▶ if ( $self->_is_false($matched)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_false($matched)) 34 30 64
336 34 $matched = $self->visit(@{$node->{children}}[1], $value);
337 }
338 64 return $matched;
339 }
340  
341 36 ▶sub visit_and_expression {
Subroutine visit_and_expression: called CC=2 SCAR=6.9
Pod undocumented
342 36 my ($self, $node, $value) = @_;
343 36 my $matched = $self->visit(@{$node->{children}}[0], $value);
344 # return if the left side eval is found to be false
345 36 ▶ return $matched if $self->_is_false($matched);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_false($matched) 12 24 36
346 # if this isn't true then the whole evaluation is false
347 24 $matched = $self->visit(@{$node->{children}}[1], $value);
348 24 return $matched;
349 }
350  
351 24 ▶sub visit_not_expression {
Subroutine visit_not_expression: called CC=2 SCAR=6.9
Pod undocumented
352 24 my ($self, $node, $value) = @_;
353 24 my $original_result = $self->visit(@{$node->{children}}[0], $value);
354 24 ▶ return JSON::true if $self->_is_false($original_result) == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_false($original_result) == 1 14 10 24
355 10 return JSON::false;
356 }
357  
358 21 ▶sub visit_pipe {
Subroutine visit_pipe: called CC=2 SCAR=6.9
Pod undocumented
359 21 my ($self, $node, $value) = @_;
360 21 my $result = $value;
361 21 foreach my $node ( @{$node->{children}}) {
362 42 $result = $self->visit($node, $result);
363 }
364 21 return $result;
365 }
366  
367 200 ▶sub visit_projection {
Subroutine visit_projection: called CC=4 SCAR=13.9
Pod undocumented
368 200 my ($self, $node, $value) = @_;
369 200 my $base = $self->visit(@{$node->{children}}[0], $value);
370 199 ▶ return if ref($base) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $base ne "ARRAY" 30 169 199
371  
372 169 my $collected = [];
373 169 foreach my $element (@$base) {
374 720 my $current = $self->visit(@{$node->{children}}[1], $element);
375 720 ▶ push (@$collected, $current) if defined $current;
Branch: 1 branch
BranchTrueFalseTotal
if defined $current 522 198 720
376 }
377 169 return $collected;
378 }
379  
380 63 ▶sub visit_value_projection {
Subroutine visit_value_projection: called CC=4 SCAR=13.9
Pod undocumented
381 63 my ($self, $node, $value) = @_;
382 63 my $base = $self->visit(@{$node->{children}}[0], $value);
383 63 my @basekeys;
384 63 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
385 63 @basekeys = map { $base->{ $_ } } sort keys %$base ;
386 14 ▶ } catch {
Subroutine __ANON__: called CC=1 SCAR=0.0
387 14 return;
388 63 };
389 63 ▶ return if scalar @basekeys == 0;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @basekeys == 0 17 46 63
390 46 my $collected = [];
391 46 foreach my $element (@basekeys) {
392 103 my $current = $self->visit(@{$node->{children}}[1], $element);
393 103 ▶ push( @$collected, $current ) if defined $current;
Branch: 1 branch
BranchTrueFalseTotal
if defined $current 69 34 103
394 }
395 46 return $collected;
396 }
397  
398 571 ▶sub _is_false {
Subroutine _is_false: called CC=13 SCAR=25.8
399 571 my ($self, $value) = @_;
400 571 ▶ return 1 if not defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 14 557 571
401 # return 1 if JSON::is_bool($value) and $value == JSON::false;
402 # return 0 if JSON::is_bool($value) and $value == JSON::true;
403 557 ▶ return 1 if ref($value) eq 'JSON::PP::Boolean' and $value == JSON::false;
Branch: 1 branch
BranchTrueFalseTotal
if ref $value eq "JSON::PP::Boolean" and $value == JSON::false() 273 284 557
Condition100%3/3
ref $value eq "JSON::PP::Boolean" and $value == JSON::false()
!ll&&!rl&&r
41243273
MC/DC100%2/2
ref $value eq "JSON::PP::Boolean" and $value == JSON::false()
ref $value eq "JSON::PP::Boolean" $value == JSON::false()
Truth table100%3/3
A and B
A= ref $value eq "JSON::PP::Boolean"B= $value == JSON::false()
ABresult
0X0
100
111
404 284 ▶ return 0 if ref($value) eq 'JSON::PP::Boolean' and $value == JSON::true;
Branch: 1 branch
BranchTrueFalseTotal
if ref $value eq "JSON::PP::Boolean" and $value == JSON::true() 243 41 284
Condition66%2/3
ref $value eq "JSON::PP::Boolean" and $value == JSON::true()
!ll&&!rl&&r
410243
MC/DC50%1/2
ref $value eq "JSON::PP::Boolean" and $value == JSON::true()
ref $value eq "JSON::PP::Boolean" $value == JSON::true()
Truth table66%2/3
A and B
A= ref $value eq "JSON::PP::Boolean"B= $value == JSON::true()
ABresult
0X0
100
111
405 41 ▶ return 1 if ref($value) eq 'ARRAY' and scalar @$value == 0;
Branch: 1 branch
BranchTrueFalseTotal
if ref $value eq "ARRAY" and scalar @$value == 0 10 31 41
Condition100%3/3
ref $value eq "ARRAY" and scalar @$value == 0
!ll&&!rl&&r
29210
MC/DC100%2/2
ref $value eq "ARRAY" and scalar @$value == 0
ref $value eq "ARRAY" scalar @$value == 0
Truth table100%3/3
A and B
A= ref $value eq "ARRAY"B= scalar @$value == 0
ABresult
0X0
100
111
406 31 ▶ return 1 if ref($value) eq 'HASH' and scalar keys %$value == 0;
Branch: 1 branch
BranchTrueFalseTotal
if ref $value eq "HASH" and scalar keys %$value == 0 2 29 31
Condition100%3/3
ref $value eq "HASH" and scalar keys %$value == 0
!ll&&!rl&&r
2722
MC/DC100%2/2
ref $value eq "HASH" and scalar keys %$value == 0
ref $value eq "HASH" scalar keys %$value == 0
Truth table100%3/3
A and B
A= ref $value eq "HASH"B= scalar keys %$value == 0
ABresult
0X0
100
111
407 29 ▶ return 1 if ref($value) eq 'SCALAR' and $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if ref $value eq "SCALAR" and $value eq "" 0 29 29
Condition33%1/3
ref $value eq "SCALAR" and $value eq ""
!ll&&!rl&&r
2900
MC/DC0%0/2
ref $value eq "SCALAR" and $value eq ""
ref $value eq "SCALAR" $value eq ""
Truth table33%1/3
A and B
A= ref $value eq "SCALAR"B= $value eq ""
ABresult
0X0
100
111
408 29 ▶ return 1 if $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "" 2 27 29
409 27 return 0;
410 }
411  
412 447 ▶sub _is_true {
Subroutine _is_true: called CC=1 SCAR=0.0
413 447 return ! shift->_is_false(shift);
414 }
415  
416 2 1;
417  
418 __END__
« Jmespath/Lexer.pm ↑ Summary Jmespath/ArityException.pm »