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

Comparing JSON-XS/t/12_blessed.t (file contents):
Revision 1.2 by root, Mon Jul 2 00:48:18 2007 UTC vs.
Revision 1.3 by root, Mon Jul 2 02:57:11 2007 UTC

1BEGIN { $| = 1; print "1..15\n"; } 1BEGIN { $| = 1; print "1..16\n"; }
2 2
3use JSON::XS; 3use JSON::XS;
4 4
5our $test; 5our $test;
6sub ok($;$) { 6sub ok($;$) {
24$js->convert_blessed; 24$js->convert_blessed;
25ok ($js->encode ($o1) eq '{"__":""}'); 25ok ($js->encode ($o1) eq '{"__":""}');
26ok ($js->encode ($o2) eq "null"); 26ok ($js->encode ($o2) eq "null");
27 27
28$js->filter_json_object (sub { 5 }); 28$js->filter_json_object (sub { 5 });
29$js->filter_json_single_key_object (a => sub { shift });
29$js->filter_json_single_key_object (sub { 6 }); 30$js->filter_json_single_key_object (b => sub { 7 });
30 31
31ok ("ARRAY" eq ref $js->decode ("[]")); 32ok ("ARRAY" eq ref $js->decode ("[]"));
32ok (5 eq join ":", @{ $js->decode ('[{}]') }); 33ok (5 eq join ":", @{ $js->decode ('[{}]') });
33ok (6 eq join ":", @{ $js->decode ('[{"a":4}]') }); 34ok (6 eq join ":", @{ $js->decode ('[{"a":6}]') });
34ok (5 eq join ":", @{ $js->decode ('[{"a":4,"b":7}]') }); 35ok (5 eq join ":", @{ $js->decode ('[{"a":4,"b":7}]') });
35 36
36$js->filter_json_object; 37$js->filter_json_object;
37ok (7 == $js->decode ('[{"a":4,"b":7}]')->[0]{b}); 38ok (7 == $js->decode ('[{"a":4,"b":7}]')->[0]{b});
38ok (6 eq join ":", @{ $js->decode ('[{"a":4}]') }); 39ok (3 eq join ":", @{ $js->decode ('[{"a":3}]') });
39 40
40$js->filter_json_object (sub { }); 41$js->filter_json_object (sub { });
41ok (7 == $js->decode ('[{"a":4,"b":7}]')->[0]{b}); 42ok (7 == $js->decode ('[{"a":4,"b":7}]')->[0]{b});
42ok (6 eq join ":", @{ $js->decode ('[{"a":4}]') }); 43ok (9 eq join ":", @{ $js->decode ('[{"a":9}]') });
43 44
44$js->filter_json_single_key_object (sub { }); 45$js->filter_json_single_key_object ("a");
45ok (4 == $js->decode ('[{"a":4}]')->[0]{a}); 46ok (4 == $js->decode ('[{"a":4}]')->[0]{a});
46 47
48$js->filter_json_single_key_object (a => sub { });
49ok (4 == $js->decode ('[{"a":4}]')->[0]{a});
50

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines