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