line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## ---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
# Copyright (C) 2014-2016 NZRS Ltd. |
3
|
|
|
|
|
|
|
## ---------------------------------------------------------------------------- |
4
|
|
|
|
|
|
|
package Test::JSON::Assert; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
44980
|
use 5.006000; |
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
9
|
1
|
|
|
1
|
|
6
|
use Test::Builder::Module; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Test::Builder::Module); |
11
|
1
|
|
|
1
|
|
411
|
use JSON::Assert; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
431
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw( |
14
|
|
|
|
|
|
|
is_jpath_count |
15
|
|
|
|
|
|
|
does_jpath_value_match |
16
|
|
|
|
|
|
|
do_jpath_values_match |
17
|
|
|
|
|
|
|
does_jpath_contains |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $CLASS = __PACKAGE__; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub is_jpath_count($$$;$) { |
24
|
0
|
|
|
0
|
1
|
|
my ($doc, $jpath, $count, $name) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# create the $json_assert object |
27
|
0
|
|
|
|
|
|
my $json_assert = JSON::Assert->new(); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# do the test and remember the result |
30
|
0
|
|
|
|
|
|
my $is_ok = $json_assert->is_jpath_count($doc, $jpath, $count); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $tb = $CLASS->builder(); |
33
|
0
|
|
|
|
|
|
return $tb->ok($is_ok, $name); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub does_jpath_value_match($$$;$) { |
37
|
0
|
|
|
0
|
1
|
|
my ($doc, $jpath, $match, $name) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $json_assert = JSON::Assert->new(); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# do the test and remember the result |
42
|
0
|
|
|
|
|
|
my $is_ok = $json_assert->does_jpath_value_match($doc, $jpath, $match); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $tb = $CLASS->builder(); |
45
|
0
|
|
|
|
|
|
return $tb->ok($is_ok, $name); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub do_jpath_values_match($$$;$) { |
49
|
0
|
|
|
0
|
1
|
|
my ($doc, $jpath, $match, $name) = @_; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $json_assert = JSON::Assert->new(); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# do the test and remember the result |
54
|
0
|
|
|
|
|
|
my $is_ok = $json_assert->do_jpath_values_match($doc, $jpath, $match); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $tb = $CLASS->builder(); |
57
|
0
|
|
|
|
|
|
return $tb->ok($is_ok, $name); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub does_jpath_contains($$$;$) { |
61
|
0
|
|
|
0
|
1
|
|
my ($doc, $jpath_str, $match, $name) = @_; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $json_assert = JSON::Assert->new(); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# do the test and remember the result |
66
|
0
|
|
|
|
|
|
my $is_ok = $json_assert->does_jpath_contains($doc, $jpath_str, $match); |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $tb = $CLASS->builder(); |
69
|
0
|
|
|
|
|
|
return $tb->ok($is_ok, $name); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |