Cpanel-JSON-XS

 view release on metacpan or  search on metacpan

t/19_incr.t  view on Meta::CPAN


   # feed partial input: the } is inside the single-quoted value, must not trigger done
   ok (!defined $coder->incr_parse("{'a':'}'"), "sqstr-incr: } inside single-quote does not close object");

   # complete the object
   my $r = $coder->incr_parse("}");
   ok (defined $r, "sqstr-incr: object completes after closing brace");
   is_deeply ($r, {a => "}"}, "sqstr-incr: decoded value correct");
}

# allow_singlequote: chunked streaming with structural chars inside single-quoted string
{
   my $coder = Cpanel::JSON::XS->new->allow_singlequote(1);

   # feed one byte at a time to exercise every state transition
   my $json = "{'x':'}[{'}";
   my $r;
   for my $ch (split //, $json) {
      $r = $coder->incr_parse($ch);
   }
   ok (defined $r, "sqstr-incr chunked: defined result");



( run in 0.495 second using v1.01-cache-2.11-cpan-140bd7fdf52 )