--- CBOR-XS/t/52_object.t 2013/10/28 22:50:50 1.2 +++ CBOR-XS/t/52_object.t 2013/11/30 17:37:45 1.8 @@ -1,6 +1,6 @@ -BEGIN { $| = 1; print "1..20\n"; } +BEGIN { $| = 1; print "1..22\n"; } +BEGIN { $^W = 0 } # hate -while(){ use CBOR::XS; print "ok 1\n"; @@ -41,11 +41,20 @@ $obj = bless { k => 1 }, CBOR::XS::freeze::; $enc = encode_cbor $obj; -print $enc eq (pack "H*", "d90100845043424f523a3a58533a3a667265657a65030102") ? "" : "not ", "ok 12\n"; +print $enc eq (pack "H*", "d81a845043424f523a3a58533a3a667265657a65030102") ? "" : "not ", "ok 12 ", (unpack "H*", $enc), "\n"; $dec = decode_cbor $enc; print $dec eq 777 ? "" : "not ", "ok 19\n"; -print "ok 20\n"; +sub CBOR::XS::freeze2::FREEZE { + 77 } +$enc = CBOR::XS::encode_cbor_sharing [(bless [], CBOR::XS::freeze2::) x 3]; +print $enc eq (pack "H*", "83d81cd81a825143424f523a3a58533a3a667265657a6532184dd81d00d81d00") ? "" : "not ", "ok 20 ", (unpack "H*", $enc), "\n"; + +$enc = CBOR::XS->new->allow_sharing->encode ([(bless [], CBOR::XS::freeze2::) x 3]); +print $enc eq (pack "H*", "83d81cd81a825143424f523a3a58533a3a667265657a6532184dd81d00d81d00") ? "" : "not ", "ok 21 ", (unpack "H*", $enc), "\n"; + +print "ok 22\n"; +