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