line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::MasterData::Declare::Compare::RowHash; |
2
|
4
|
|
|
4
|
|
84
|
use 5.010001; |
|
4
|
|
|
|
|
17
|
|
3
|
4
|
|
|
4
|
|
26
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
99
|
|
4
|
4
|
|
|
4
|
|
27
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
132
|
|
5
|
4
|
|
|
4
|
|
26
|
use utf8; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
31
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
125
|
use parent "Test2::Compare::Hash"; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
34
|
|
8
|
4
|
|
|
4
|
|
325
|
use Test2::Util::HashBase qw/json_checks/; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
39
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
807
|
use Carp qw/croak/; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
270
|
|
11
|
4
|
|
|
4
|
|
29
|
use Scalar::Util qw/blessed/; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
2362
|
|
12
|
|
|
|
|
|
|
|
13
|
10
|
|
|
10
|
0
|
62
|
sub object_base { "Test::MasterData::Declare::Row" } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub verify { |
16
|
10
|
|
|
10
|
1
|
334
|
my $self = shift; |
17
|
10
|
|
|
|
|
43
|
my %params = @_; |
18
|
10
|
|
|
|
|
41
|
my ($got, $exists) = @params{qw/got exists/}; |
19
|
|
|
|
|
|
|
|
20
|
10
|
50
|
|
|
|
35
|
return 0 unless $exists; |
21
|
10
|
50
|
|
|
|
32
|
return 0 unless $got; |
22
|
10
|
50
|
|
|
|
33
|
return 0 unless ref($got); |
23
|
10
|
50
|
|
|
|
51
|
return 0 unless blessed($got); |
24
|
10
|
50
|
|
|
|
41
|
return 0 unless $got->isa($self->object_base); |
25
|
10
|
|
|
|
|
44
|
return 1; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub add_json_field { |
29
|
2
|
|
|
2
|
0
|
7
|
my $self = shift; |
30
|
2
|
|
|
|
|
10
|
my ($name, @path) = @_; |
31
|
2
|
|
|
|
|
7
|
my $check = pop @path; |
32
|
|
|
|
|
|
|
|
33
|
2
|
50
|
|
|
|
11
|
croak "column name is required" |
34
|
|
|
|
|
|
|
unless defined $name; |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
100
|
|
|
17
|
$self->{+JSON_CHECKS} ||= []; |
37
|
2
|
|
|
|
|
5
|
push @{$self->{+JSON_CHECKS}} => [$name, \@path, $check]; |
|
2
|
|
|
|
|
20
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _wrap_check { |
41
|
13
|
|
|
13
|
|
46
|
my ($class, $got, $check) = @_; |
42
|
|
|
|
|
|
|
|
43
|
13
|
|
|
|
|
59
|
my $ccheck = $check->clone; |
44
|
13
|
|
|
|
|
227
|
$ccheck->set_file($got->file); |
45
|
13
|
|
|
|
|
183
|
$ccheck->set_lines([$got->lineno]); |
46
|
|
|
|
|
|
|
|
47
|
13
|
|
|
|
|
168
|
return $ccheck; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub deltas { |
51
|
10
|
|
|
10
|
1
|
76
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
10
|
|
|
|
|
43
|
my %params = @_; |
54
|
10
|
|
|
|
|
36
|
my ($got, $convert, $seen) = @params{qw/got convert seen/}; |
55
|
10
|
|
|
|
|
51
|
my $row = $got->row; |
56
|
10
|
|
|
|
|
32
|
$params{got} = $row; |
57
|
|
|
|
|
|
|
my $wrap_convert = sub { |
58
|
13
|
|
|
13
|
|
267
|
my $check = $convert->(@_); |
59
|
13
|
|
|
|
|
1074
|
return $self->_wrap_check($got, $check); |
60
|
10
|
|
|
|
|
63
|
}; |
61
|
10
|
|
|
|
|
30
|
$params{convert} = $wrap_convert; |
62
|
|
|
|
|
|
|
|
63
|
10
|
|
|
|
|
93
|
my @deltas = $self->SUPER::deltas(%params); |
64
|
|
|
|
|
|
|
|
65
|
10
|
|
|
|
|
728
|
my $json_checks = $self->{+JSON_CHECKS}; |
66
|
10
|
|
|
|
|
33
|
for my $json_check (@$json_checks) { |
67
|
6
|
|
|
|
|
88
|
my ($json_column, $path, $check) = @$json_check; |
68
|
6
|
|
|
|
|
23
|
my $converted_check = $wrap_convert->($check); |
69
|
|
|
|
|
|
|
|
70
|
6
|
|
|
|
|
29
|
my $out = $got->json($json_column, @$path); |
71
|
6
|
50
|
|
|
|
55
|
push @deltas => $converted_check->run( |
72
|
|
|
|
|
|
|
id => ["" => join ".", $json_column, @$path], |
73
|
|
|
|
|
|
|
convert => $wrap_convert, |
74
|
|
|
|
|
|
|
seen => $seen, |
75
|
|
|
|
|
|
|
got => $out, |
76
|
|
|
|
|
|
|
exists => defined $out ? 1 : 0, |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
10
|
|
|
|
|
162
|
return @deltas; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub run { |
84
|
10
|
|
|
10
|
1
|
1653
|
my $self = shift; |
85
|
10
|
|
|
|
|
51
|
my %params = @_; |
86
|
10
|
|
|
|
|
30
|
my $got = $params{got}; |
87
|
|
|
|
|
|
|
|
88
|
10
|
|
|
|
|
61
|
my $delta = $self->SUPER::run(@_); |
89
|
10
|
100
|
|
|
|
191
|
return unless $delta; |
90
|
|
|
|
|
|
|
|
91
|
1
|
50
|
33
|
|
|
40
|
if ($got && blessed $got && $got->isa("Test::MasterData::Declare::Row")) { |
|
|
|
33
|
|
|
|
|
92
|
1
|
|
|
|
|
10
|
$delta->set_id(["HASH" => $got->source]); |
93
|
|
|
|
|
|
|
} |
94
|
1
|
|
|
|
|
27
|
return $delta; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |