line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::JSYNC; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
145424
|
use 5.006; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
124
|
|
4
|
3
|
|
|
3
|
|
66
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
116
|
|
5
|
3
|
|
|
3
|
|
2553
|
use parent 'Test::Builder::Module'; |
|
3
|
|
|
|
|
1306
|
|
|
3
|
|
|
|
|
26
|
|
6
|
3
|
|
|
3
|
|
3117
|
use English qw( -no_match_vars ); |
|
3
|
|
|
|
|
16700
|
|
|
3
|
|
|
|
|
20
|
|
7
|
3
|
|
|
3
|
|
1401
|
use Carp; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
224
|
|
8
|
3
|
|
|
3
|
|
2440
|
use JSYNC; |
|
3
|
|
|
|
|
124269
|
|
|
3
|
|
|
|
|
256
|
|
9
|
3
|
|
|
3
|
|
14367
|
use Test::Differences; |
|
3
|
|
|
|
|
103228
|
|
|
3
|
|
|
|
|
1945
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
12
|
|
|
|
|
|
|
our @EXPORT = qw( jsync_ok jsync_is ); |
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw( is_valid_jsync is_jsync ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
*is_valid_jsync = \&jsync_ok; |
16
|
|
|
|
|
|
|
*is_jsync = \&jsync_is; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub jsync_ok ($;$) { |
19
|
4
|
|
|
4
|
1
|
127578
|
my ($input, $test_name) = @_; |
20
|
4
|
|
|
|
|
35
|
my $test = __PACKAGE__->builder; |
21
|
|
|
|
|
|
|
|
22
|
4
|
50
|
|
|
|
42
|
croak 'usage: jsync_ok(input, test_name)' |
23
|
|
|
|
|
|
|
if !defined $input; |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
7
|
eval { JSYNC::load($input) }; |
|
4
|
|
|
|
|
21
|
|
26
|
|
|
|
|
|
|
|
27
|
4
|
100
|
|
|
|
658
|
if (my $error = $EVAL_ERROR) { |
28
|
2
|
|
|
|
|
19
|
$test->ok(0, $test_name); |
29
|
2
|
|
|
|
|
256
|
$test->diag("Input was not valid JSYNC: $error"); |
30
|
2
|
|
|
|
|
106
|
return; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
22
|
$test->ok(1, $test_name); |
34
|
2
|
|
|
|
|
217
|
return 1; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub jsync_is ($$;$) { |
38
|
8
|
|
|
8
|
1
|
73690
|
my ($input, $expected, $test_name) = @_; |
39
|
8
|
|
|
|
|
66
|
my $test = __PACKAGE__->builder; |
40
|
8
|
|
|
|
|
65
|
my %result_for; |
41
|
|
|
|
|
|
|
|
42
|
8
|
50
|
33
|
|
|
67
|
croak 'usage: jsync_is(input, expected, test_name)' |
43
|
|
|
|
|
|
|
if !defined $input || !defined $expected; |
44
|
|
|
|
|
|
|
|
45
|
8
|
|
|
|
|
59
|
for my $item ( |
46
|
|
|
|
|
|
|
{ key => 'input', value => $input }, |
47
|
|
|
|
|
|
|
{ key => 'expected', value => $expected }, |
48
|
|
|
|
|
|
|
) { |
49
|
16
|
|
|
|
|
29
|
$result_for{ $item->{key} } = eval { JSYNC::load( $item->{value} ) }; |
|
16
|
|
|
|
|
67
|
|
50
|
|
|
|
|
|
|
|
51
|
16
|
100
|
|
|
|
4289
|
if (my $error = $EVAL_ERROR) { |
52
|
2
|
|
|
|
|
22
|
$test->ok(0, $test_name); |
53
|
2
|
|
|
|
|
300
|
$test->diag(ucfirst "$item->{key} was not valid JSYNC: $error"); |
54
|
2
|
|
|
|
|
76
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
6
|
|
|
|
|
22
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
59
|
|
|
|
|
|
|
|
60
|
6
|
|
|
|
|
41
|
return eq_or_diff($result_for{input}, $result_for{expected}, $test_name); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |