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

Side by Side Diff: trunk/src/third_party/JSON/JSON-2.59/t/02_error.t

Issue 16539003: Revert 205057 "Add JSON.pm to third_party" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 # copied over from JSON::XS and modified to use JSON
2
3 use strict;
4 use Test::More;
5 BEGIN { plan tests => 31 };
6
7 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
8
9 BEGIN {
10 use lib qw(t);
11 use _unicode_handling;
12 }
13
14 use utf8;
15 use JSON;
16
17
18 eval { JSON->new->encode ([\-1]) }; ok $@ =~ /cannot encode reference/;
19 eval { JSON->new->encode ([\undef]) }; ok $@ =~ /cannot encode reference/;
20 eval { JSON->new->encode ([\2]) }; ok $@ =~ /cannot encode reference/;
21 eval { JSON->new->encode ([\{}]) }; ok $@ =~ /cannot encode reference/;
22 eval { JSON->new->encode ([\[]]) }; ok $@ =~ /cannot encode reference/;
23 eval { JSON->new->encode ([\\1]) }; ok $@ =~ /cannot encode reference/;
24 eval { JSON->new->allow_nonref (1)->decode ('"\u1234\udc00"') }; ok $@ =~ /missi ng high /;
25 eval { JSON->new->allow_nonref->decode ('"\ud800"') }; ok $@ =~ /missing low /;
26 eval { JSON->new->allow_nonref (1)->decode ('"\ud800\u1234"') }; ok $@ =~ /surro gate pair /;
27 eval { JSON->new->decode ('null') }; ok $@ =~ /allow_nonref/;
28 eval { JSON->new->allow_nonref (1)->decode ('+0') }; ok $@ =~ /malformed/;
29 eval { JSON->new->allow_nonref->decode ('.2') }; ok $@ =~ /malformed/;
30 eval { JSON->new->allow_nonref (1)->decode ('bare') }; ok $@ =~ /malformed/;
31 eval { JSON->new->allow_nonref->decode ('naughty') }; ok $@ =~ /null/;
32 eval { JSON->new->allow_nonref (1)->decode ('01') }; ok $@ =~ /leading zero/;
33 eval { JSON->new->allow_nonref->decode ('00') }; ok $@ =~ /leading zero/;
34 eval { JSON->new->allow_nonref (1)->decode ('-0.') }; ok $@ =~ /decimal point/;
35 eval { JSON->new->allow_nonref->decode ('-0e') }; ok $@ =~ /exp sign/;
36 eval { JSON->new->allow_nonref (1)->decode ('-e+1') }; ok $@ =~ /initial minus/;
37 eval { JSON->new->allow_nonref->decode ("\"\n\"") }; ok $@ =~ /invalid character /;
38 eval { JSON->new->allow_nonref (1)->decode ("\"\x01\"") }; ok $@ =~ /invalid cha racter/;
39 eval { JSON->new->decode ('[5') }; ok $@ =~ /parsing array/;
40 eval { JSON->new->decode ('{"5"') }; ok $@ =~ /':' expected/;
41 eval { JSON->new->decode ('{"5":null') }; ok $@ =~ /parsing object/;
42
43 eval { JSON->new->decode (undef) }; ok $@ =~ /malformed/;
44 eval { JSON->new->decode (\5) }; ok !!$@; # Can't coerce readonly
45 eval { JSON->new->decode ([]) }; ok $@ =~ /malformed/;
46 eval { JSON->new->decode (\*STDERR) }; ok $@ =~ /malformed/;
47 eval { JSON->new->decode (*STDERR) }; ok !!$@; # cannot coerce GLOB
48
49 eval { decode_json ("\"\xa0") }; ok $@ =~ /malformed.*character/;
50 eval { decode_json ("\"\xa0\"") }; ok $@ =~ /malformed.*character/;
51
OLDNEW
« no previous file with comments | « trunk/src/third_party/JSON/JSON-2.59/t/01_utf8.t ('k') | trunk/src/third_party/JSON/JSON-2.59/t/03_types.t » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698