Skip to content

Instantly share code, notes, and snippets.

@FROGGS

FROGGS/bigint.t Secret

Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FROGGS/64c224637a10fff02e33 to your computer and use it in GitHub Desktop.
Save FROGGS/64c224637a10fff02e33 to your computer and use it in GitHub Desktop.
#! nqp
use nqpmo;
plan(275);
sub add_to_sc($sc, $idx, $obj) {
nqp::scsetobj($sc, $idx, $obj);
nqp::setobjsc($obj, $sc);
}
my $k := 0;
for [
-562949953421312,
-4398046511104,
-34359738368,
-2147483647,
-268435456,
-2097152,
-1048576,
-16384,
-8192,
-4096,
-128,
-64,
0,
64,
128,
4096,
8192,
16384,
1048576,
2097152,
268435456,
2147483647,
34359738368,
4398046511104,
562949953421312,
] -> $x {
for [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5] -> $y {
my $z := $x + $y;
my $sc := nqp::createsc("IN_$k");
my $sh := nqp::list_s();
my $type := nqp::knowhow().new_type(:name('Badger'), :repr('P6bigint'));
$type.HOW.compose($type);
add_to_sc($sc, 0, $type);
add_to_sc($sc, 1, nqp::box_i($z, $type));
my $serialized := nqp::serialize($sc, $sh);
my $dsc := nqp::createsc("OUT_$k");
nqp::deserialize($serialized, $dsc, $sh, nqp::list(), nqp::null());
ok(nqp::unbox_i(nqp::scgetobj($dsc, 1)) == $z, 'serialized P6bigint instance has correct value');
$k := $k + 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment