ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/t/52_object.t
Revision: 1.9
Committed: Sat Nov 30 18:13:53 2013 UTC (10 years, 6 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-1_11, rel-1_12, rel-1_71, rel-1_8, rel-1_1, rel-1_3, rel-1_5, rel-1_4, rel-1_7, rel-1_6, rel-1_25, rel-1_26, rel-1_41, rel-1_82, rel-1_83, rel-1_81, rel-1_86, rel-1_87, rel-1_84, rel-1_85, HEAD
Changes since 1.8: +2 -12 lines
Log Message:
*** empty log message ***

File Contents

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