line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package JSON::Streaming::Writer::TestUtil; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# Just some utility bits for the test scripts to use. |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
47068
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
69
|
|
7
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
56
|
|
8
|
2
|
|
|
2
|
|
10
|
use base qw(Exporter); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
208
|
|
9
|
2
|
|
|
2
|
|
1100
|
use JSON::Streaming::Writer; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
64
|
|
10
|
2
|
|
|
2
|
|
14
|
use Symbol; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
860
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw(test_jsonw test_jsonw_croak); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub test_jsonw { |
15
|
34
|
|
|
34
|
0
|
1179
|
my ($test_name, $correct_output, $code) = @_; |
16
|
|
|
|
|
|
|
|
17
|
34
|
|
|
|
|
198
|
my $fh = JSON::Streaming::Writer::TestUtil::FakeHandle->new(); |
18
|
34
|
|
|
|
|
181
|
my $jsonw = JSON::Streaming::Writer->for_stream($fh); |
19
|
|
|
|
|
|
|
|
20
|
34
|
|
|
|
|
130
|
$code->($jsonw); |
21
|
|
|
|
|
|
|
|
22
|
21
|
|
|
|
|
57
|
my $actual_output = $fh->result; |
23
|
|
|
|
|
|
|
|
24
|
21
|
50
|
|
|
|
107
|
Test::More::is($correct_output, $actual_output, $test_name) if defined($correct_output); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub test_jsonw_croak { |
28
|
13
|
|
|
13
|
0
|
5021
|
my ($test_name, $code) = @_; |
29
|
|
|
|
|
|
|
|
30
|
13
|
|
|
|
|
22
|
eval { |
31
|
13
|
|
|
|
|
30
|
test_jsonw($test_name, undef, $code); |
32
|
|
|
|
|
|
|
}; |
33
|
13
|
50
|
|
|
|
42
|
if ($@) { |
34
|
13
|
|
|
|
|
34
|
Test::More::pass($test_name); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
0
|
|
|
|
|
0
|
Test::More::fail($test_name); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
package JSON::Streaming::Writer::TestUtil::FakeHandle; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
44
|
34
|
|
|
34
|
|
49
|
my ($class) = @_; |
45
|
|
|
|
|
|
|
|
46
|
34
|
|
|
|
|
89
|
my $sym = Symbol::gensym(); |
47
|
34
|
|
|
|
|
547
|
return tie(*$sym, __PACKAGE__); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub TIEHANDLE { |
51
|
34
|
|
|
34
|
|
56
|
my ($class) = @_; |
52
|
|
|
|
|
|
|
|
53
|
34
|
|
|
|
|
49
|
my $buf = ""; |
54
|
34
|
|
|
|
|
41
|
my $ret = \$buf; |
55
|
34
|
|
|
|
|
96
|
my $self = bless $ret, $class; |
56
|
34
|
|
|
|
|
166
|
return $ret; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub print { |
60
|
89
|
|
|
89
|
|
102
|
${(shift)} .= join('', @_); |
|
89
|
|
|
|
|
326
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub result { |
64
|
21
|
|
|
21
|
|
24
|
return ${$_[0]}; |
|
21
|
|
|
|
|
55
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|