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