ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/t/12_blessed.t
Revision: 1.1
Committed: Sun Jul 1 22:20:00 2007 UTC (17 years 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..6\n"; }
2    
3     use JSON::XS;
4    
5     our $test;
6     sub ok($;$) {
7     print $_[0] ? "" : "not ", "ok ", ++$test, "\n";
8     }
9    
10     my $o1 = bless { a => 3 }, "XX";
11     my $o2 = bless \(my $dummy = 1), "YY";
12    
13     sub XX::TO_JSON {
14     {__,""}
15     }
16    
17     my $js = JSON::XS->new;
18    
19     eval { $js->encode ($o1) }; ok ($@ =~ /allow_blessed/);
20     eval { $js->encode ($o2) }; ok ($@ =~ /allow_blessed/);
21     $js->allow_blessed;
22     ok ($js->encode ($o1) eq "null");
23     ok ($js->encode ($o2) eq "null");
24     $js->convert_blessed;
25     ok ($js->encode ($o1) eq '{"__":""}');
26     ok ($js->encode ($o2) eq "null");
27