Branch Coverage

blib/lib/JSON/Schema/Modern/Utilities.pm
Criterion Covered Total %
branch 235 276 85.1


line true false branch
95 0 0 eval { do { 'JSON::PP'->VERSION('4.11'); 1 } } ? :
45 0 eval { do { 'Cpanel::JSON::XS'->VERSION('4.38'); 1 } } ? :
105 113 87535 if ($type eq "null")
108 11231 76304 if ($type eq "boolean")
111 19901 56403 if ($type eq "object")
114 14093 42310 if ($type eq "array")
118 11971 16 if ($type eq "string" or $type eq "number" or $type eq "integer")
119 20 42274 unless defined $value
127 30307 11967 if ($type eq "string")
136 8048 3919 if ($type eq "number")
141 3919 0 if ($type eq "integer")
142 17 3902 if ($$config{'legacy_ints'}) { }
159 11 5 if ($type =~ /^reference to (.+)\z/u)
171 74954 48460 if ref $value eq "HASH"
172 11400 37060 if is_bool($value)
173 644 36416 unless defined $value
174 6021 30395 if ref $value eq "ARRAY"
177 880 29515 if (length(my $ref = ref $value))
179 327 320 !$$config{'legacy_ints'} && $value->is_int ? :
7 64 defined builtin::blessed($value) ? :
647 71 $ref eq 'Math::BigFloat' ? :
162 718 $ref eq 'Math::BigInt' ? :
195 22575 15 if $flags & 1024 and !($flags & 768) || do { BEGIN {${^WARNING_BITS} = "\xdd\x7f\xf7\xc3\xd7\xff\xf5\xff\xff\xff\xff\xff\xf5\xd7\xf4\xd7\x15\x51\x55\x15\x55\x55\x55"} 0 + $value eq $value }
197 316 6624 if ($$config{'legacy_ints'}) { }
200 313 3 $flags & 256 && !($flags & 512) ? :
316 0 if &created_as_number($value)
207 6567 42 int $value == $value ? :
6609 15 if &created_as_number($value)
219 60096 4 unless builtin::is_bool($value)
228 409 34374 unless ref $value eq "HASH"
247 3 17305 if grep(($types[$_] eq "ambiguous type"), (0, 1))
250 88 17217 if ($$state{"scalarref_booleans"})
251 14 74 if $types[0] eq "reference to SCALAR"
252 18 70 if $types[1] eq "reference to SCALAR"
255 16 17289 if ($$state{"stringy_numbers"})
256 5 3 int 0 + $x == $x ? :
8 8 if $types[0] eq "string" and &looks_like_number($x)
259 4 1 int 0 + $y == $y ? :
5 11 if $types[1] eq "string" and &looks_like_number($y)
263 1405 15900 if $types[0] ne $types[1]
264 36 15864 if $types[0] eq "null"
265 9495 6369 if $types[0] eq "string"
267 2106 4263 if grep(($types[0] eq $_), ("boolean", "number", "integer"))
271 1827 2436 if ($types[0] eq "object")
272 101 1726 if keys %$x != keys %$y
275 12 1714 unless (is_equal(my $arr_x = [sort(keys %$x)], my $arr_y = [sort(keys %$y)], scalar(my $s = {})))
283 187 3833 unless is_equal($$x{$property}, $$y{$property}, $state)
289 2436 0 if ($types[0] eq "array")
290 11 2425 if @$x != @$y
293 199 5462 unless is_equal($$x[$idx], $$y[$idx], $state)
311 280 1843 if (is_equal($$array[$idx0], $$array[$idx1], $state))
312 280 0 if exists $$state{"equal_indices"}
324 0 51662 if length $_[0] and substr($_[0], 0, 1) ne "/"
330 0 0 if length $_[0] and substr($_[0], 0, 1) ne "/"
344 3 0 ref $data eq 'ARRAY' ? :
7 3 ref $data eq 'HASH' ? :
11 10 ref $data eq '' ? :
353 2 17410 unless grep((ref $data eq $_), ("HASH", "ARRAY")) or defined wantarray
357 17412 56 unless (length $pointer)
358 17410 2 if (not ref $data or ref $data ne ref $value)
359 17408 2 if defined wantarray
363 1 1 if (ref $value eq "HASH")
364 0 1 unless ref $data
367 1 1 if (ref $value eq "ARRAY")
368 0 1 unless ref $data
375 56 0 length $pointer ? :
378 1 46 if @keys >= 2 and not $keys[1] =~ /^(?:\d+|-)\z/a and ref $data eq "ARRAY" and not defined wantarray
386 45 68 if not ref $$curp or ref $$curp eq "ARRAY" and not $key =~ /^(?:\d+|-)\z/a
394 25 2 $key =~ /^\d+\z/a ? :
86 27 ref $$curp eq 'HASH' || !($key =~ /^(?:\d+|-)\z/a) ? :
441 68 46 if (not $document and my $filename = get_schema_filename($uri))
443 0 68 unless -f $file
455 0 68 if $document->has_errors
465 11 103 unless $document
502 2 207 unless defined $type and defined $subtype
508 14 73 defined $3 ? :
87 0 /^($TOKEN)=($TOKEN|$QUOTED_STRING)\z/u ? :
515 0 207 if keys %$params > 64
517 71 136 keys %$params ? :
536 3 18 if $media_type_string eq "application/json"
543 0 18 if $media_type_string eq "application/octet-stream"
554 2 3 $$parameters{'charset'} ? :
559 2 0 $$parameters{'charset'} ? :
562 1 17 if $media_type_string eq "text/*"
575 1 16 if $media_type_string eq "application/x-www-form-urlencoded"
598 1 15 if $media_type_string eq "application/x-ndjson"
606 4 20 unless defined $matched_string
610 5 15 unless exists $$definition{"decode"}
616 0 16 if defined $decoder_sub and ref $decoder_sub ne "CODE"
617 0 16 if defined $encoder_sub and ref $encoder_sub ne "CODE"
620 1 15 unless $type
623 15 0 unless exists $$MEDIA_TYPES{$media_type_string}
625 1 14 if (CORE::any {is_equal($type, {%$_{"type", "subtype", "parameters"}});} values %$MEDIA_TYPES)
626 1 0 if $caller_addr == 1
644 2 5 unless exists $$MEDIA_TYPES{$media_type_string}
650 5 0 if $caller_addr == 1 or $$MEDIA_TYPES{$media_type_string}{"caller_addr"} = [grep(($_ != 1 && $_ != $caller_addr), @{$$MEDIA_TYPES{$media_type_string}{"caller_addr"}})]
656 0 29 if ref $content_ref ne "SCALAR"
659 2 27 unless $matched_string
663 1 26 unless exists $$definition{"decode"}
665 1 26 unless $$definition{"decode"}
673 0 8 if ref $content_ref ne "REF" and ref $content_ref ne "SCALAR"
676 0 8 unless $matched_string
680 0 8 unless exists $$definition{"encode"}
682 1 7 unless $$definition{"encode"}
694 38 50 if @$media_types and CORE::any {$_ eq $media_type_string;} @$media_types or not @$media_types and exists $$MEDIA_TYPES{$media_type_string}
697 1 49 unless $mt
699 11 38 @$media_types ? :
711 104 18 if not exists(($$mt{"parameters"} // {})->{$param}) or $$types{$candidate}{"parameters"}{$param} ne $$mt{"parameters"}{$param}
716 28 391 if $candidate eq "*/*"
719 35 356 if $$types{$candidate}{"subtype"} eq "*" and $$types{$candidate}{"type"} eq $$mt{"type"}
722 80 276 if ($$types{$candidate}{"type"} eq $$mt{"type"})
724 24 56 if $$types{$candidate}{"subtype"} eq $$mt{"subtype"}
728 2 54 if $$mt{"subtype"} =~ /^.+\+(.+)\z/u and $$types{$candidate}{"subtype"} eq $1
732 6 43 unless @matches
751 21446 12799 unless @extra_path or length $$state{"keyword_path"}
753 0 12799 @extra_path ? :
754 0 12799 unless length $fragment
775 0 13954 unless defined wantarray
779 1 13953 defined $sps && ref $sps eq 'ARRAY' ? :
799 266 13688 $$state{'traverse'} ? :
7131 6823 @args ? :
266 13688 $$state{'traverse'} ? :
821 3686 8342 $$state{'specification_version'} =~ /^draft[467]\z/u ? :
9390 2638 unless $$state{"collect_annotations"} & ($$state{"specification_version"} =~ /^draft[467]\z/u ? '18446744073709551359' : '18446744073709551615')
837 37 2601 $$state{'_unknown'} ? :
849 0 34 if $$state{"traverse"}
854 0 0 unless defined wantarray
855 0 0 unless exists $$schema{$$state{"keyword"}}
860 0 42348 unless defined wantarray
861 42331 17 if is_type($type, $$schema{$$state{"keyword"}})
862 3 14 $type =~ /^[aeiou]/u ? :
866 0 2875 unless defined wantarray
879 0 5886 unless defined wantarray
884 26 2595 if fc "Mojo::URL"->new($string)->to_unsafe_string ne fc $string or $string =~ /[^[:ascii:]]/u or $string =~ /#/u and not $string =~ /#\z/u and not $string =~ /#[A-Za-z_][A-Za-z0-9_:.-]*\z/u and not $string =~ m[#/(?:[^~]|~[01])*\z]u
897 0 6199 unless defined wantarray
902 8 1 if fc $uri->to_unsafe_string ne fc $string or $string =~ /[^[:ascii:]]/u or not $uri->is_abs or $string =~ /#/u and not $string =~ /#\z/u and not $string =~ /#[A-Za-z][A-Za-z0-9_:.-]*\z/u and not $string =~ m[#/(?:[^~]|~[01])*\z]u
919 102 1036 ref $$schema{$$state{'keyword'}} ? :
924 121 1184 is_bignum($value) ? :