line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Shodo::JSONRPC; |
2
|
2
|
|
|
2
|
|
103836
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
133
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
62
|
|
4
|
2
|
|
|
2
|
|
421
|
use Shodo; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
71
|
|
5
|
2
|
|
|
2
|
|
1571
|
use parent qw/Exporter/; |
|
2
|
|
|
|
|
670
|
|
|
2
|
|
|
|
|
10
|
|
6
|
2
|
|
|
2
|
|
103
|
use JSON qw/from_json/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
22
|
|
7
|
2
|
|
|
2
|
|
261
|
use Try::Tiny; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
108
|
|
8
|
2
|
|
|
2
|
|
10
|
use Test::More; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
24
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT = qw/ |
11
|
|
|
|
|
|
|
shodo_document_root |
12
|
|
|
|
|
|
|
shodo_test |
13
|
|
|
|
|
|
|
shodo_params |
14
|
|
|
|
|
|
|
shodo_req_ok |
15
|
|
|
|
|
|
|
shodo_res_ok |
16
|
|
|
|
|
|
|
shodo_doc |
17
|
|
|
|
|
|
|
shodo_write |
18
|
|
|
|
|
|
|
/; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $shodo = Shodo->new(); |
21
|
|
|
|
|
|
|
my $suzuri; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub shodo_document_root { |
24
|
1
|
|
|
1
|
0
|
8
|
my $dir = shift; |
25
|
1
|
|
|
|
|
8
|
$shodo->document_root($dir); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub shodo_test { |
29
|
2
|
|
|
2
|
0
|
948
|
my ($description, $coderef) = @_; |
30
|
2
|
50
|
|
|
|
17
|
$suzuri = $shodo->new_suzuri($description) unless $suzuri; |
31
|
2
|
|
|
|
|
10
|
my $result = Test::More::subtest($description => $coderef); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub shodo_params { |
35
|
2
|
|
|
2
|
0
|
1266
|
my %args = @_; |
36
|
2
|
|
|
|
|
12
|
$suzuri->params(%args); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub shodo_req_ok { |
40
|
2
|
|
|
2
|
0
|
5736
|
my ($req, $note) = @_; |
41
|
2
|
|
|
|
|
12
|
$suzuri->request($req); |
42
|
|
|
|
|
|
|
my $data = try { |
43
|
2
|
|
|
2
|
|
81
|
from_json($req->content); |
44
|
|
|
|
|
|
|
}catch{ |
45
|
0
|
|
|
0
|
|
0
|
warn "$_\n"; |
46
|
2
|
|
|
|
|
21
|
}; |
47
|
2
|
50
|
|
|
|
91
|
return unless $data; |
48
|
2
|
100
|
|
|
|
13
|
return unless $suzuri->validate($data->{params}); |
49
|
1
|
|
|
|
|
7
|
Test::More::ok($req, $note); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub shodo_res_ok { |
53
|
1
|
|
|
1
|
0
|
634
|
my ($res, $code, $note) = @_; |
54
|
1
|
|
|
|
|
6
|
$suzuri->response($res); |
55
|
1
|
|
|
|
|
5
|
my $result = Test::More::is $res->code, 200, $note; |
56
|
1
|
|
|
|
|
292
|
$shodo->stock($suzuri->doc()); |
57
|
1
|
|
|
|
|
3
|
$suzuri = undef; |
58
|
1
|
|
|
|
|
52
|
return $result; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub shodo_doc { |
62
|
1
|
|
|
1
|
0
|
929
|
return $shodo->stock(); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub shodo_write { |
66
|
1
|
|
|
1
|
0
|
3
|
my $filename = shift; |
67
|
1
|
|
|
|
|
6
|
$shodo->write($filename); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |