1 | BEGIN { $| = 1; print "1..20\n"; } |
1 | BEGIN { $| = 1; print "1..22\n"; } |
2 | BEGIN { $^W = 0 } # hate |
2 | BEGIN { $^W = 0 } # hate |
3 | |
3 | |
4 | use CBOR::XS; |
4 | use CBOR::XS; |
5 | |
5 | |
6 | print "ok 1\n"; |
6 | print "ok 1\n"; |
… | |
… | |
44 | print $enc eq (pack "H*", "d81a845043424f523a3a58533a3a667265657a65030102") ? "" : "not ", "ok 12 ", (unpack "H*", $enc), "\n"; |
44 | print $enc eq (pack "H*", "d81a845043424f523a3a58533a3a667265657a65030102") ? "" : "not ", "ok 12 ", (unpack "H*", $enc), "\n"; |
45 | |
45 | |
46 | $dec = decode_cbor $enc; |
46 | $dec = decode_cbor $enc; |
47 | print $dec eq 777 ? "" : "not ", "ok 19\n"; |
47 | print $dec eq 777 ? "" : "not ", "ok 19\n"; |
48 | |
48 | |
49 | print "ok 20\n"; |
49 | sub CBOR::XS::freeze2::FREEZE { |
|
|
50 | 77 |
|
|
51 | } |
50 | |
52 | |
|
|
53 | $enc = CBOR::XS::encode_cbor_sharing [(bless [], CBOR::XS::freeze2::) x 3]; |
|
|
54 | print $enc eq (pack "H*", "83d81cd81a825143424f523a3a58533a3a667265657a6532184dd81d00d81d00") ? "" : "not ", "ok 20 ", (unpack "H*", $enc), "\n"; |
|
|
55 | |
|
|
56 | $enc = CBOR::XS->new->allow_sharing->encode ([(bless [], CBOR::XS::freeze2::) x 3]); |
|
|
57 | print $enc eq (pack "H*", "83d81cd81a825143424f523a3a58533a3a667265657a6532184dd81d00d81d00") ? "" : "not ", "ok 21 ", (unpack "H*", $enc), "\n"; |
|
|
58 | |
|
|
59 | print "ok 22\n"; |
|
|
60 | |