ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/t/17_relaxed.t
Revision: 1.1
Committed: Mon Aug 27 01:49:01 2007 UTC (16 years, 10 months ago) by root
Content type: application/x-troff
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 BEGIN { $| = 1; print "1..7\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     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