ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/t/02_error.t
Revision: 1.1
Committed: Thu Mar 22 23:24:18 2007 UTC (17 years, 3 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-0_2
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     eval { JSON::XS->new->allow_nonref (1)->decode ('"\ud800"') }; ok $@ =~ /missing low /;
13     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     eval { JSON::XS->new->allow_nonref (1)->decode ('.2') }; ok $@ =~ /malformed/;
18     eval { JSON::XS->new->allow_nonref (1)->decode ('bare') }; ok $@ =~ /malformed/;
19     eval { JSON::XS->new->allow_nonref (1)->decode ('naughty') }; ok $@ =~ /null/;
20     eval { JSON::XS->new->allow_nonref (1)->decode ('01') }; ok $@ =~ /leading zero/;
21     eval { JSON::XS->new->allow_nonref (1)->decode ('00') }; ok $@ =~ /leading zero/;
22     eval { JSON::XS->new->allow_nonref (1)->decode ('-0.') }; ok $@ =~ /decimal point/;
23     eval { JSON::XS->new->allow_nonref (1)->decode ('-0e') }; ok $@ =~ /exp sign/;
24     eval { JSON::XS->new->allow_nonref (1)->decode ('-e+1') }; ok $@ =~ /initial minus/;
25     eval { JSON::XS->new->allow_nonref (1)->decode ("\"\n\"") }; ok $@ =~ /invalid character/;
26     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/;