ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/t/02_error.t
(Generate patch)

Comparing JSON-XS/t/02_error.t (file contents):
Revision 1.3 by root, Thu Mar 29 02:45:49 2007 UTC vs.
Revision 1.7 by root, Thu Nov 20 03:59:53 2008 UTC

1BEGIN { $| = 1; print "1..25\n"; } 1BEGIN { $| = 1; print "1..31\n"; }
2 2
3use utf8; 3use utf8;
4use JSON::XS; 4use JSON::XS;
5no warnings;
5 6
6our $test; 7our $test;
7sub ok($) { 8sub ok($) {
8 print $_[0] ? "" : "not ", "ok ", ++$test, "\n"; 9 print $_[0] ? "" : "not ", "ok ", ++$test, "\n";
9} 10}
32eval { JSON::XS->new->allow_nonref->decode ("\"\n\"") }; ok $@ =~ /invalid character/; 33eval { JSON::XS->new->allow_nonref->decode ("\"\n\"") }; ok $@ =~ /invalid character/;
33eval { JSON::XS->new->allow_nonref (1)->decode ("\"\x01\"") }; ok $@ =~ /invalid character/; 34eval { JSON::XS->new->allow_nonref (1)->decode ("\"\x01\"") }; ok $@ =~ /invalid character/;
34eval { JSON::XS->new->decode ('[5') }; ok $@ =~ /parsing array/; 35eval { JSON::XS->new->decode ('[5') }; ok $@ =~ /parsing array/;
35eval { JSON::XS->new->decode ('{"5"') }; ok $@ =~ /':' expected/; 36eval { JSON::XS->new->decode ('{"5"') }; ok $@ =~ /':' expected/;
36eval { JSON::XS->new->decode ('{"5":null') }; ok $@ =~ /parsing object/; 37eval { JSON::XS->new->decode ('{"5":null') }; ok $@ =~ /parsing object/;
38
39eval { JSON::XS->new->decode (undef) }; ok $@ =~ /malformed/;
40eval { JSON::XS->new->decode (\5) }; ok !!$@; # Can't coerce readonly
37eval { JSON::XS->new->decode ('{"5":5 5') }; ok $@ =~ /parsing object/; 41eval { JSON::XS->new->decode ([]) }; ok $@ =~ /malformed/;
42eval { JSON::XS->new->decode (\*STDERR) }; ok $@ =~ /malformed/;
43eval { JSON::XS->new->decode (*STDERR) }; ok !!$@; # cannot coerce GLOB
44
45eval { decode_json ("\"\xa0") }; ok $@ =~ /malformed.*character/;
46eval { decode_json ("\"\xa0\"") }; ok $@ =~ /malformed.*character/;
47

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines