--- JSON-XS/t/19_incr.t 2008/04/05 18:15:47 1.3 +++ JSON-XS/t/19_incr.t 2008/06/22 12:05:49 1.4 @@ -3,7 +3,7 @@ use strict; no warnings; use Test::More; -BEGIN { plan tests => 693 }; +BEGIN { plan tests => 697 }; use JSON::XS; @@ -75,4 +75,20 @@ eval { !$coder->incr_parse (" [] ") }; ok ($@ =~ /maximum nesting/, "incdepth2 $@"); } +# contributed by yuval kogman, reformatted to fit style +{ + my $coder = JSON::XS->new; + + my $res = eval { $coder->incr_parse("]") }; + my $e = $@; # test more clobbers $@, we need it twice + + ok (!$res, "unbalanced bracket"); + ok ($e, "got error"); + like ($e, qr/malformed/, "malformed json string error"); + + $coder->incr_skip; + + is_deeply (eval { $coder->incr_parse("[42]") }, [42], "valid data after incr_skip"); +} +