ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/t/52_object.t
Revision: 1.1
Committed: Sun Oct 27 22:35:15 2013 UTC (10 years, 7 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-0_04, rel-0_05
Log Message:
*** empty log message ***

File Contents

# Content
1 BEGIN { $| = 1; print "1..20\n"; }
2
3 use CBOR::XS;
4
5 print "ok 1\n";
6
7 sub CBOR::XS::tocbor::TO_CBOR {
8 print @_ == 1 ? "" : "not ", "ok 3\n";
9 print CBOR::XS::tocbor:: eq ref $_[0] ? "" : "not ", "ok 4\n";
10 print $_[0]{k} == 1 ? "" : "not ", "ok 5\n";
11 7
12 }
13
14 $obj = bless { k => 1 }, CBOR::XS::tocbor::;
15
16 print "ok 2\n";
17
18 $enc = encode_cbor $obj;
19 print $enc eq "\x07" ? "" : "not ", "ok 6\n";
20
21 print "ok 7\n";
22
23 sub CBOR::XS::freeze::FREEZE {
24 print @_ == 2 ? "" : "not ", "ok 8\n";
25 print $_[1] eq "CBOR" ? "" : "not ", "ok 9\n";
26 print CBOR::XS::freeze:: eq ref $_[0] ? "" : "not ", "ok 10\n";
27 print $_[0]{k} == 1 ? "" : "not ", "ok 11\n";
28 (3, 1, 2)
29 }
30
31 sub CBOR::XS::freeze::THAW {
32 print @_ == 5 ? "" : "not ", "ok 13\n";
33 print CBOR::XS::freeze:: eq $_[0] ? "" : "not ", "ok 14\n";
34 print $_[1] eq "CBOR" ? "" : "not ", "ok 15\n";
35 print $_[2] == 3 ? "" : "not ", "ok 16\n";
36 print $_[3] == 1 ? "" : "not ", "ok 17\n";
37 print $_[4] == 2 ? "" : "not ", "ok 18\n";
38 777
39 }
40
41 $obj = bless { k => 1 }, CBOR::XS::freeze::;
42 $enc = encode_cbor $obj;
43 print $enc eq (pack "H*", "d90100845043424f523a3a58533a3a667265657a65030102") ? "" : "not ", "ok 12\n";
44
45 $dec = decode_cbor $enc;
46 print $dec eq 777 ? "" : "not ", "ok 19\n";
47
48 print "ok 20\n";
49