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