ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/t/17_relaxed.t
Revision: 1.2
Committed: Mon Aug 27 02:03:23 2007 UTC (16 years, 10 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-1_51, rel-1_53, rel-2_0, rel-1_5
Changes since 1.1: +2 -1 lines
Log Message:
#-comments

File Contents

# User Rev Content
1 root 1.2 BEGIN { $| = 1; print "1..8\n"; }
2 root 1.1
3     use utf8;
4     use JSON::XS;
5    
6     our $test;
7     sub ok($) {
8     print $_[0] ? "" : "not ", "ok ", ++$test, "\n";
9     }
10    
11     my $json = JSON::XS->new->relaxed;
12    
13     ok ('[1,2,3]' eq to_json $json->decode (' [1,2, 3]'));
14     ok ('[1,2,4]' eq to_json $json->decode ('[1,2, 4 , ]'));
15     ok (!eval { $json->decode ('[1,2, 3,4,,]') });
16     ok (!eval { $json->decode ('[,1]') });
17    
18     ok ('{"1":2}' eq to_json $json->decode (' {"1":2}'));
19     ok ('{"1":2}' eq to_json $json->decode ('{"1":2,}'));
20     ok (!eval { $json->decode ('{,}') });
21    
22 root 1.2 ok ('[1,2]' eq to_json $json->decode ("[1#,2\n ,2,# ] \n\t]"));