line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::JSV::Suite; |
2
|
|
|
|
|
|
|
|
3
|
40
|
|
|
40
|
|
888318
|
use strict; |
|
40
|
|
|
|
|
93
|
|
|
40
|
|
|
|
|
1070
|
|
4
|
40
|
|
|
40
|
|
192
|
use warnings; |
|
40
|
|
|
|
|
1304
|
|
|
40
|
|
|
|
|
1134
|
|
5
|
|
|
|
|
|
|
|
6
|
40
|
|
|
40
|
|
196
|
use Carp; |
|
40
|
|
|
|
|
70
|
|
|
40
|
|
|
|
|
3246
|
|
7
|
40
|
|
|
40
|
|
210
|
use File::Basename; |
|
40
|
|
|
|
|
91
|
|
|
40
|
|
|
|
|
3228
|
|
8
|
40
|
|
|
40
|
|
193
|
use File::Spec; |
|
40
|
|
|
|
|
68
|
|
|
40
|
|
|
|
|
870
|
|
9
|
40
|
|
|
40
|
|
35746
|
use FindBin; |
|
40
|
|
|
|
|
65265
|
|
|
40
|
|
|
|
|
1703
|
|
10
|
40
|
|
|
40
|
|
39161
|
use JSON; |
|
40
|
|
|
|
|
682256
|
|
|
40
|
|
|
|
|
187
|
|
11
|
40
|
|
|
40
|
|
6837
|
use Test::More; |
|
40
|
|
|
|
|
69
|
|
|
40
|
|
|
|
|
360
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub run { |
14
|
75
|
|
|
75
|
0
|
88102
|
my ($class, %opts) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
%opts = ( |
17
|
|
|
|
|
|
|
base_dir => $opts{base_dir}, |
18
|
|
|
|
|
|
|
version => "", |
19
|
|
|
|
|
|
|
suite => "type", |
20
|
|
|
|
|
|
|
cb => sub { |
21
|
0
|
|
|
0
|
|
0
|
my ($schema, $instance, $expect) = @_; |
22
|
0
|
|
|
|
|
0
|
return 1; |
23
|
|
|
|
|
|
|
}, |
24
|
75
|
|
|
|
|
1351
|
skip_test_cases => {}, |
25
|
|
|
|
|
|
|
verbose => 0, |
26
|
|
|
|
|
|
|
%opts |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
75
|
|
|
|
|
502
|
my $self = bless \%opts => $class; |
30
|
75
|
|
|
|
|
369
|
my $test_suite = $self->load_test_suite; |
31
|
|
|
|
|
|
|
|
32
|
75
|
|
|
|
|
515
|
for my $test_cases (@$test_suite) { |
33
|
197
|
|
|
|
|
127760
|
$self->run_test_cases($test_cases, $opts{skip_test_cases}); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
75
|
|
|
|
|
86935
|
done_testing; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub run_test_cases { |
40
|
197
|
|
|
197
|
0
|
478
|
my ($self, $test_cases, $skip_test_cases) = @_; |
41
|
|
|
|
|
|
|
|
42
|
197
|
|
|
|
|
775
|
my ($desc, $schema, $tests) = @$test_cases{qw/description schema tests/}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
subtest $desc => sub { |
45
|
|
|
|
|
|
|
SKIP: { |
46
|
197
|
|
|
197
|
|
133659
|
for my $test_case (@$tests) { |
|
197
|
|
|
|
|
583
|
|
47
|
682
|
50
|
66
|
|
|
206910
|
if (defined $test_case->{description} && exists $skip_test_cases->{$test_case->{description}}) { |
48
|
0
|
|
|
|
|
0
|
skip $test_case->{description} => 1; |
49
|
|
|
|
|
|
|
} |
50
|
682
|
|
|
|
|
2318
|
$self->run_test_case($schema, $test_case); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
197
|
|
|
|
|
1850
|
}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub run_test_case { |
57
|
682
|
|
|
682
|
0
|
1199
|
my ($self, $schema, $test_case) = @_; |
58
|
682
|
|
|
|
|
1753
|
my ($desc, $data, $expect) = @$test_case{qw/description data valid/}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
is( |
61
|
682
|
100
|
|
|
|
2414
|
$self->{cb}->($schema, $data, $expect), |
62
|
|
|
|
|
|
|
$expect ? 1 : 0, |
63
|
|
|
|
|
|
|
$desc, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub load_test_suite { |
68
|
75
|
|
|
75
|
0
|
169
|
my $self = shift; |
69
|
|
|
|
|
|
|
my $test_suite_file = File::Spec->catfile( |
70
|
|
|
|
|
|
|
$self->{version} ? ( $self->{base_dir}, $self->{version} ) : ( $self->{base_dir} ), |
71
|
75
|
100
|
|
|
|
1558
|
$self->{suite} . ".json" |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
75
|
|
|
|
|
492
|
note $test_suite_file; |
75
|
|
|
|
|
|
|
|
76
|
75
|
50
|
|
|
|
13404
|
unless (-f $test_suite_file) { |
77
|
0
|
|
|
|
|
0
|
croak sprintf("Not exists test suite (base_dir: %s, version: %s, suite: %s)", @$self{qw/base_dir version suite/}); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
75
|
50
|
|
|
|
3487
|
open(my $fh, "<", $test_suite_file) or croak $!; |
81
|
75
|
|
|
|
|
177
|
my $test_suite = decode_json(do { local $/; <$fh> }); |
|
75
|
|
|
|
|
332
|
|
|
75
|
|
|
|
|
27150063
|
|
82
|
75
|
|
|
|
|
1839
|
close $fh; |
83
|
75
|
|
|
|
|
721
|
return $test_suite; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |