blib/lib/JQ/Lite/Util.pm

filter: Statementstmt 83.3% 60 / 72 Branchbran 40.0% 4 / 10 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 14 / 14 Podpod n/a totaltotal 74.5% 79 / 106 CC 8 SCAR 17.8
CC
8
Cov
74%
__ANON__
19.1
__ANON__
4.1
BEGIN
1.0
CRAP 5.9
« lib/JQ/Lite/Value.pm ↑ Summary blib/lib/JQ/Lite/Builtin/Type.pm »
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
BranchTrueFalseTotal
unless $want_structured 7113 0 7113
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
BranchTrueFalseTotal
if $ok 0 0 0
37 0 ▶ die $err if ref($err) && eval { $err->isa('JQ::Lite::Error') };
Branch: 1 branch
BranchTrueFalseTotal
if ref $err and eval { do { $err->isa("JQ::Lite::Error") } } 0 0 0
Condition0%0/3
ref $err and eval { do { $err->isa("JQ::Lite::Error") } }
!ll&&!rl&&r
000
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") } }
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if $ok 58 8 66
56 0 ▶ die $err if ref($err) && eval { $err->isa('JQ::Lite::Error') };
Branch: 1 branch
BranchTrueFalseTotal
if ref $err and eval { do { $err->isa("JQ::Lite::Error") } } 0 8 8
Condition33%1/3
ref $err and eval { do { $err->isa("JQ::Lite::Error") } }
!ll&&!rl&&r
800
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") } }
ABresult
0X0
100
111
57 8 die JQ::Lite::Error::Evaluation->new(message => $err);
58 182 };
59 }
60  
61 182 1;
« lib/JQ/Lite/Value.pm ↑ Summary blib/lib/JQ/Lite/Builtin/Type.pm »