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