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
|
|
14617
|
use 5.006000; |
|
1
|
|
|
|
|
3
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
9
|
1
|
|
|
1
|
|
5
|
use Test::Builder::Module; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Test::Builder::Module); |
11
|
1
|
|
|
1
|
|
380
|
use JSON::Assert; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
my ($doc, $jpath, $count, $name) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# create the $json_assert object |
27
|
|
|
|
|
|
|
my $json_assert = JSON::Assert->new(); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# do the test and remember the result |
30
|
|
|
|
|
|
|
my $is_ok = $json_assert->is_jpath_count($doc, $jpath, $count); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $tb = $CLASS->builder(); |
33
|
|
|
|
|
|
|
return $tb->ok($is_ok, $name); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub does_jpath_value_match($$$;$) { |
37
|
|
|
|
|
|
|
my ($doc, $jpath, $match, $name) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $json_assert = JSON::Assert->new(); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# do the test and remember the result |
42
|
|
|
|
|
|
|
my $is_ok = $json_assert->does_jpath_value_match($doc, $jpath, $match); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $tb = $CLASS->builder(); |
45
|
|
|
|
|
|
|
return $tb->ok($is_ok, $name); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub do_jpath_values_match($$$;$) { |
49
|
|
|
|
|
|
|
my ($doc, $jpath, $match, $name) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $json_assert = JSON::Assert->new(); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# do the test and remember the result |
54
|
|
|
|
|
|
|
my $is_ok = $json_assert->do_jpath_values_match($doc, $jpath, $match); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $tb = $CLASS->builder(); |
57
|
|
|
|
|
|
|
return $tb->ok($is_ok, $name); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub does_jpath_contains($$$;$) { |
61
|
|
|
|
|
|
|
my ($doc, $jpath_str, $match, $name) = @_; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $json_assert = JSON::Assert->new(); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# do the test and remember the result |
66
|
|
|
|
|
|
|
my $is_ok = $json_assert->does_jpath_contains($doc, $jpath_str, $match); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $tb = $CLASS->builder(); |
69
|
|
|
|
|
|
|
return $tb->ok($is_ok, $name); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |