ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/t/02_error.t
Revision: 1.2
Committed: Fri Mar 23 15:10:55 2007 UTC (17 years, 2 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-0_31, rel-0_3, rel-0_5, rel-0_7, rel-0_8
Changes since 1.1: +6 -6 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 BEGIN { $| = 1; print "1..19\n"; }
2    
3     use utf8;
4     use JSON::XS;
5    
6     our $test;
7     sub ok($) {
8     print $_[0] ? "" : "not ", "ok ", ++$test, "\n";
9     }
10    
11     eval { JSON::XS->new->allow_nonref (1)->decode ('"\u1234\udc00"') }; ok $@ =~ /missing high /;
12 root 1.2 eval { JSON::XS->new->allow_nonref->decode ('"\ud800"') }; ok $@ =~ /missing low /;
13 root 1.1 eval { JSON::XS->new->allow_nonref (1)->decode ('"\ud800\u1234"') }; ok $@ =~ /surrogate pair /;
14    
15     eval { JSON::XS->new->decode ('null') }; ok $@ =~ /allow_nonref/;
16     eval { JSON::XS->new->allow_nonref (1)->decode ('+0') }; ok $@ =~ /malformed/;
17 root 1.2 eval { JSON::XS->new->allow_nonref->decode ('.2') }; ok $@ =~ /malformed/;
18 root 1.1 eval { JSON::XS->new->allow_nonref (1)->decode ('bare') }; ok $@ =~ /malformed/;
19 root 1.2 eval { JSON::XS->new->allow_nonref->decode ('naughty') }; ok $@ =~ /null/;
20 root 1.1 eval { JSON::XS->new->allow_nonref (1)->decode ('01') }; ok $@ =~ /leading zero/;
21 root 1.2 eval { JSON::XS->new->allow_nonref->decode ('00') }; ok $@ =~ /leading zero/;
22 root 1.1 eval { JSON::XS->new->allow_nonref (1)->decode ('-0.') }; ok $@ =~ /decimal point/;
23 root 1.2 eval { JSON::XS->new->allow_nonref->decode ('-0e') }; ok $@ =~ /exp sign/;
24 root 1.1 eval { JSON::XS->new->allow_nonref (1)->decode ('-e+1') }; ok $@ =~ /initial minus/;
25 root 1.2 eval { JSON::XS->new->allow_nonref->decode ("\"\n\"") }; ok $@ =~ /invalid character/;
26 root 1.1 eval { JSON::XS->new->allow_nonref (1)->decode ("\"\x01\"") }; ok $@ =~ /invalid character/;
27     eval { JSON::XS->new->decode ('[5') }; ok $@ =~ /parsing array/;
28     eval { JSON::XS->new->decode ('{"5"') }; ok $@ =~ /':' expected/;
29     eval { JSON::XS->new->decode ('{"5":null') }; ok $@ =~ /parsing object/;
30     eval { JSON::XS->new->decode ('{"5":5 5') }; ok $@ =~ /parsing object/;