Branch Coverage

blib/lib/JQ/Lite/Util/Parsing.pm
Criterion Covered Total %
branch 291 434 67.0


line true false branch
18 352 0 if ($decoder->can("boolean_values"))
33 6 6888 if (defined $text and &is_utf8($text, 1))
43 0 22 unless defined $text and length $text
57 27 204 if (defined $string)
58 0 27 if ($escape)
63 0 27 if ($char eq "\\")
68 6 21 if ($char eq $string)
75 6 198 if ($char eq "'" or $char eq "\"")
80 6 192 if (exists $pairs{$char})
85 8 184 if (exists $closing{$char})
86 2 6 unless @stack
88 0 6 unless $pairs{$open} eq $char
99 0 6040 unless defined $text
106 2 20 unless _are_brackets_balanced($inner)
117 0 8 unless defined $text
135 1 102 if (defined $string)
136 0 1 if ($escape)
141 0 1 if ($char eq "\\")
146 1 0 if ($char eq $string)
153 1 101 if ($char eq "'" or $char eq "\"")
158 0 101 if (exists $pairs{$char})
163 0 101 if (exists $closing{$char})
164 0 0 unless @stack
166 0 0 unless $pairs{$open} eq $char
170 92 9 unless $char eq ";"
172 9 0 unless (@stack)
179 8 0 if $start <= length $text
187 0 1739 unless defined $text
207 1528 19362 if (defined $string)
208 8 1520 if ($escape)
213 8 1512 if ($char eq "\\")
218 336 1176 if ($char eq $string)
225 336 19026 if ($char eq "'" or $char eq "\"")
230 776 18250 if (exists $pairs{$char})
235 15265 0 unless ($in_try or @stack or defined $string)
236 14 15251 if (substr($text, $i) =~ /^try\b/)
242 101 85 if ($in_try and not @stack and not defined $string)
243 10 91 if (substr($text, $i) =~ /^catch\b/)
249 776 17450 if (exists $closing{$char})
250 0 776 unless @stack
252 0 776 unless $pairs{$open} eq $char
256 16968 482 unless $char eq "|"
257 2 480 if $in_try
258 0 480 if (substr($text, $i, 2) eq "||")
263 474 6 unless (@stack)
270 1739 0 if $start <= $length
278 0 1494 unless defined $text
296 1635 13572 if (defined $string)
297 8 1627 if ($escape)
302 8 1619 if ($char eq "\\")
307 339 1280 if ($char eq $string)
314 339 13233 if ($char eq "'" or $char eq "\"")
319 706 12527 if (exists $pairs{$char})
324 706 11821 if (exists $closing{$char})
325 0 706 unless @stack
327 0 706 unless $pairs{$open} eq $char
331 11695 126 unless $char eq ","
333 38 88 unless (@stack)
340 1494 0 if $start <= length $text
348 0 1933 unless defined $text and defined $operator and length $operator == 1
364 1473 15536 if (defined $string)
365 6 1467 if ($escape)
370 6 1461 if ($char eq "\\")
375 322 1139 if ($char eq $string)
382 322 15214 if ($char eq "'" or $char eq "\"")
387 711 14503 if (exists $pairs{$char})
392 711 13792 if (exists $closing{$char})
393 0 711 unless @stack
395 0 711 if $pairs{$open} ne $char
399 13724 68 if $char ne $operator
401 51 17 unless (@stack)
402 51 0 if ($operator eq "+" or $operator eq "-")
403 51 0 $i > 0 ? :
404 51 0 $i + 1 < length $text ? :
405 0 51 if ($prev =~ /[eE]/ and $next =~ /[0-9]/)
408 2 49 if ($next eq "=")
425 0 49 unless defined $text
441 132 181 if (defined $string)
442 0 132 if ($escape)
447 0 132 if ($char eq "\\")
452 24 108 if ($char eq $string)
459 24 157 if ($char eq "'" or $char eq "\"")
464 0 157 if (exists $pairs{$char})
469 0 157 if (exists $closing{$char})
470 0 0 unless @stack
472 0 0 unless $pairs{$open} eq $char
476 111 46 if $char ne ":"
478 46 0 unless (@stack)
491 0 13 unless defined $raw
495 0 13 if $text eq ""
498 2 0 unless ($@ or ref $decoded)
502 0 11 if ($text =~ /^'(.*)'$/s)
515 0 0 unless @parts == 2
523 0 2126 unless defined $text
524 0 2126 if $pos < 0
527 27 2099 if $pos + $kw_len > length $text
528 2054 45 if substr($text, $pos, $kw_len) ne $keyword
530 9 36 $pos == 0 ? :
531 36 9 $pos + $kw_len < length $text ? :
533 0 45 if $before =~ /[A-Za-z0-9_]/
534 0 45 if $after =~ /[A-Za-z0-9_]/
542 0 1274 unless defined $expr
546 1265 9 unless $copy =~ /^if\b/
551 0 9 unless _matches_keyword($copy, $pos, "if")
568 0 333 if ($escape)
575 0 333 if ($in_single)
576 0 0 if ($char eq '\\') { }
0 0 elsif ($char eq q[']) { }
587 36 297 if ($in_double)
588 0 36 if ($char eq '\\') { }
14 22 elsif ($char eq '"') { }
599 0 297 if ($char eq "'")
606 14 283 if ($char eq "\"")
613 1 282 if (_matches_keyword($copy, $pos, "if"))
620 11 1 if (_matches_keyword($copy, $pos, "then") and $depth == 1 and $state eq "condition")
623 0 11 unless defined $condition and length $condition
631 2 0 if (_matches_keyword($copy, $pos, "elif") and $depth == 1 and $state eq "then")
634 0 2 unless length $then_expr
636 0 2 unless defined $condition
646 8 1 if (_matches_keyword($copy, $pos, "else") and $depth == 1 and $state eq "then")
649 0 8 unless length $then_expr
651 0 8 unless defined $condition
661 10 251 if (_matches_keyword($copy, $pos, "end"))
662 9 1 if ($depth == 1) { }
663 1 8 if ($state eq 'then') { }
8 0 elsif ($state eq 'else') { }
0 0 elsif ($state eq 'condition') { }
666 0 1 unless length $then_expr
668 0 1 unless defined $condition
674 8 0 length $else ? :
694 1 250 if (_matches_keyword($copy, $pos, "then") and $depth > 1)
700 0 250 if (_matches_keyword($copy, $pos, "elif") and $depth > 1)
706 1 249 if (_matches_keyword($copy, $pos, "else") and $depth > 1)
716 0 9 unless @branches
718 0 9 if ($pos < $len)
721 0 0 if $remaining =~ /\S/
733 0 1265 unless defined $expr
736 1261 4 unless $copy =~ /^reduce\s+(.+?)\s+as\s+\$(\w+)\s*\((.*)\)$/s
740 0 4 unless @parts == 2
758 0 1278 unless defined $expr
761 1274 4 unless $copy =~ /^foreach\s+(.+?)\s+as\s+\$(\w+)\s*\((.*)\)$/s
765 0 4 unless @parts >= 2 and @parts <= 3
770 0 12 unless defined $_
774 1 3 if (defined $extract_expr)
790 0 48 unless defined $self and ref $self eq "JQ::Lite"
791 0 48 unless defined $name and length $name
794 1 47 unless exists $vars->{$name}
803 1 47 unless $exists
805 38 9 unless defined $suffix and $suffix =~ /\S/
811 9 0 $ok ? :
817 0 771 unless defined $expr
821 0 771 if $copy eq ""
823 62 709 if (_looks_like_expression($copy))
851 0 17 if not defined $path or $path eq ""
853 17 0 @values ? :
859 6 49 if ($ok)
865 5 753 if (@pipeline_parts > 1)
866 5 0 if (defined $self and $self->can("run_query"))
873 32 721 if ($copy =~ /^\$(\w+)(.*)$/s)
879 1 720 if ($copy =~ /^\[(.*)$/s)
883 31 690 if ($copy eq ".")
887 128 562 if ($copy =~ /^\.(.*)$/s)
891 70 0 unless ($path =~ /\s/ or $path =~ m[[+\-*/]])
892 0 70 unless defined $context
893 0 70 if $path eq ""
901 37 583 if (defined $lhs_expr and defined $rhs_expr)
905 37 0 if (length $lhs_expr and length $rhs_expr)
908 37 0 if ($lhs_ok) { }
909 37 0 @$lhs_values ? :
913 0 0 @outputs ? :
918 37 0 if ($rhs_ok) { }
919 37 0 @$rhs_values ? :
923 0 0 @outputs ? :
932 47 536 unless ($@)
936 0 536 if ($copy =~ /^'(.*)'$/s)
942 13 523 if (not $copy =~ /\bthen\b/i || $copy =~ /\belse\b/i || $copy =~ /\bend\b/i and $copy =~ /(?:==|!=|>=|<=|>|<|\band\b|\bor\b|\bcontains\b|\bhas\b|\bmatch\b)/)
948 5 8 $bool ? :
958 0 46 unless defined $left
959 0 46 unless defined $right
961 0 46 if (ref $left eq "JSON::PP::Boolean")
962 0 0 $left ? :
965 0 46 if (ref $right eq "JSON::PP::Boolean")
966 0 0 $right ? :
969 45 0 unless (ref $left or ref $right)
973 13 32 if ($left_is_string or $right_is_string)
974 3 10 unless $left_is_string and $right_is_string
975 0 10 unless defined $left
976 0 10 unless defined $right
980 32 0 if (&looks_like_number($left) and &looks_like_number($right))
987 0 1 if (ref $left eq "ARRAY" and ref $right eq "ARRAY")
991 0 1 if (ref $left eq "ARRAY")
995 0 1 if (ref $right eq "ARRAY")
999 1 0 if (ref $left eq "HASH" and ref $right eq "HASH")
1003 0 0 if not ref $left and ref $right eq "HASH"
1004 0 0 if ref $left eq "HASH" and not ref $right
1014 0 30 unless defined $value
1016 0 30 if (ref $value eq "JSON::PP::Boolean")
1017 0 0 $value ? :
1020 0 30 if ref $value
1021 0 30 unless &looks_like_number($value)
1029 0 3 unless defined $value
1031 0 3 if (ref $value eq "JSON::PP::Boolean")
1032 0 0 $value ? :
1035 0 3 if (ref $value)
1042 0 3 unless length $text and &looks_like_number($text)
1050 0 2118 unless defined $expr
1052 35 2083 if $expr =~ /\b(?:floor|ceil|round|tonumber)\b/
1053 24 2059 if $expr =~ /^\s*[\{\[]/
1054 427 1632 if $expr =~ /^[A-Za-z_]\w*\s*\(/
1055 43 1589 if $expr =~ m[[\-*/%]]
1056 43 1546 if $expr =~ /(?:==|!=|>=|<=|>|<|\band\b|\bor\b)/i
1064 0 1184 unless defined $expr
1065 389 795 if $expr =~ /[()]/
1066 0 795 if $expr =~ /(?:==|!=|>=|<=|=>|=<)/
1097 1 15 if ($raw =~ /^\.(.+)$/)
1102 11 4 unless ($@)
1106 2 2 if ($raw =~ /^'(.*)'$/)