ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/t/03_types.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..14\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     use PApp::Util;
12     ok (!defined JSON::XS->new->allow_nonref (1)->decode ('null'));
13     ok (JSON::XS->new->allow_nonref (1)->decode ('true') == 1);
14     ok (JSON::XS->new->allow_nonref (1)->decode ('false') == 0);
15    
16     ok (JSON::XS->new->allow_nonref (1)->decode ('5') == 5);
17     ok (JSON::XS->new->allow_nonref (1)->decode ('-5') == -5);
18     ok (JSON::XS->new->allow_nonref (1)->decode ('5e1') == 50);
19     ok (JSON::XS->new->allow_nonref (1)->decode ('-333e+0') == -333);
20     ok (JSON::XS->new->allow_nonref (1)->decode ('2.5') == 2.5);
21    
22     ok (JSON::XS->new->allow_nonref (1)->decode ('""') eq "");
23     ok ('[1,2,3,4]' eq to_json from_json ('[1,2, 3,4]'));
24     ok ('[{},[],[],{}]' eq to_json from_json ('[{},[], [ ] ,{ }]'));
25     ok ('[{"1":[5]}]' eq to_json [{1 => [5]}]);
26     ok ('{"1":2,"3":4}' eq JSON::XS->new->canonical (1)->encode (from_json '{ "1" : 2, "3" : 4 }'));
27     ok ('{"1":2,"3":1.2}' eq JSON::XS->new->canonical (1)->encode (from_json '{ "1" : 2, "3" : 1.2 }'));