line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Sah; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23740
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
40
|
|
6
|
|
|
|
|
|
|
#use Log::Any '$log'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
895
|
use Data::Sah qw(gen_validator); |
|
1
|
|
|
|
|
78750
|
|
|
1
|
|
|
|
|
82
|
|
9
|
1
|
|
|
1
|
|
8
|
use Test::Builder; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.01'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $Test = Test::Builder->new; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub import { |
16
|
1
|
|
|
1
|
|
9
|
my $self = shift; |
17
|
1
|
|
|
|
|
2
|
my $caller = caller; |
18
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
267
|
|
19
|
1
|
|
|
|
|
3
|
*{$caller.'::is_valid'} = \&is_valid; |
|
1
|
|
|
|
|
6
|
|
20
|
1
|
|
|
|
|
2
|
*{$caller.'::is_invalid'} = \&is_invalid; |
|
1
|
|
|
|
|
4
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
10
|
$Test->exported_to($caller); |
23
|
1
|
|
|
|
|
12
|
$Test->plan(@_); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub is_valid { |
27
|
1
|
|
|
1
|
1
|
10
|
my ($data, $schema, $msg) = @_; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
9
|
my $v = gen_validator($schema, {return_type=>'str'}); |
30
|
1
|
|
|
|
|
711041
|
my $res = $v->($data); |
31
|
1
|
|
|
|
|
30
|
my $ok = $Test->ok(!$res, $msg); |
32
|
1
|
50
|
|
|
|
408
|
$ok or $Test->diag($res); |
33
|
1
|
|
|
|
|
20
|
$ok; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub is_invalid { |
37
|
1
|
|
|
1
|
1
|
7
|
my ($data, $schema, $msg) = @_; |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
7
|
my $v = gen_validator($schema, {return_type=>'str'}); |
40
|
1
|
|
|
|
|
52704
|
$Test->ok($v->($data), $msg); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
# ABSTRACT: Test data against Sah schema |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |