line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::JSON; |
2
|
3
|
|
|
3
|
|
25
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
72
|
|
3
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
63
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
12
|
use base 'Test2::Compare::Base'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
565
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
14272
|
use Carp qw/croak/; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
130
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
31
|
use Test2::Util::HashBase qw/inref json/; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
19
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub init { |
12
|
7
|
|
|
7
|
0
|
142
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
7
|
50
|
|
|
|
27
|
croak "'inref' must be a reference" unless ref $self->{+INREF}; |
15
|
|
|
|
|
|
|
|
16
|
7
|
|
|
|
|
27
|
$self->SUPER::init(); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
3
|
1
|
1533
|
sub operator { 'JSON' } |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
3
|
1
|
86
|
sub name { '' . $_[0]->{+INREF} } |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub verify { |
24
|
7
|
|
|
7
|
1
|
7024
|
my $self = shift; |
25
|
7
|
|
|
|
|
19
|
my %params = @_; |
26
|
7
|
|
|
|
|
18
|
my ($got, $exists) = @params{qw/got exists/}; |
27
|
|
|
|
|
|
|
|
28
|
7
|
50
|
|
|
|
17
|
return 0 unless $exists; |
29
|
|
|
|
|
|
|
|
30
|
7
|
|
|
|
|
13
|
eval { |
31
|
7
|
|
|
|
|
53
|
$self->{+JSON}->decode($got); |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
7
|
100
|
|
|
|
27
|
return $@ ? 0 : 1; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub deltas { |
38
|
6
|
|
|
6
|
1
|
33
|
my $self = shift; |
39
|
6
|
|
|
|
|
16
|
my %params = @_; |
40
|
6
|
|
|
|
|
16
|
my ($got, $convert, $seen) = @params{qw/got convert seen/}; |
41
|
|
|
|
|
|
|
|
42
|
6
|
|
|
|
|
14
|
my $check = $convert->($self->{+INREF}); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return $check->run( |
45
|
|
|
|
|
|
|
id => [META => 'JSON'], |
46
|
|
|
|
|
|
|
convert => $convert, |
47
|
|
|
|
|
|
|
seen => $seen, |
48
|
6
|
|
|
|
|
369
|
got => $self->{+JSON}->decode($got), |
49
|
|
|
|
|
|
|
exists => 1, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |