| 1 |
root |
1.1 |
BEGIN { $| = 1; print "1..20\n"; } |
| 2 |
root |
1.4 |
BEGIN { $^W = 0 } # hate |
| 3 |
root |
1.1 |
|
| 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*", "d90100845043424f523a3a58533a3a667265657a65030102") ? "" : "not ", "ok 12\n"; |
| 45 |
|
|
|
| 46 |
|
|
$dec = decode_cbor $enc; |
| 47 |
|
|
print $dec eq 777 ? "" : "not ", "ok 19\n"; |
| 48 |
|
|
|
| 49 |
|
|
print "ok 20\n"; |
| 50 |
|
|
|