| 1 | package JQ::Lite::Util; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 182 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 182 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 182 | ▶ | use JSON::PP (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 182 | ▶ | use List::Util qw(sum min max); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 182 | ▶ | use Scalar::Util qw(looks_like_number); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 182 | ▶ | use MIME::Base64 qw(encode_base64 decode_base64); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 182 | ▶ | use Encode qw(encode is_utf8); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 182 | ▶ | use B (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 182 | ▶ | use JQ::Lite::Expression (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 182 | ▶ | use JQ::Lite::Error (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 182 | require JQ::Lite::Util::Parsing; | |||||||||||||||||||||||||||
| 16 | 182 | require JQ::Lite::Util::Paths; | |||||||||||||||||||||||||||
| 17 | 182 | require JQ::Lite::Util::Transform; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 182 | my $decode_json_impl = \&_decode_json; | |||||||||||||||||||||||||||
| 20 | { | ||||||||||||||||||||||||||||
| 21 | 182 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 7113 | ▶ | *_decode_json = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=29.5
| |||||||||||||||||||||||||||||
| 23 | 7113 | my @args = @_; | |||||||||||||||||||||||||||
| 24 | 7113 | my $want_structured = (caller)[0] eq 'JQ::Lite'; | |||||||||||||||||||||||||||
| 25 | 7113 | ▶ | return $decode_json_impl->(@args) unless $want_structured; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | my ($value, $ok, $err); | |||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||
| 29 | 0 | local $@; | |||||||||||||||||||||||||||
| 30 | 0 | $ok = eval { | |||||||||||||||||||||||||||
| 31 | 0 | $value = $decode_json_impl->(@args); | |||||||||||||||||||||||||||
| 32 | 0 | 1; | |||||||||||||||||||||||||||
| 33 | }; | ||||||||||||||||||||||||||||
| 34 | 0 | $err = $@; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | return $value if $ok; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | die $err if ref($err) && eval { $err->isa('JQ::Lite::Error') }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $err and eval {
do {
$err->isa("JQ::Lite::Error")
}
}
MC/DC0%0/2
ref $err and eval {
do {
$err->isa("JQ::Lite::Error")
}
}
ref $err
eval {
do {
$err->isa("JQ::Lite::Error")
}
}
Truth table0%0/3
A and B
A= ref $errB= eval {
do {
$err->isa("JQ::Lite::Error")
}
}
| |||||||||||||||||||||||||||||
| 38 | 0 | die JQ::Lite::Error::Input->new(message => $err); | |||||||||||||||||||||||||||
| 39 | 182 | }; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 182 | my $expression_evaluate_impl = \&JQ::Lite::Expression::evaluate; | |||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||
| 44 | 182 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | 66 | ▶ | *JQ::Lite::Expression::evaluate = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||
| 46 | 66 | my ($value, $ok, $err); | |||||||||||||||||||||||||||
| 47 | { | ||||||||||||||||||||||||||||
| 48 | 66 | local $@; | |||||||||||||||||||||||||||
| 49 | 66 | $ok = eval { | |||||||||||||||||||||||||||
| 50 | 66 | $value = [ $expression_evaluate_impl->(@_) ]; | |||||||||||||||||||||||||||
| 51 | 58 | 1; | |||||||||||||||||||||||||||
| 52 | }; | ||||||||||||||||||||||||||||
| 53 | 66 | $err = $@; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 66 | ▶ | return @{$value} if $ok; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | die $err if ref($err) && eval { $err->isa('JQ::Lite::Error') }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $err and eval {
do {
$err->isa("JQ::Lite::Error")
}
}
MC/DC0%0/2
ref $err and eval {
do {
$err->isa("JQ::Lite::Error")
}
}
ref $err
eval {
do {
$err->isa("JQ::Lite::Error")
}
}
Truth table33%1/3
A and B
A= ref $errB= eval {
do {
$err->isa("JQ::Lite::Error")
}
}
| |||||||||||||||||||||||||||||
| 57 | 8 | die JQ::Lite::Error::Evaluation->new(message => $err); | |||||||||||||||||||||||||||
| 58 | 182 | }; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 182 | 1; | |||||||||||||||||||||||||||