ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/t/19_incr.t
(Generate patch)

Comparing JSON-XS/t/19_incr.t (file contents):
Revision 1.3 by root, Sat Apr 5 18:15:47 2008 UTC vs.
Revision 1.4 by root, Sun Jun 22 12:05:49 2008 UTC

1#! perl 1#! perl
2 2
3use strict; 3use strict;
4no warnings; 4no warnings;
5use Test::More; 5use Test::More;
6BEGIN { plan tests => 693 }; 6BEGIN { plan tests => 697 };
7 7
8use JSON::XS; 8use JSON::XS;
9 9
10sub splitter { 10sub splitter {
11 my ($coder, $text) = @_; 11 my ($coder, $text) = @_;
73 my $coder = JSON::XS->new->max_depth (3); 73 my $coder = JSON::XS->new->max_depth (3);
74 ok (!$coder->incr_parse ("[[["), "incdepth1"); 74 ok (!$coder->incr_parse ("[[["), "incdepth1");
75 eval { !$coder->incr_parse (" [] ") }; ok ($@ =~ /maximum nesting/, "incdepth2 $@"); 75 eval { !$coder->incr_parse (" [] ") }; ok ($@ =~ /maximum nesting/, "incdepth2 $@");
76} 76}
77 77
78# contributed by yuval kogman, reformatted to fit style
79{
80 my $coder = JSON::XS->new;
81
82 my $res = eval { $coder->incr_parse("]") };
83 my $e = $@; # test more clobbers $@, we need it twice
84
85 ok (!$res, "unbalanced bracket");
86 ok ($e, "got error");
87 like ($e, qr/malformed/, "malformed json string error");
88
89 $coder->incr_skip;
90
91 is_deeply (eval { $coder->incr_parse("[42]") }, [42], "valid data after incr_skip");
92}
78 93
94

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines