OLD | NEW |
| (Empty) |
1 use strict; | |
2 use Test::More; | |
3 | |
4 BEGIN { plan tests => 6 }; | |
5 | |
6 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; } | |
7 | |
8 BEGIN { | |
9 use lib qw(t); | |
10 use _unicode_handling; | |
11 } | |
12 | |
13 | |
14 use JSON; | |
15 | |
16 print JSON->backend, "\t", JSON->backend->VERSION, "\n"; | |
17 | |
18 my $data = ["\x{3042}\x{3044}\x{3046}\x{3048}\x{304a}", | |
19 "\x{304b}\x{304d}\x{304f}\x{3051}\x{3053}"]; | |
20 | |
21 my $j = new JSON; | |
22 my $js = $j->encode($data); | |
23 $j = undef; | |
24 | |
25 my @parts = (substr($js, 0, int(length($js) / 2)), | |
26 substr($js, int(length($js) / 2))); | |
27 $j = JSON->new; | |
28 my $object = $j->incr_parse($parts[0]); | |
29 | |
30 ok( !defined $object ); | |
31 | |
32 eval { | |
33 $j->incr_text; | |
34 }; | |
35 | |
36 like( $@, qr/incr_text can not be called when the incremental parser already sta
rted parsing/ ); | |
37 | |
38 $object = $j->incr_parse($parts[1]); | |
39 | |
40 ok( defined $object ); | |
41 | |
42 is( $object->[0], $data->[0] ); | |
43 is( $object->[1], $data->[1] ); | |
44 | |
45 eval { | |
46 $j->incr_text; | |
47 }; | |
48 | |
49 ok( !$@ ); | |
50 | |
OLD | NEW |