--- CBOR-XS/t/53_bignum.t 2013/11/22 15:44:13 1.3 +++ CBOR-XS/t/53_bignum.t 2016/04/25 21:30:23 1.4 @@ -1,8 +1,10 @@ -BEGIN { $| = 1; print "1..100\n"; } +BEGIN { $| = 1; print "1..102\n"; } BEGIN { $^W = 0 } # hate use CBOR::XS; +use Math::BigInt only => "Calc"; # needed for representation stability + print "ok 1\n"; my $t = decode_cbor pack "H*", "82c48221196ab3c5822003"; @@ -14,7 +16,7 @@ print $t eq (pack "H*", "82c48221196ab3c482200f") ? "" : "not ", "ok 4 # ", (unpack "H*", $t), "\n"; -# Math::BigFloat is loaded by now... +# Math::BigFloat must be loaded by now... for (5..99) { my $n = Math::BigFloat->new ((int rand 1e9) . "." . (int rand 1e9) . "e" . ((int rand 1e8) - 0.5e8)); @@ -26,5 +28,12 @@ print $n != $m ? "not " : "ok $_ # $n eq $m\n"; } -print "ok 100\n"; +$t = encode_cbor CBOR::XS::tag 264, [Math::BigInt->new ("99999999999999999998"), Math::BigInt->new ("799999999999999999998")]; +$t = decode_cbor $t; +print "799999999999999999998e+99999999999999999998" eq $t->bsstr ? "" : "not ", "ok 100\n"; + +$t = encode_cbor $t; +print "d9010882c249056bc75e2d63100000c2492b5e3af16b187ffffe" eq (unpack "H*", $t) ? "" : "not ", "ok 101\n"; + +print "ok 102\n";