| Index: third_party/JSON/JSON-2.59/t/22_comment_at_eof.t
|
| diff --git a/third_party/JSON/JSON-2.59/t/22_comment_at_eof.t b/third_party/JSON/JSON-2.59/t/22_comment_at_eof.t
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a388a78d78c5a340cd978860d98d59625b805f33
|
| --- /dev/null
|
| +++ b/third_party/JSON/JSON-2.59/t/22_comment_at_eof.t
|
| @@ -0,0 +1,47 @@
|
| +# the oritinal test case was provided by IKEGAMI@cpan.org
|
| +
|
| +use strict;
|
| +
|
| +use Test::More tests => 13;
|
| +
|
| +BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
|
| +
|
| +use JSON;
|
| +
|
| +use Data::Dumper qw( Dumper );
|
| +
|
| +sub decoder {
|
| + my ($str) = @_;
|
| +
|
| + my $json = JSON->new->relaxed;
|
| +
|
| + $json->incr_parse($_[0]);
|
| +
|
| + my $rv;
|
| + if (!eval { $rv = $json->incr_parse(); 1 }) {
|
| + $rv = "died with $@";
|
| + }
|
| +
|
| + local $Data::Dumper::Useqq = 1;
|
| + local $Data::Dumper::Terse = 1;
|
| + local $Data::Dumper::Indent = 0;
|
| +
|
| + return Dumper($rv);
|
| +}
|
| +
|
| +
|
| +is( decoder( "[]" ), '[]', 'array baseline' );
|
| +is( decoder( " []" ), '[]', 'space ignored before array' );
|
| +is( decoder( "\n[]" ), '[]', 'newline ignored before array' );
|
| +is( decoder( "# foo\n[]" ), '[]', 'comment ignored before array' );
|
| +is( decoder( "# fo[o\n[]"), '[]', 'comment ignored before array' );
|
| +is( decoder( "# fo]o\n[]"), '[]', 'comment ignored before array' );
|
| +is( decoder( "[# fo]o\n]"), '[]', 'comment ignored inside array' );
|
| +
|
| +is( decoder( "" ), 'undef', 'eof baseline' );
|
| +is( decoder( " " ), 'undef', 'space ignored before eof' );
|
| +is( decoder( "\n" ), 'undef', 'newline ignored before eof' );
|
| +is( decoder( "#,foo\n" ), 'undef', 'comment ignored before eof' );
|
| +is( decoder( "# []o\n" ), 'undef', 'comment ignored before eof' );
|
| +
|
| +is( decoder( qq/#\n[#foo\n"#\\n"#\n]/), '["#\n"]', 'array and string in multiple lines' );
|
|
|