Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/JSON/JSON-2.59/t/22_comment_at_eof.t

Issue 15736030: Add JSON.pm to third_party (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix permissions and shebangs Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # the oritinal test case was provided by IKEGAMI@cpan.org
2
3 use strict;
4
5 use Test::More tests => 13;
6
7 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
8
9 use JSON;
10
11 use Data::Dumper qw( Dumper );
12
13 sub decoder {
14 my ($str) = @_;
15
16 my $json = JSON->new->relaxed;
17
18 $json->incr_parse($_[0]);
19
20 my $rv;
21 if (!eval { $rv = $json->incr_parse(); 1 }) {
22 $rv = "died with $@";
23 }
24
25 local $Data::Dumper::Useqq = 1;
26 local $Data::Dumper::Terse = 1;
27 local $Data::Dumper::Indent = 0;
28
29 return Dumper($rv);
30 }
31
32
33 is( decoder( "[]" ), '[]', 'array baseline' );
34 is( decoder( " []" ), '[]', 'space ignored before array' );
35 is( decoder( "\n[]" ), '[]', 'newline ignored before array' );
36 is( decoder( "# foo\n[]" ), '[]', 'comment ignored before array' );
37 is( decoder( "# fo[o\n[]"), '[]', 'comment ignored before array' );
38 is( decoder( "# fo]o\n[]"), '[]', 'comment ignored before array' );
39 is( decoder( "[# fo]o\n]"), '[]', 'comment ignored inside array' );
40
41 is( decoder( "" ), 'undef', 'eof baseline' );
42 is( decoder( " " ), 'undef', 'space ignored before eof' );
43 is( decoder( "\n" ), 'undef', 'newline ignored before eof' );
44 is( decoder( "#,foo\n" ), 'undef', 'comment ignored before eof' );
45 is( decoder( "# []o\n" ), 'undef', 'comment ignored before eof' );
46
47 is( decoder( qq/#\n[#foo\n"#\\n"#\n]/), '["#\n"]', 'array and string in multiple lines' );
OLDNEW
« no previous file with comments | « third_party/JSON/JSON-2.59/t/21_evans_bugrep.t ('k') | third_party/JSON/JSON-2.59/t/99_binary.t » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698