blib/lib/Test/Deep/JSON.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 11 / 11 Podpod 25.0% 1 / 4 totaltotal 91.8% 56 / 61 CC 4 SCAR 4.5
CC
4
Cov
98%
diagnostics
3.0
descend
2.0
BEGIN
1.0
CRAP 1.6
↑ Summary
1 package Test::Deep::JSON;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use 5.008_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Test::Deep ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Test::Deep::Cmp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Exporter::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our $VERSION = '0.05';
11  
12 2 our @EXPORT = qw(json);
13  
14 6 ▶sub json ($) {
Subroutine json: called CC=1 SCAR=0.0
Pod documented
15 6 my ($expected) = @_;
16 6 return __PACKAGE__->new($expected);
17 }
18  
19 6 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
20 6 my ($self, $expected) = @_;
21 6 $self->{val} = $expected;
22 }
23  
24 6 ▶sub descend {
Subroutine descend: called CC=2 SCAR=6.9
Pod undocumented
25 6 my ($self, $got) = @_;
26 6 my $parsed = eval { decode_json($got) };
27 6 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 5 6
28 1 $self->{error} = $@;
29 1 return 0;
30 }
31 5 return Test::Deep::wrap($self->{val})->descend($parsed);
32 }
33  
34 2 ▶sub diagnostics {
Subroutine diagnostics: called CC=3 SCAR=11.0
Pod undocumented
35 2 my $self = shift;
36 2 ▶ return $self->{error} if defined $self->{error} && length $self->{error};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"error"} and length $self->{"error"} 1 1 2
Condition66%2/3
defined $self->{"error"} and length $self->{"error"}
!ll&&!rl&&r
101
MC/DC50%1/2
defined $self->{"error"} and length $self->{"error"}
defined $self->{"error"} length $self->{"error"}
Truth table66%2/3
A and B
A= defined $self->{"error"}B= length $self->{"error"}
ABresult
0X0
100
111
37 1 return $self->{val}->diagnostics(@_);
38 }
39  
40 2 1;
41  
42 __END__
↑ Summary