Compare/JSON.pm

filter: Statementstmt 100% 33 / 33 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 80.0% 4 / 5 totaltotal 94.4% 51 / 54 CC 4 SCAR 4.8
CC
4
Cov
95%
verify
3.0
init
2.0
BEGIN
1.0
CRAP 1.6
↑ Summary Tools/JSON.pm »
1 package Test2::Compare::JSON;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use base 'Test2::Compare::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use Test2::Util::HashBase qw/inref json/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 9 ▶sub init {
Subroutine init: called CC=2 SCAR=7.1
Pod undocumented
12 9 my $self = shift;
13  
14 9 ▶ croak "'inref' must be a reference" unless ref $self->{+INREF};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{"inref"} 0 9 9
15  
16 9 $self->SUPER::init();
17 }
18  
19 3 ▶sub operator { 'JSON' }
Subroutine operator: called CC=1 SCAR=0.0
Pod documented
20  
21 3 ▶sub name { '' . $_[0]->{+INREF} }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
22  
23 9 ▶sub verify {
Subroutine verify: called CC=3 SCAR=11.0
Pod documented
24 9 my $self = shift;
25 9 my %params = @_;
26 9 my ($got, $exists) = @params{qw/got exists/};
27  
28 9 ▶ return 0 unless $exists;
Branch: 1 branch
BranchTrueFalseTotal
unless $exists 0 9 9
29  
30 9 eval {
31 9 $self->{+JSON}->decode($got);
32 };
33  
34 9 ▶ return $@ ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 1 8 9
35 }
36  
37 8 ▶sub deltas {
Subroutine deltas: called CC=1 SCAR=0.0
Pod documented
38 8 my $self = shift;
39 8 my %params = @_;
40 8 my ($got, $convert, $seen) = @params{qw/got convert seen/};
41  
42 8 my $check = $convert->($self->{+INREF});
43  
44 return $check->run(
45 id => [META => 'JSON'],
46 convert => $convert,
47 seen => $seen,
48 8 got => $self->{+JSON}->decode($got),
49 exists => 1,
50 );
51 }
52  
53 3 1;
↑ Summary Tools/JSON.pm »