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.1 by root, Sun Jul 1 22:20:00 2007 UTC vs.
Revision 1.3 by root, Mon Jul 2 02:57:11 2007 UTC

1BEGIN { $| = 1; print "1..6\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($;$) {
23ok ($js->encode ($o2) eq "null"); 23ok ($js->encode ($o2) eq "null");
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 });
29$js->filter_json_single_key_object (a => sub { shift });
30$js->filter_json_single_key_object (b => sub { 7 });
31
32ok ("ARRAY" eq ref $js->decode ("[]"));
33ok (5 eq join ":", @{ $js->decode ('[{}]') });
34ok (6 eq join ":", @{ $js->decode ('[{"a":6}]') });
35ok (5 eq join ":", @{ $js->decode ('[{"a":4,"b":7}]') });
36
37$js->filter_json_object;
38ok (7 == $js->decode ('[{"a":4,"b":7}]')->[0]{b});
39ok (3 eq join ":", @{ $js->decode ('[{"a":3}]') });
40
41$js->filter_json_object (sub { });
42ok (7 == $js->decode ('[{"a":4,"b":7}]')->[0]{b});
43ok (9 eq join ":", @{ $js->decode ('[{"a":9}]') });
44
45$js->filter_json_single_key_object ("a");
46ok (4 == $js->decode ('[{"a":4}]')->[0]{a});
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