Commit eff7f321 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[bigint] Add tests for unary/binary ops

The tests are generated randomly, using Python's arbitrary-precision
integers as the source of truth.
The generator script is landed as part of this CL. It also supports
a "stress test" mode for on-demand intensive test coverage.

Bug: v8:6791
Change-Id: Idc7a2e90fd8a0a8176283614b33ecd4c3597b1d1
Reviewed-on: https://chromium-review.googlesource.com/731464
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48844}
parent 3f95a446
......@@ -114,6 +114,7 @@ MaybeHandle<BigInt> BigInt::Remainder(Handle<BigInt> x, Handle<BigInt> y) {
AbsoluteDivLarge(x, y, nullptr, &remainder);
}
remainder->set_sign(x->sign());
remainder->RightTrim();
return remainder;
}
......@@ -1018,6 +1019,12 @@ Handle<BigInt> BigInt::SpecialLeftShift(Handle<BigInt> x, int shift,
int result_length = mode == kAlwaysAddOneDigit ? n + 1 : n;
Handle<BigInt> result =
x->GetIsolate()->factory()->NewBigIntRaw(result_length);
if (shift == 0) {
for (int i = 0; i < n; i++) result->set_digit(i, x->digit(i));
if (mode == kAlwaysAddOneDigit) result->set_digit(n, 0);
return result;
}
DCHECK_GT(shift, 0);
digit_t carry = 0;
for (int i = 0; i < n; i++) {
digit_t d = x->digit(i);
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
var data = [{
a: "a2102214b151421124f462d37f843",
b: "90f3fa0f2fb9b1481b1a4737586ad6bdf71cb2ae51e06fdcb00fb779163e94ae4237",
r: "90f3fa0f2fb9b1481b1a4737586ad6bdf71cb2b872e29127c523d88b6584c1e63a7a"
}, {
a: "35ca28bdd383c1b9ffdb851cc7f385ad370eef3d",
b: "-ca2d4dd677f23e005f44ec121303c3c304940eb2fd15e9e88772a3c5ba8515",
r: "-ca2d4dd677f23e005f44ebdc48db05ef80d254b32190cd2093ecf68eab95d8"
}, {
a: "-8abb4b6ca534b584fad2f5898dd22ae6",
b: "0",
r: "-8abb4b6ca534b584fad2f5898dd22ae6"
}, {
a: "b3",
b: "4180a0a",
r: "4180abd"
}, {
a: "-8de89",
b: "c329fbab24d762a9453f90b134fcf5da9777aa1fdb26b74f27583a92a43f0f2c450",
r: "c329fbab24d762a9453f90b134fcf5da9777aa1fdb26b74f27583a92a43f0e9e5c7"
}, {
a: "-49af5f350d64c75047dfb107550dae478c983dd520e86c9807b1f5",
b: "60a62691669b8c323a29db2eb9cb75ba5811",
r: "-49af5f350d64c750477f0ae0c3a712bb5a5e13f9f22ea1224d59e4"
}, {
a: "80bf614aaa1140792099375f7fac9c7046303a8d13086755d505795f38761",
b: "-949dc945",
r: "80bf614aaa1140792099375f7fac9c7046303a8d13086755d50570155be1c"
}, {
a: "4241d736e6a40",
b: "-78e88f5eaeae4ff8b",
r: "-78e84d1cd7776954b"
}, {
a: "-8033927bf52210827b99e712fb220631503adfaa4e0045c872b9b",
b: "-2f",
r: "-8033927bf52210827b99e712fb220631503adfaa4e0045c872bca"
}, {
a: "-3ad8b67efe9",
b: "-35586bf43788fd8e313da33c62d9a5",
r: "-35586bf43788fd8e314150c7cac98e"
}, {
a: "-a43d8c9af54e8ea545e1af4674613932650c833669c7adc9273b77",
b: "-6a4",
r: "-a43d8c9af54e8ea545e1af4674613932650c833669c7adc927421b"
}, {
a: "26c178e22dd42280a59b",
b: "fba77d85ba082981ce4a1ca21ac8b805b389297dc",
r: "fba77d85ba082981ce4a1f0e3256dae2f5b133d77"
}, {
a: "-c9bc2ac82920efc63fa48f63fae105ec432672b50269fad72ee8b44a1",
b: "8967d49deeff878f40fa1bf408400b8085820d47b",
r: "-c9bc2ac82920efc5b63cbac60be17e5d022c56c0fa29ef56a966a7026"
}, {
a: "815a18c9a2d8c6e5f3fffa958430851c4ea3",
b: "59d451c6efad276d3cc393907dda0eca463488958f397bb09",
r: "59d451c6efad2f82de502dbe0a486e0a45dde0d8978b409ac"
}, {
a: "8cfc360e8d215045cb5c289a50e5c7fa9da34c0b9d9be9597e6e476efdb121",
b: "-482747619f0edd06",
r: "8cfc360e8d215045cb5c289a50e5c7fa9da34c0b9d9be9115726e5cfeed41b"
}, {
a: "346337dbb9bbfc08cb815434c50315d32d",
b: "-ac569f54f5ea8852463c7542e876a9953",
r: "299dcde66a5d5383a71d8ce0967bab39da"
}, {
a: "8bb7c3e56",
b: "-c334d52ed6eb903256253e01fc0c5118fe9bc",
r: "-c334d52ed6eb903256253e01fc0bc5613ab66"
}, {
a: "b1f444a7a95e6d1d293ff0182e3dd5e945234484a5b47516b5b42627ed54fa8cf1221e",
b: "-93b77e906778b7e0a85c07e08babe730edd93ed37adef19da9e76de2add3",
r: "b1f444a7a8cab59e98d877604d9579e16497989d74c69bd7e23947364fab131f0e744b"
}, {
a: "9a156524b9",
b: "-bce28d1561fc0153b836c6e0969d2674fcb960331cdb55df24e34e4b65136fcb59",
r: "-bce28d1561fc0153b836c6e0969d2674fcb960331cdb55df24e34e4acafe0aa6a0"
}, {
a: "5eaf418fbccefb4f53abc413c02cee60eb3880b615c615c2005b3d11c8ee4aaf3b4ded8",
b: "-eb8aa4a72cf44f06208",
r: "5eaf418fbccefb4f53abc413c02cee60eb3880b615c615c2005a518724471dbaec47cd0"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var b = BigInt.parseInt(d.b, 16);
var r = a + b;
if (d.r !== r.toString(16)) {
print("Input A: " + a.toString(16));
print("Input B: " + b.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
print("Op: +");
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
var data = [{
a: "-193b47d0d9a8688b329e80de92195f311825",
b: "-2fabed9434bff933e23ea21af0f21a43",
r: "-193b6ffbfdbc7cbffbbfe2feb21bfff31a67"
}, {
a: "35979ec99b7ff03f81817ebc9ddd50025d1ccf41565b502f0fc85ec54f630",
b: "be96016cc031653c9b1eceb1dd",
r: "8c9401648000603c810c44b010"
}, {
a: "-f594f8199c11594681a9c38fd985a03d8c79ce6c8d342809924c89b385af43116ec3a21",
b: "-53e7b9738caaecc58fde1b5a4aa9f782f28a04e2bb29d207ccd5d45",
r: "-f594f8199c115946d3effbffddafecfd8fffdf7ecfbdff8bf2ce8df3bfafd317eed7f65"
}, {
a: "dd7245d3ca5b360296082e6ca91915179b257f36e45e6e44cf892db875fdcfb19522b3",
b: "-dcc83137df3bb234e1144390f6c5bc0772a07f2a4540865554d20ebd37be",
r: "dd7245d3ca0336028000044c891801140b013a02e00c4e00c5882d3820a90db1000002"
}, {
a: "-28",
b: "eaec4017147fd9741ff3b98f1b6f71d8f3d6869c18b39c6237a6b2d4d2fc3c81e9",
r: "eaec4017147fd9741ff3b98f1b6f71d8f3d6869c18b39c6237a6b2d4d2fc3c81c8"
}, {
a: "-223909fc585f36f995d6f72dd9f169df1fad8",
b: "b13e919ce59c18c7c0517eecdb2519155cc",
r: "80360184a0880042000052240a040000508"
}, {
a: "-fcb4ac9fdc7ee85d03585f944a79b28efffb461e17df2d",
b: "13cd27fb49c92d53c567688ab6b9",
r: "38023b100492100042160882091"
}, {
a: "-1a16ca8c3725cec0c8a61ce81",
b: "-dbf3e",
r: "-1a16ca8c3725cec0c8a6dffbe"
}, {
a: "-834db45b67472062091e",
b: "5aff66623af6b6cd042a361d5a22aea03152b764a056c71",
r: "5aff66623af6b6cd042a361d5a228a2030408304a056460"
}, {
a: "1a8c37cff2e02f5272bc61d60b8301e443c38172446f75d75e01c41f60",
b: "e15d12bee18edaca77ad15ff0a567e132bb1b046623858",
r: "215012bc61860a8201a401c30052440321911000401840"
}, {
a: "-f463",
b: "bb02038e2ff03fa",
r: "bb02038e2ff0398"
}, {
a: "3178f92d2eeee1aebc33f085aa96c9046f1133ad6afbd666664ab79625639e001",
b: "124d8bd8ea20d8e510ba30d9",
r: "20d02406020586010382001"
}, {
a: "fc7aaaa7a52f3604e1e700f01ea6f266912f583bffa78aee08939401056cde",
b: "-50e3611d6ada075f432319f10c8192f1de56ead628972",
r: "fc7aaaa7a52f3604e0e100e008025202010d4820ef2782c00012900005648e"
}, {
a: "7dea10c67bdf023c00d94643e9f2d38295635b0b2b55a0e40818",
b: "8defe4741785c6c2d2ecaf7752a903ed",
r: "443e0701380844252082b5500a00008"
}, {
a: "6f837e0ec2d00abb60051299bfd36b58c803f6445f91bb8dded858c6c1c476142",
b: "-26746eda5ca5095ab8f315c88b201cfa2affbbb700fc3bba8626b5bfd0a",
r: "6f837e08829000a3400400010cc22350c80304440000088d02c04040c14040042"
}, {
a: "ab69c286138358dea4308b60f12f212fcd1e0",
b: "-c8735b6ce5513cc661fdae7941055028a2ea768dc13b9c83a79b9bf84e62cdf",
r: "aa29c2041181501e84200840602401218d120"
}, {
a: "6c9ec2e7cdb2c1fb630a8e16323138db939c2a21e3576b777d",
b: "-51cf93f77a711c00",
r: "6c9ec2e7cdb2c1fb630a8e16323138db938c202000050a6400"
}, {
a: "edee34cd0c29ad27fed12e77a42aedbf8b53161716c90d516394b9038a2f125c95",
b: "-18a515e3705a582d82f14bd42075b3b",
r: "edee34cd0c29ad27fed12e77a42aedbf8b52140600c8085061049003022d100485"
}, {
a: "466fee7dabecbaea71c19892f045d7d196a80c6f",
b: "-5c93c7afd552be",
r: "466fee7dabecbaea71c19892f001441010280c42"
}, {
a: "-657c587f67a70177797befb96f116c2843",
b: "-c3b8e2",
r: "-657c587f67a70177797befb96f11efb8e4"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var b = BigInt.parseInt(d.b, 16);
var r = a & b;
if (d.r !== r.toString(16)) {
print("Input A: " + a.toString(16));
print("Input B: " + b.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
print("Op: &");
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
// TODO(adamk/jkummerow/neis): Support BigInts in TF unary ops.
// Flags: --noopt
var data = [{
a: "-609648ccf253976b12f6b6c8e20790c17ef6b89ea9f536267783607cf465b1ca",
r: "-609648ccf253976b12f6b6c8e20790c17ef6b89ea9f536267783607cf465b1cb"
}, {
a: "-6e4c39cdd2c666e32cf2fd3c53a20eeb725e7578af97d42",
r: "-6e4c39cdd2c666e32cf2fd3c53a20eeb725e7578af97d43"
}, {
a: "34c93e1c",
r: "34c93e1b"
}, {
a: "-db3032",
r: "-db3033"
}, {
a: "8e658ffacbefbdec5",
r: "8e658ffacbefbdec4"
}, {
a: "-d321033ec94d6a75f",
r: "-d321033ec94d6a760"
}, {
a: "-286017f718d6118b581ec4357e456ce6d12c01aed9a32ff0cc048d",
r: "-286017f718d6118b581ec4357e456ce6d12c01aed9a32ff0cc048e"
}, {
a: "c0",
r: "bf"
}, {
a: "9f9577e008a6f46f7709f71362176ebe23d19eb9e58a41de6f2631b18f2ca",
r: "9f9577e008a6f46f7709f71362176ebe23d19eb9e58a41de6f2631b18f2c9"
}, {
a: "-9d4294590df0aa8ea46a5c2a3d186a6afcc00c6ebb072752",
r: "-9d4294590df0aa8ea46a5c2a3d186a6afcc00c6ebb072753"
}, {
a: "-4bc2aed1641151db908c0eb21aa46d8b406803dc0f71d66671322d59babf10c2",
r: "-4bc2aed1641151db908c0eb21aa46d8b406803dc0f71d66671322d59babf10c3"
}, {
a: "-1dfb3929632fbba39f60cabdc27",
r: "-1dfb3929632fbba39f60cabdc28"
}, {
a: "c0d409943c093aec43ba99a33ef2bb54574ecdc7cccf6547ab44eafb27",
r: "c0d409943c093aec43ba99a33ef2bb54574ecdc7cccf6547ab44eafb26"
}, {
a: "3d148dcffe94f859c80b38c4",
r: "3d148dcffe94f859c80b38c3"
}, {
a: "0",
r: "-1"
}, {
a: "d659f6507e0ac2e653bdb7c3fb38c1514dd33619a9a0c87fcb69b22",
r: "d659f6507e0ac2e653bdb7c3fb38c1514dd33619a9a0c87fcb69b21"
}, {
a: "14efe",
r: "14efd"
}, {
a: "-f2df301948cd17ff391a6589a67551c00679687ba5",
r: "-f2df301948cd17ff391a6589a67551c00679687ba6"
}, {
a: "-e",
r: "-f"
}, {
a: "-a09cf77fea7af1767695c978af13fdb62f4f040b6fb803625fb124cc99139cddadd",
r: "-a09cf77fea7af1767695c978af13fdb62f4f040b6fb803625fb124cc99139cddade"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var r = --a;
if (d.r !== r.toString(16)) {
print("Input: " + a.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
var data = [{
a: "c0bb18527ab19a800932cc14c553c69688372809dde38f095fdb99478a7eba",
b: "8137ebc482f361a3e43fb80fe2ba509caa3f0acc62be0d2",
r: "17dd3b8ecbdd71a4"
}, {
a: "10c5163e874c786fcfcb48bbb0ccf8d6c66f480b76332194",
b: "4e462b2",
r: "36d8ca96869a7226d456bff9b5ed3effdcaaf6f83"
}, {
a: "-677f8c8668fcc826129f2724a5b88a6225dd19959810b5254afbc0",
b: "-2bf8ff1c49636",
r: "25a8bd406d721554f45ad37cc691d58821ad163f3a"
}, {
a: "e80276ba7d416f4f7e5f8917529eb204cc7ed08413261e73aa23f169eb46e7162",
b: "-c884f07a",
r: "-12834073e7cbc44804a99cb2778fb82b098645946d5e4f5e6c47c49267"
}, {
a: "-f9a51f64ce995e0a1c7f8369a573dae2533bc3df801edbb79235d41502e1ce",
b: "-f33bf",
r: "106bf522569501704f9700d6bfcd203a606e63725e339e92ff931f568f"
}, {
a: "-6c9ae08dfa5b11c29ae30e53c108d915e0e87f1a8ca82f42d23a53b08895",
b: "-43fd79afe1ae6a4994ee7dfc2c89453d6b6",
r: "198ecd667e8cca17c2839b38fe"
}, {
a: "-d20a2f7074ecbc776b64c2e04ff007e194b8cdd106b2be2e78d752f2d16e9",
b: "43eb8ae7d7f9be6d77e3be696ffef",
r: "-317ab1a09014950e1c53b9e3e8f44873c"
}, {
a: "-999e0f75f2f652d403840cea3536b1a522433a331dace7c39d7990b993908fdd6",
b: "cea1de74020232c6c4bedca49d63f140c",
r: "-be51ac62c073e7d7cb9e43fc12436bfe"
}, {
a: "1b49ac0c323436294f1471a3f00feb197b9b42549c3",
b: "5a7e30888a22fbbcecfe2a0b2e5eca30",
r: "4d321e8fe1c"
}, {
a: "-689adf0d332ed26c63f8f361d5cb66056321b683ce87c60567df7305396f20d6ab8",
b: "82f3b92f5bb57811fdb66f519",
r: "-cc7e64b9ef239ac4c31b6ae3687aa181bda7657222"
}, {
a: "-6fecb457f9e05c15b7fe038494c25053938d4747a01577cf2dc939a21e",
b: "b7cb6ce62c1d7483d0b675109f5782a1ad19",
r: "-9be52d2e94716bb441dbcd"
}, {
a: "f96f8276f314d37657ce7774bc539198ee84fcec8a53cbb3d36ad81040b715",
b: "-891c9a0dd99b02",
r: "-1d1b803e3484173c0d2e8add5042117eaa27c853c222f5fdd"
}, {
a: "-d2c9a9068d57f2ebc9ad432b48b4135f2a911519d4b791",
b: "-a34d124b5b4825d314683098d0",
r: "14a715b96671307438926"
}, {
a: "-59593d55f61c1c739601e15624fe2e61592fe6abf1ecb238c9f8e1a7bded9c1bd1c",
b: "f067a5a155fc894b0f7f0a939f1772c4d135a",
r: "-5f250867331e7eff64dafcd58e9922"
}, {
a: "2c0a3172494623013ba14d01433ad38167f365765b1c0ca610",
b: "ffe8",
r: "2c0e52ca0c37483000215020c64d6ac36a455bf6fa4382"
}, {
a: "-a9cde7cdfe56eb8bd6777543ae714fadac2d97a394d8e9e8",
b: "104b0d7135d3d2",
r: "-a6bfb9031e60b5bc4b20e814cabfd80bd27"
}, {
a: "6216ceed0d221476bfba7701f8297af56a4e66d003f8165b",
b: "bfcaaf8676ad6a",
r: "82ed6efc83669b0bc476bdd717dcfb6f10"
}, {
a: "-707752a899efbe8989d205293535a404a6afb39cf21ce1274",
b: "-3a24848be1024a6ea901f",
r: "1ef2f2a8c0ad85ff4e6e6afdd3966"
}, {
a: "-e662fb8c46f979ff3b3f576fffd5c51cf70071ab61168b2eafee4708af",
b: "964c4dd019b9a543df0cd1830a90428ec84ec04f8165283",
r: "-18869d87ce54"
}, {
a: "b4403dee3a192009a5aae85c74efdb52b66dee1be6befa66f708ca9bf6b7",
b: "-36db9f9f6e",
r: "-34928ce65c2b71a6b6ce351838d4263d91ff2bceecec7a91441"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var b = BigInt.parseInt(d.b, 16);
var r = a / b;
if (d.r !== r.toString(16)) {
print("Input A: " + a.toString(16));
print("Input B: " + b.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
print("Op: /");
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
// TODO(adamk/jkummerow/neis): Support BigInts in TF unary ops.
// Flags: --noopt
var data = [{
a: "-989c298c6fc3",
r: "-989c298c6fc2"
}, {
a: "bff2c86c449a56",
r: "bff2c86c449a57"
}, {
a: "-6fb15264369b63e3b92d6f74458140d4b62a56ecbfca000492b6b8a0c56c651ebaecdd1",
r: "-6fb15264369b63e3b92d6f74458140d4b62a56ecbfca000492b6b8a0c56c651ebaecdd0"
}, {
a: "e161f6284b91fa2646dc0f162c575bb8a0d0f5bfee26748b7181413567",
r: "e161f6284b91fa2646dc0f162c575bb8a0d0f5bfee26748b7181413568"
}, {
a: "-4d073653cc812",
r: "-4d073653cc811"
}, {
a: "-ce31549364717dea9d1bf30baed642f",
r: "-ce31549364717dea9d1bf30baed642e"
}, {
a: "2ae123a62361f1de2cc5ca9cfd9658f47d",
r: "2ae123a62361f1de2cc5ca9cfd9658f47e"
}, {
a: "-4820298153b7bbd86337ad72e0d1ac7448de99bc6ce4c43c2",
r: "-4820298153b7bbd86337ad72e0d1ac7448de99bc6ce4c43c1"
}, {
a: "2e",
r: "2f"
}, {
a: "-8f3b598ac2ab8a78a2d3e1f7ab1124b05a830aa1261bf57d8de2a",
r: "-8f3b598ac2ab8a78a2d3e1f7ab1124b05a830aa1261bf57d8de29"
}, {
a: "-5c070fdee0d3f4a9adc63",
r: "-5c070fdee0d3f4a9adc62"
}, {
a: "-3700cd6a6d1e68de1",
r: "-3700cd6a6d1e68de0"
}, {
a: "56c68c",
r: "56c68d"
}, {
a: "-1ab894376fcf0dab9c",
r: "-1ab894376fcf0dab9b"
}, {
a: "-937dcf37c57588e55260c3eea20318",
r: "-937dcf37c57588e55260c3eea20317"
}, {
a: "-f8ee63b438580a8915baf84edcfd0688247905e593e153644a88761bab0",
r: "-f8ee63b438580a8915baf84edcfd0688247905e593e153644a88761baaf"
}, {
a: "-c63d4353ddf575bf02",
r: "-c63d4353ddf575bf01"
}, {
a: "-bef439cc990a8b1d69b80fa7b3c703ba2",
r: "-bef439cc990a8b1d69b80fa7b3c703ba1"
}, {
a: "6007edbd20b0ba90d86cf80e871e898c8907bb37",
r: "6007edbd20b0ba90d86cf80e871e898c8907bb38"
}, {
a: "-692b36b5e874a448415678ac2b4d0a61c75bdc1674ae14d753cad7d46846",
r: "-692b36b5e874a448415678ac2b4d0a61c75bdc1674ae14d753cad7d46845"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var r = ++a;
if (d.r !== r.toString(16)) {
print("Input: " + a.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
var data = [{
a: "-67c2a5ba4221c048b64ecca6dd979391c44296b8b87ce97584ebab03be18",
b: "-bebdbd9b278d05704416fd87d09aece9b69f98843",
r: "-8794ba5d9204eb8adfb5e44c11a65fe5af057e6a4"
}, {
a: "-843cfbe576106b8e7c0aabec2cde402e7f76a711dbbf6ae79d6d932e22cf",
b: "553d800ffcf69f80026",
r: "-272250d344908c21525"
}, {
a: "-b5fc9e8e21fbad798bcd3571ab169dd5e2059d1a9aa4d1bf44fe18da725b",
b: "-da5d287414fbb2b4b",
r: "-2610eb2277e01a758"
}, {
a: "a9c92d42b53a6fbf0824f5b7bd9ed1cab1f9419d7ec2b50f192abfa6d620d53",
b: "9de30592e1fe27d26afe06bbb4781c77ef58418",
r: "9a67af5868a619a48883aed4c0d0a876e2ce143"
}, {
a: "ffa271b138163a779c89f17aa720490854520120b1307ef",
b: "ab27ef49f3a00085981a5bc1c13530aec35e29c",
r: "4c49a63b98d2dd7a33a843f98ba82b54909e337"
}, {
a: "d43f739464bcc8643dfaa807cbbe1157189e33368dd19b800db3682bb0dcb73",
b: "bf66b1dc93054920039f9b3eba688d9",
r: "bb2f3000959d66b3962d755d141c3ac"
}, {
a: "111ae5ba62ec37fd157ef531195363c5c8ace4427ff58811746af94ab8",
b: "58112d0d88f3c8722d1e28942e8949c433c4619b451",
r: "283276aa2b6316ca2146b1e6bcc8aa8de4b5446847a"
}, {
a: "-4609a1c7d563bbdb49fd01e05031395e6e06b78407e440",
b: "-75ee71f85344163bae2ba0e438",
r: "-68b517938971cb261babea1cf8"
}, {
a: "292cd2c5eb3e80942066c5af8bfdaf8d1d091f61f3005d226318",
b: "5",
r: "3"
}, {
a: "-a9f8c03f06200b54959a2ced325090be25417f0bf1274d",
b: "13eb3a0c772fc98e537883a3ef72e1ee37b249ee17c0510",
r: "-a9f8c03f06200b54959a2ced325090be25417f0bf1274d"
}, {
a: "c4ddadae9abee150068fe6536c6b2fe229070410da61a09abe1a7270b",
b: "5f4d55e3345e37fe8887f3ca5e",
r: "42eea65dd545aacdcd250b505b"
}, {
a: "-7a73d61e639dacedd207dfe1edc630b1dfda9078489a7f0cf79dcdfcbf3992efc13861f",
b: "-c0f2b9045bb3865d89cc0c9920c3ccfae382c250",
r: "-6bdc3d5943d7a35e4ecbc5c8deb335ca2c3bbc0f"
}, {
a: "-a9ac4a2e055f22c8ba7956ffca5457a71412eb74d3a180555bb25ce5096e23d6c619",
b: "-f3c",
r: "-a5d"
}, {
a: "-b16cfd7fbbf820afc77be1590fd9802ecd12059238b98bb96d9d215af4808",
b: "2c288a9de167",
r: "-2b3901c1b8d1"
}, {
a: "-df12dd3e56dc3c3dd769ad964f8356a5860177f1b4a3b95acc75",
b: "4ec6f5474b18",
r: "-17bf0980582d"
}, {
a: "1d197bf4aa09a02760cb004e9edf25e6591ae14d92b6cbf1349ea1c040d66",
b: "-23ebacc5f380e5649a1234c3ed050472569cbcd056",
r: "20e5e588b4861be3ec7b4005a6a50566e60a3a4364"
}, {
a: "fab19b7e774bf33bb42a7af90d8dc75cbc927e3225003610c05b117c25c90944d",
b: "-3b433469282a54d46cac",
r: "10eda9e98b721b4a2505"
}, {
a: "5b19514660782d3a2429d7791659868abb9d8fc96077247",
b: "-59188be60",
r: "2340c3607"
}, {
a: "-2884ed1401b5e976be7dc1faf7bffb632c808649fa75ab458cc66ef4e75",
b: "bf",
r: "-40"
}, {
a: "-4c9cdf26be1797e54480ab20797e35d04941c11ff78b040c00099422cec",
b: "ee20f34835529f4a73",
r: "-e24db40426d47f968b"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var b = BigInt.parseInt(d.b, 16);
var r = a % b;
if (d.r !== r.toString(16)) {
print("Input A: " + a.toString(16));
print("Input B: " + b.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
print("Op: %");
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
var data = [{
a: "-be5e349bf5ad48e7a5d",
b: "a47a19a48667620a82973579739e08c64651b3ede2c578ff975e",
r: "-7a4f25aa8725368922062fc91a110352a660657ffb3a489126ded10ccd29d929120c926"
}, {
a: "912d5d85aec5ec6caf90514f0ec005f711caac82960c0ee911ef30f145107ae236783e6",
b: "0",
r: "0"
}, {
a: "-87c17f6930bdef7e7c7ae7dab8be3baa2e7d67",
b: "285af6503c42d077a0d59558deb170bad",
r: "-1566788db7747e33ddb6540190617b57856e5f3924447f9f400f34a9aa75aa7d20f2b9b"
}, {
a: "-3d0fd72abc5fb82d5cf45679812b71",
b: "-3c537c742e17c5fac136e33f5e7edf256ef52b6df",
r: "e63a0402966391e13e600371183f223379b66912ee706a2b369668b3e33e9a15992d6f"
}, {
a: "dfd77cf4b0d071df2487c9b77959ee027380a159b0",
b: "-56300fb05cba28d5150892ff66e77",
r: "-4b5c6a1976d3a318cb9f93e154dc362da4e740fa31d82baefead60c355bfea99eaa50d0"
}, {
a: "-bea52261387bb2aaf8c61b5ee7bbf85b3bbbedfe60773ed9873cbceba078d3fecbb",
b: "-2ad7",
r: "1fe73453d2eabb331a676ede8eb9759c8c6bffe09c76947578e08b0152379841d867f0d"
}, {
a: "5b5a3a047d8f7e1519d6d92d3241c0f32c4d789",
b: "-4bd3e8c09b0ba71bc25416877a4c7135",
r: "-1b0f0d6ba20fe60049c4a172e8b1fb9824c1e85e21f1ebe08556b7074d8d4f4ac90185d"
}, {
a: "1b2c8263d4bac8cc825657f81fca6196799aff00fa960d5c04",
b: "-6b140fca30c8037b18d88",
r: "-b5dbba6fba700592408e2ebbba2d4c6557d61d1201e24314f690e77c0b59c68d8b1620"
}, {
a: "dd74f1f92ab5b9e0b447b7fe9076f7",
b: "-9dbb0acb24e6336fe4f37f8e942d1d5c22dfe4f34",
r: "-88728628dd4ed79514e720448e4f9ad422ba6ca62cd61bf779cfb3cb12afb5bbe20632c"
}, {
a: "-e97d2712832aa20a",
b: "-cb98c0fa9b4b35fc7a4ebed6d3d106bb758c244eb756c75587300ad",
r: "b9b1904d502a19d20cc7bd8e05670f667db817bb9104ef8acc747f3df6541eede4d80c2"
}, {
a: "828ca2d8981f347f4bec14ba",
b: "-8ce5b6b1c329477a0a728ed81331af1f03e3eaa1ccb2cb3",
r: "-47da0e06c179e58b3e5d8abc4a2b274ede3a7d73c0b5fcb3690f0b544ed6c0b7120760e"
}, {
a: "aade382f2483a571e12cb1796bd124e21c6014261cef5d733a1b35fb01db7232c5b",
b: "-d34a",
r: "-8d068c8b18b90f6aaf82ed3260f68bdb06bf64613cdda736fc33395b7d16688edb9d34e"
}, {
a: "34188043594e64ac10b37923ad29b4b536a4098ce76c9133155820b7843de95af",
b: "106952",
r: "356f6c0aa4a1a0d27dd2e8867420eddcd9fb5614450d6bb85cba0071e03e4563a0b90e"
}, {
a: "96b2a125fc041fe36aebe7dfd02a4f56b90",
b: "-a9f9c57a732002abf0764868f297442f61d1",
r: "-640ef4605c38f6643d60526833e7a3b7b71a72b7042434abc0ca600e7f79b3aa98e6090"
}, {
a: "-ae8327a77a340d2c90c93bb0ebe02d7a77d7c2a4e8d21a21d0",
b: "268a49068f2769f949d95",
r: "-1a45bc5e1b636b28bf716dfeaf0599cd932270796233adf7d58b8d72d06ac580c323e10"
}, {
a: "-a0adcb953540a4f25fc97a40a2c9285bfba7e70e4ffc",
b: "fff2302a069e8f69d00e529a81b",
r: "-a0a5204f09eeb3ecd9fe2c6de34d0e0ed70c6d1589d95fd83de33d921a3152dfe5bcf94"
}, {
a: "-83771467194c5b612539be7228f366a8",
b: "9412ce8f98510486287bc15c35883fff04d126e",
r: "-4c0a803e9a079742969e01dbb7990566b2f5ac9658653c967b5d295f6a996ba1655ec30"
}, {
a: "12c3327d3d7ed4b3180cc301f98d351804451be431137fa48aa67627db867a2cd",
b: "-ee0af6",
r: "-11724697fa94a9caafbee6e7b778ecae17ed7ebba5575296b1fc4995a12fe5c9a8872fe"
}, {
a: "-5",
b: "-a00c8e774e3d4a6fc2fa384382720700e49e3e4b882bb5c4c0dbe4cdcd92126731128b",
r: "3203ec8548732742ecee319518c3a230477173779a8da8cd7c44b780503da5c03f55cb7"
}, {
a: "a0a4dc9610ada50dfa633ad910a02aa20c85",
b: "-4d7aa1dc1cc1d1767b4e25a839e7c177652",
r: "-309e8a7c10fbc6b50f6ad012099765a35395b9d51112d50e0a8f3ac076942a9e5a0509a"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var b = BigInt.parseInt(d.b, 16);
var r = a * b;
if (d.r !== r.toString(16)) {
print("Input A: " + a.toString(16));
print("Input B: " + b.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
print("Op: *");
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
// TODO(adamk/jkummerow/neis): Support BigInts in TF unary ops.
// Flags: --noopt
var data = [{
a: "58ad59aa3aa9d04d4c12493966e204ef0500d5f92ecb31",
r: "-58ad59aa3aa9d04d4c12493966e204ef0500d5f92ecb31"
}, {
a: "6dbd19e4b781a8f113ae95738dda4b70ba027755052126c198d20ade97869ff",
r: "-6dbd19e4b781a8f113ae95738dda4b70ba027755052126c198d20ade97869ff"
}, {
a: "d02befb1c96364a984664f85",
r: "-d02befb1c96364a984664f85"
}, {
a: "86",
r: "-86"
}, {
a: "0",
r: "0"
}, {
a: "-f8da",
r: "f8da"
}, {
a: "2b0f358b54a82fbaddc5a6e61a5d",
r: "-2b0f358b54a82fbaddc5a6e61a5d"
}, {
a: "-3d32065b9bbb36ee521ff82da",
r: "3d32065b9bbb36ee521ff82da"
}, {
a: "ca3da934e8081c457933c90",
r: "-ca3da934e8081c457933c90"
}, {
a: "-e4d2bbdf90affad1d2a",
r: "e4d2bbdf90affad1d2a"
}, {
a: "-290845e8f55d467e3",
r: "290845e8f55d467e3"
}, {
a: "-771c77d2dd2227c30cf44f1bf3230",
r: "771c77d2dd2227c30cf44f1bf3230"
}, {
a: "-77aa11",
r: "77aa11"
}, {
a: "d220c8af9c97516bf5ec295585f711e020480d08ac11689726a285930",
r: "-d220c8af9c97516bf5ec295585f711e020480d08ac11689726a285930"
}, {
a: "53841e699f994e1a43f7f848f34d418792191de15b78e1a852c430b2f8af6e7",
r: "-53841e699f994e1a43f7f848f34d418792191de15b78e1a852c430b2f8af6e7"
}, {
a: "7c30187b8901bd748adc4bc243",
r: "-7c30187b8901bd748adc4bc243"
}, {
a: "-e07ac5649eb741a023b0f9928d5982032f6766a479c7fbf26",
r: "e07ac5649eb741a023b0f9928d5982032f6766a479c7fbf26"
}, {
a: "5ab3237bb32234bcaf8",
r: "-5ab3237bb32234bcaf8"
}, {
a: "7df7",
r: "-7df7"
}, {
a: "-518b7b",
r: "518b7b"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var r = -a;
if (d.r !== r.toString(16)) {
print("Input: " + a.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
// TODO(adamk/jkummerow/neis): Support BigInts in TF unary ops.
// Flags: --noopt
var data = [{
a: "3d02c87edc77722299f6559ecca038911f864a4e78c20af80f4a6d9",
r: "-3d02c87edc77722299f6559ecca038911f864a4e78c20af80f4a6da"
}, {
a: "ac01894aeaf77255ede209897561ec1e3c7e916b9",
r: "-ac01894aeaf77255ede209897561ec1e3c7e916ba"
}, {
a: "-7aaab657ab197f26eb6b98fe4c2c79b199a8156129ca04",
r: "7aaab657ab197f26eb6b98fe4c2c79b199a8156129ca03"
}, {
a: "9718579cc52befdaff1ec035b5ed03cec5c1d1678c28712cf0c9bec2c807897b74f0",
r: "-9718579cc52befdaff1ec035b5ed03cec5c1d1678c28712cf0c9bec2c807897b74f1"
}, {
a: "e614366bc4e67509843254c52e13da5380b00a35aa1d233e70821f7d649ad1957db",
r: "-e614366bc4e67509843254c52e13da5380b00a35aa1d233e70821f7d649ad1957dc"
}, {
a: "fb815f78e6952b500226c",
r: "-fb815f78e6952b500226d"
}, {
a: "94404df802649cff2ea6c0996f55ec60c14f00ab29b287092389951f6227c4ec7",
r: "-94404df802649cff2ea6c0996f55ec60c14f00ab29b287092389951f6227c4ec8"
}, {
a: "-74b42cd7bccd",
r: "74b42cd7bccc"
}, {
a: "da",
r: "-db"
}, {
a: "3a9ade198",
r: "-3a9ade199"
}, {
a: "56e766d24fd18c2241f244dedc426c0b1ae59e7ed4f06def0a75e0a5c8651e2ce87928",
r: "-56e766d24fd18c2241f244dedc426c0b1ae59e7ed4f06def0a75e0a5c8651e2ce87929"
}, {
a: "cc430c91347b22ecb1a6f1a2ceea168ffa4a9b80065bd1ec5d",
r: "-cc430c91347b22ecb1a6f1a2ceea168ffa4a9b80065bd1ec5e"
}, {
a: "32e4b7f82d8c037d0f562296e21b1e58a",
r: "-32e4b7f82d8c037d0f562296e21b1e58b"
}, {
a: "-526d3f1a904561f0cde1f0a2a4",
r: "526d3f1a904561f0cde1f0a2a3"
}, {
a: "3de5a9635a40539831c9665577e5eedbf680755e2065a0caa346759e17225",
r: "-3de5a9635a40539831c9665577e5eedbf680755e2065a0caa346759e17226"
}, {
a: "-d912828b8d6419900",
r: "d912828b8d64198ff"
}, {
a: "-17968ddf93",
r: "17968ddf92"
}, {
a: "-c2bfd766e34923d549bbaedb4d9b7bb35a61908e6144462a",
r: "c2bfd766e34923d549bbaedb4d9b7bb35a61908e61444629"
}, {
a: "af426ec83aaafc84a94930e51a2899696a3d",
r: "-af426ec83aaafc84a94930e51a2899696a3e"
}, {
a: "-283de5b9379a45f065d3b8662ac38faa6492bc0eea6b7e3b51591a5cc27669e",
r: "283de5b9379a45f065d3b8662ac38faa6492bc0eea6b7e3b51591a5cc27669d"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var r = ~a;
if (d.r !== r.toString(16)) {
print("Input: " + a.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
var data = [{
a: "a66",
b: "d0671cd6e4ebd7baf6e48b2529348cfa89fc9513ba30ef3f99aee07f267df163cf8",
r: "d0671cd6e4ebd7baf6e48b2529348cfa89fc9513ba30ef3f99aee07f267df163efe"
}, {
a: "a9950e5fc429f0f93d5fa8f306f4e5da88a8c9f9",
b: "d1fc1ac3db7ff5547462800923e616727120f74f0a6cb7bf1886dd4f4ac",
r: "d1fc1ac3db7ff554746a9959e7fe56ff7fb3f7ff8f7cffff5daedfcfdfd"
}, {
a: "5e277a64b6515ad69ed8935ae8dcdb6dc66f98fcbb462b10bea0db15ad6010d",
b: "7df3",
r: "5e277a64b6515ad69ed8935ae8dcdb6dc66f98fcbb462b10bea0db15ad67dff"
}, {
a: "3b8368196588e684403965902763d66aa",
b: "-edf58c5ab418f49cf9fdb7f3b1c416a03c1dfbe90ba7ea6373c",
r: "-edf58c5ab418f49cf9c43493a0801600381dc2880b808821112"
}, {
a: "-5587f5e86137f8ea4d7259acdd0b77a26ea069385501c9985df6a5fcd3c",
b: "9878871628ea5cb66",
r: "-5587f5e86137f8ea4d7259acdd0b77a26ea069385501811849d605a041a"
}, {
a: "-dc65679b1ea7c86c10890e6d6be3bd069b4c7",
b: "83ea9",
r: "-dc65679b1ea7c86c10890e6d6be3bd0618047"
}, {
a: "-755f422bfb614b7ed2c8e05cd1e0e0a",
b: "-d3185fac5454a495d7b149e67df4436339e060d924d",
r: "-24154221496049744240204040c0209"
}, {
a: "-1dfdf84b41ddd069053",
b: "f9b2bc80b580311773e9a5d57e8f24ace46bd2a0fce24404db684efa8692638b5d604e6",
r: "-1105784900548009011"
}, {
a: "18d1b78380aa9016029417c2ebe77a",
b: "-b63b35e6711dcbf00dc02cd936",
r: "-3835446109c9600800041806"
}, {
a: "-9981f",
b: "-5d876576146a2d5dc8d52d26ea3304287af0922685f8e1a46875e80f24a470",
r: "-800f"
}, {
a: "-20f8052991bc5a8f2631c9e4b34aa9073a69913185a539d719",
b: "a59fdaa025b42",
r: "-20f8052991bc5a8f2631c9e4b34aa9073a6991200005398419"
}, {
a: "-d02620570",
b: "-3b14d75fb9d9b95d13f884a82c9f16",
r: "-400200506"
}, {
a: "-8",
b: "-4",
r: "-4"
}, {
a: "e0e8ab319d1f051560e1155ae5789dd4d9b638e07e5a57c3432e6cb9239d",
b: "85c9cd1f09436dc45ac783f31a21a1ff4e11ceca00cc164",
r: "e0e8ab319d1f0d5dfcf1f5def7fcddfcf9bf39e27e5ff7e35feeecbde3fd"
}, {
a: "8131173cb5597e2ae560cae6d0907f004792b1b1c7",
b: "-2ac290724a7c86",
r: "-c290604a4c01"
}, {
a: "bdb24fd4d78b01d77e41d95f2c3eedeb2bf919",
b: "-97f6ccbd94d64ada501e0f288568",
r: "-14f60881940600d2401204000467"
}, {
a: "-d5ad86f9a4808394f6e7dcd2a67bd3e6a9",
b: "1a80309934942e4e55fbf2ba4d1d2f8cc4697338097e2c1b7ce013da8a79965974286",
r: "-408c066804000010f6c25450261a40a429"
}, {
a: "c7a0086120a1613a28456",
b: "b8",
r: "c7a0086120a1613a284fe"
}, {
a: "c8480c",
b: "0",
r: "c8480c"
}, {
a: "ec8913fc89aa7a47672bc0f5269e8629cabf2dba88836cb3a9",
b: "-52594e7",
r: "-4010447"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var b = BigInt.parseInt(d.b, 16);
var r = a | b;
if (d.r !== r.toString(16)) {
print("Input A: " + a.toString(16));
print("Input B: " + b.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
print("Op: |");
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
var data = [{
a: "-4efa0d1f8a127",
b: "-66",
r: "-13be8347e2849c0000000000000000000000000"
}, {
a: "853cd87b0bd5c046aecbf4b3d",
b: "-96",
r: "214f361ec2f57011abb2fd2cf40000000000000000000000000000000000000"
}, {
a: "-4bc82dba903fedec0a079f7ae4fa6bd6befa",
b: "0",
r: "-4bc82dba903fedec0a079f7ae4fa6bd6befa"
}, {
a: "43969b4db0d921d9f0ca68f74e4e4b9073732a7955a5b4571",
b: "-91",
r: "872d369b61b243b3e194d1ee9c9c9720e6e654f2ab4b68ae2000000000000000000000000000000000000"
}, {
a: "495f57",
b: "-a5",
r: "92beae00000000000000000000000000000000000000000"
}, {
a: "-22109b99d3025aaef5c3fbd27420a72",
b: "45d",
r: "-1"
}, {
a: "b3f6b156f4afcf259efd3cd1",
b: "c7",
r: "0"
}, {
a: "137aeeadc8d1395042e80393cc1b6a1c7b6e526ab1b6fc2f2859fd70e0c29df2802",
b: "f49",
r: "0"
}, {
a: "70f51026476e43bd7e911d37a4553701",
b: "33",
r: "e1ea204c8edc877afd2"
}, {
a: "-3f935a89481c85d666498cf64fdc2a57028f7b295621dc665c0442229563",
b: "-2",
r: "-fe4d6a2520721759992633d93f70a95c0a3deca5588771997011088a558c"
}, {
a: "-c3",
b: "-87",
r: "-618000000000000000000000000000000000"
}, {
a: "aae225520f630c0dfbb815f121836612d75a1f65a301461cd05ad0a741496",
b: "-4",
r: "aae225520f630c0dfbb815f121836612d75a1f65a301461cd05ad0a7414960"
}, {
a: "a5348f9af939041cc6ed386c060619a42f30c4aa8",
b: "95",
r: "529a"
}, {
a: "-4c27fc7e3892a6a5b517",
b: "-6c",
r: "-4c27fc7e3892a6a5b517000000000000000000000000000"
}, {
a: "98efd35f2239f7efde9aef42ad0acd835e68ad868a2cd8fac260f1c7496e3fd2ada76",
b: "0",
r: "98efd35f2239f7efde9aef42ad0acd835e68ad868a2cd8fac260f1c7496e3fd2ada76"
}, {
a: "-92f0264c863bdf66d4c83e8bf812123d759b4",
b: "-96",
r: "-24bc0993218ef7d9b5320fa2fe04848f5d66d00000000000000000000000000000000000000"
}, {
a: "ec6341ff2b0e9cf8721e2eb4ec9c9",
b: "74",
r: "0"
}, {
a: "-32de8dced947fa55cd0b91332a81f70",
b: "-5b",
r: "-196f46e76ca3fd2ae685c8999540fb800000000000000000000000"
}, {
a: "-3ef43bf8610f6533526ba734e85eafa04cd50a3",
b: "-25",
r: "-7de877f0c21eca66a4d74e69d0bd5f4099aa146000000000"
}, {
a: "-9979591a367a32ae0039c54fd0f3d9e0ccc80be52b7e517fc94d9f3587dc54d933bb",
b: "0",
r: "-9979591a367a32ae0039c54fd0f3d9e0ccc80be52b7e517fc94d9f3587dc54d933bb"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var b = BigInt.parseInt(d.b, 16);
var r = a >> b;
if (d.r !== r.toString(16)) {
print("Input A: " + a.toString(16));
print("Input B: " + b.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
print("Op: >>");
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
var data = [{
a: "-9a6d035348727045f6abf7d59056d30e9ce885e87f5f8438347bfcda0a1f9b",
b: "-2",
r: "-269b40d4d21c9c117daafdf56415b4c3a73a217a1fd7e10e0d1eff368287e7"
}, {
a: "615f9676062ea7a1b89396ce4208712f279475490829",
b: "ff",
r: "30afcb3b031753d0dc49cb672104389793ca3aa484148000000000000000000000000000000000000000000000000000000000000000"
}, {
a: "-9b6131d8b806543fce32b4c2ca2038ffa956929848a61b5eb7f",
b: "-e7",
r: "-1"
}, {
a: "-331d9e",
b: "0",
r: "-331d9e"
}, {
a: "cb79696d3a6f5d5d034e9d2",
b: "-d33",
r: "0"
}, {
a: "ca99",
b: "10",
r: "ca990000"
}, {
a: "6f97833d5",
b: "0",
r: "6f97833d5"
}, {
a: "67d36e7948d18af35f0823c0d58ba47ca0846cdfaa7a7407f09d44747275532681b343",
b: "f",
r: "33e9b73ca468c579af8411e06ac5d23e5042366fd53d3a03f84ea23a393aa99340d9a18000"
}, {
a: "f4896",
b: "-7",
r: "1e91"
}, {
a: "996ce2a9e0f7d65e0523204c9c469bfd14821efe571ac59cdc01",
b: "1d",
r: "132d9c553c1efacbc0a464099388d37fa29043dfcae358b39b8020000000"
}, {
a: "-f8f",
b: "f1",
r: "-1f1e000000000000000000000000000000000000000000000000000000000000"
}, {
a: "-b685bbcd953ba9c5973ae523dc81d7b35e0cf2b9b51026d4ba1ac21bd5c3c18f9c13",
b: "0",
r: "-b685bbcd953ba9c5973ae523dc81d7b35e0cf2b9b51026d4ba1ac21bd5c3c18f9c13"
}, {
a: "e2295b362b7048fb163d1272178ed441517fc689e5ec5ea40f29",
b: "-30",
r: "e2295b362b7048fb163d1272178ed441517fc689"
}, {
a: "-b322e816b014448f44e60b418582390d2a3ad95",
b: "0",
r: "-b322e816b014448f44e60b418582390d2a3ad95"
}, {
a: "4c135e4d7",
b: "0",
r: "4c135e4d7"
}, {
a: "-d5b694",
b: "f1",
r: "-1ab6d28000000000000000000000000000000000000000000000000000000000000"
}, {
a: "-7994be7",
b: "-d",
r: "-3ccb"
}, {
a: "a6443add555ea15af90092e8",
b: "42",
r: "29910eb75557a856be4024ba00000000000000000"
}, {
a: "9385ed",
b: "e5",
r: "1270bda000000000000000000000000000000000000000000000000000000000"
}, {
a: "-531",
b: "7d",
r: "-a620000000000000000000000000000000"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var b = BigInt.parseInt(d.b, 16);
var r = a << b;
if (d.r !== r.toString(16)) {
print("Input A: " + a.toString(16));
print("Input B: " + b.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
print("Op: <<");
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
var data = [{
a: "e5e5071838eb1314",
b: "3b7f55dce703a25ea14fdea6186156f775dec5d29f6edb3a014",
r: "-3b7f55dce703a25ea14fdea6186156f775d067822deb4c88d00"
}, {
a: "-f",
b: "22d6805c7201a8ad4b9e6c2a7e8b5ab3bac",
r: "-22d6805c7201a8ad4b9e6c2a7e8b5ab3bbb"
}, {
a: "-22",
b: "-11a0adfaedd5adb92297af1c3794ef5461dd8bc146db3",
r: "11a0adfaedd5adb92297af1c3794ef5461dd8bc146d91"
}, {
a: "-d20c39d0",
b: "-46faa9d3eabcbd8b6d07adc2d0ff289d2",
r: "46faa9d3eabcbd8b6d07adc2c3de65002"
}, {
a: "-e5b56109a11",
b: "211e1dcdf52f020ab0f16e18cc4e46027d05bfa3155b88973e630ae9a75bf2c7fbad269",
r: "-211e1dcdf52f020ab0f16e18cc4e46027d05bfa3155b88973e630ae9a75cd87d5cb6c7a"
}, {
a: "-b682aa",
b: "-5fa59a6a80d39c0c885c030e9c8c84ec7",
r: "5fa59a6a80d39c0c885c030e9c811cc1d"
}, {
a: "-c1325b8ab9fea966f093bbfbc2e611b0e5bf0b13ce047c7133056d4eea",
b: "f97d5c4014c5cc87923c344a",
r: "-c1325b8ab9fea966f093bbfbc2e611b0e6b888700e19423dba97a98334"
}, {
a: "-1872900ab729911a3c021db53672eda07a9ad623",
b: "152d13997090c43551edfc89d4c7ea5e9ffee4a114085858892e67e82edea6384aaaba7",
r: "-152d13997090c43551edfc89d4c7ea602727e54c86a169fc4950433b960d803ff4581ca"
}, {
a: "5440388fc10de9",
b: "-4b",
r: "5440388fc10e34"
}, {
a: "-198dc54795a81722f70acc9cc20505492172c7819ba168e57d",
b: "-48f3b40bf850f771d44e423eb266846801d9e4e920c",
r: "-198dc543066cd66371fb557f7d20e15dfb0a81017e031a5371"
}, {
a: "c78082429b3163ce243c778",
b: "-97afe29",
r: "c78082429b3163cebbec5a1"
}, {
a: "-50df",
b: "-d5352ec9c1b0e62b97ea1363ce8b72",
r: "d5352ec9c1b0e62b97ea1363ce3a93"
}, {
a: "-5c9777f93d64636ff8bcda39125625aa58a49e9a4f29ece2b7afa5d",
b: "894bb7aa90b8687e6290c3218a4258dac9400d556caafe02cf8c312c053f2fc73",
r: "-894bb7aa9114fff65bce2784fa3b15b50252637b1703a2a169db5b18e7f6df6d0"
}, {
a: "-e15c51f0627e460c477",
b: "-dfd13bac43ebe2f8e77f5b31314843",
r: "dfd13bac43ddcd33c879334cd083cc"
}, {
a: "0",
b: "adbd3e4b06b92771ae25eb52fca5fc86391303ebf7962",
r: "-adbd3e4b06b92771ae25eb52fca5fc86391303ebf7962"
}, {
a: "960a8aa627a1c48721f4e0",
b: "-9e8742ae61615481cdd12f0728f0b61",
r: "9e8742ae6ac1fd2c304b4b4f9b10041"
}, {
a: "-abf5cf9ff3c15b0645009",
b: "-e805773176aaa712d144e172db033c64aeaddf3380b2",
r: "e805773176aaa712d144e1681ba6426572982ecf30a9"
}, {
a: "349ebb89b13a7149ec1a4e067574c3825f90ec4e4413948b808c6a",
b: "-44cdc0e3efa11513525f68163033a59d7b0610070",
r: "349ebb89b13a7596c8288d0086c5f8a856124f517e6d6c3be18cda"
}, {
a: "a86c53e8c49b20cff057882c4345c40f5c34a8cb8",
b: "-76453703c781511b52e663",
r: "a86c53e8c49b20cff05eec7fb3823c246de9d731b"
}, {
a: "-2647d3c",
b: "776e5b3a57bd5196be1b9c99ae899d949cb2b94310c53be8910db71b",
r: "-776e5b3a57bd5196be1b9c99ae899d949cb2b94310c53be893723457"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var b = BigInt.parseInt(d.b, 16);
var r = a - b;
if (d.r !== r.toString(16)) {
print("Input A: " + a.toString(16));
print("Input B: " + b.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
print("Op: -");
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by tools/bigint-tester.py.
// Flags: --harmony-bigint
var data = [{
a: "abde23cae3113c95ec7f444c7277658",
b: "-65e40fb1",
r: "-abde23cae3113c95ec7f444a2c379e9"
}, {
a: "2d0bbdc05059c78b7e9f43689b2f7a9afaefd679212c2a9b990",
b: "29fcdb109b54650f9762b494916bc1cf14853430697febe7acf4327983ce0c6c4c183",
r: "29fcdb109b54650f974fbf29513b98089ffbab7301e4c49d360eddaffaef2046d7813"
}, {
a: "b958dc77068d01811e031d6320df5e53823697be94f7654340b",
b: "-c1f5ca609a658e24fc33fec10a84b18fb745cb7c6",
r: "-b958dc77064cf44b7e9978ed04236dad433c130f1b4020883cf"
}, {
a: "cf7319e3fe16912370c830906f88b",
b: "98d972f3c",
r: "cf7319e3fe16912370c8a8491d7b7"
}, {
a: "aea6d9e7cec74bca19",
b: "5abbcd0c5aa1f96fef9db32b3618de782db64b8f6b4",
r: "5abbcd0c5aa1f96fef9db32b3cf2b3e6515a3f33cad"
}, {
a: "-b522a022e90fa094f3b729a7a0a914349f5e1fd778829d7576ad36711",
b: "-aa00d2fd6a7636",
r: "b522a022e90fa094f3b729a7a0a914349f5e1fd778883d78597b91125"
}, {
a: "9c2bc822ec4a590eb8a77ee630009713090",
b: "30b13459c1434",
r: "9c2bc822ec4a590eb8a77ed68134ced24a4"
}, {
a: "-f14873e1f6121d584d5541073c7ce162873e156b72fb3c943ffd5f212c0d6",
b: "f449f0a292048546924d2973626f5441c045d4adbfd00d301791f0db965f",
r: "-fe0cecebdf32550c247193900a5a14269b3a4821a9063c473e84402c9568b"
}, {
a: "83d5552fba4213d8dd1ed9bc6c2",
b: "4f7ccc10ba9b6880b862f8d5e1c9",
r: "47419942413f49bd35b3154e270b"
}, {
a: "9fdb44741177921c8338b70fc7fa362295bfc92f6275fa16492",
b: "93676e5ef972",
r: "9fdb44741177921c8338b70fc7fa362295bfc92654031ff9de0"
}, {
a: "4355637ed",
b: "-7aeb3013cc5eb39d56eed8104407a3e68039944f7673a0c75bd3",
r: "-7aeb3013cc5eb39d56eed8104407a3e68039944f767795916c40"
}, {
a: "7fdf50188f716c13feced67a1c33ecf422",
b: "-7106cd7b9",
r: "-7fdf50188f716c13feced67a1b2380239b"
}, {
a: "368cf8d0f5790a03774b9a1e116f82281ebd9e18de7f54a7d91f50",
b: "8bc4e4f24ce2a7d037079552e6c7db2795f15c92a01f4e0d9",
r: "368cf06cbb362ecd5d36996e683aac44630fe747cbb67ea62dff89"
}, {
a: "-7466a596078a20cc4eca96953e3",
b: "-666328e5437b1475dcfe2f44f1c6a82af82ce7ee7cf229c8398836d2d834f9014",
r: "666328e5437b1475dcfe2f44f1c6a82af82ce79a1a57bfcfb3a8fa9c12a26c3f1"
}, {
a: "ad284b70a22d96bdefba53f134c65a1e4958013bb9a31f091fde6fc89",
b: "-c89374df2",
r: "-ad284b70a22d96bdefba53f134c65a1e4958013bb9a31f09d74d1b179"
}, {
a: "-47df52354db5",
b: "-aa7f61aba9ad859e803e964418af30",
r: "aa7f61aba9ad859e807949162de29b"
}, {
a: "-f03ea80f22a3dc03f036b13f85faf5fb1",
b: "86e9110772d369fdd52b45a8fb22cea26cb73e908408f8a3cdf637f0042c8efdc11",
r: "-86e9110772d369fdd52b45a8fb22cea26c4700388b2a5b7fce0601413ba974083a2"
}, {
a: "3603d29c8",
b: "f4849ec3ec3c352b",
r: "f4849ec08c011ce3"
}, {
a: "e6668ed8eae8b4bb7bdf522d44e9f1bcf66",
b: "361cab4f5be1",
r: "e6668ed8eae8b4bb7bdf522e25234549487"
}, {
a: "-d0395d",
b: "-4a8ee89d006d22a124070241caf5f4343bdfd30d12",
r: "4a8ee89d006d22a124070241caf5f4343bdf03344d"
}];
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
var a = BigInt.parseInt(d.a, 16);
var b = BigInt.parseInt(d.b, 16);
var r = a ^ b;
if (d.r !== r.toString(16)) {
print("Input A: " + a.toString(16));
print("Input B: " + b.toString(16));
print("Result: " + r.toString(16));
print("Expected: " + d.r);
print("Op: ^");
error_count++;
}
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}
#!/usr/bin/python
# Copyright 2017 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import math
import multiprocessing
import os
import random
import subprocess
import sys
import tempfile
# Configuration.
kChars = "0123456789abcdefghijklmnopqrstuvwxyz"
kBase = 16
kLineLength = 71 # A bit less than 80.
kNumInputsGenerate = 20
kNumInputsStress = 1000
# Internally used sentinels.
kNo = 0
kYes = 1
kRandom = 2
TEST_HEADER = """\
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Generated by %s.
// Flags: --harmony-bigint
""" % sys.argv[0]
TEST_BODY = """
var error_count = 0;
for (var i = 0; i < data.length; i++) {
var d = data[i];
%s
}
if (error_count !== 0) {
print("Finished with " + error_count + " errors.")
quit(1);
}"""
def GenRandom(length, negative=kRandom):
if length == 0: return "0"
s = []
if negative == kYes or (negative == kRandom and (random.randint(0, 1) == 0)):
s.append("-") # 50% chance of negative.
s.append(kChars[random.randint(1, kBase - 1)]) # No leading zero.
for i in range(1, length):
s.append(kChars[random.randint(0, kBase - 1)])
return "".join(s)
def Format(x, base):
original = x
negative = False
if x == 0: return "0"
if x < 0:
negative = True
x = -x
s = ""
while x > 0:
s = kChars[x % base] + s
x = x / base
if negative:
s = "-" + s
assert int(s, base) == original
return s
class TestGenerator(object):
# Subclasses must implement these.
# Returns a JSON snippet defining inputs and expected output for one test.
def EmitOne(self): raise NotImplementedError
# Returns a snippet of JavaScript that will operate on a variable "d"
# whose content is defined by the result of a call to "EmitOne".
def EmitTestCore(self): raise NotImplementedError
def EmitHeader(self):
return TEST_HEADER
def EmitData(self, count):
s = []
for i in range(count):
s.append(self.EmitOne())
return "var data = [" + ", ".join(s) + "];"
def EmitTestBody(self):
return TEST_BODY % self.EmitTestCore()
def PrintTest(self, count):
print(self.EmitHeader())
print(self.EmitData(count))
print(self.EmitTestBody())
def RunTest(self, count, binary):
try:
fd, path = tempfile.mkstemp(suffix=".js", prefix="bigint-test-")
with open(path, "w") as f:
f.write(self.EmitData(count))
f.write(self.EmitTestBody())
return subprocess.call("%s --harmony-bigint %s" % (binary, path),
shell=True)
finally:
os.close(fd)
os.remove(path)
class UnaryOp(TestGenerator):
# Subclasses must implement these two.
def GetOpString(self): raise NotImplementedError
def GenerateResult(self, x): raise NotImplementedError
# Subclasses may override this:
def GenerateInput(self):
return GenRandom(random.randint(0, kLineLength))
# Subclasses should not override anything below.
def EmitOne(self):
x_str = self.GenerateInput()
x_num = int(x_str, kBase)
result_num = self.GenerateResult(x_num)
result_str = Format(result_num, kBase)
return "{\n a: \"%s\",\n r: \"%s\"\n}" % (x_str, result_str)
def EmitTestCore(self):
return """\
var a = BigInt.parseInt(d.a, %(base)d);
var r = %(op)sa;
if (d.r !== r.toString(%(base)d)) {
print("Input: " + a.toString(%(base)d));
print("Result: " + r.toString(%(base)d));
print("Expected: " + d.r);
error_count++;
}""" % {"op": self.GetOpString(), "base": kBase}
class BinaryOp(TestGenerator):
# Subclasses must implement these two.
def GetOpString(self): raise NotImplementedError
def GenerateResult(self, left, right): raise NotImplementedError
# Subclasses may override these:
def GenerateInputLengths(self):
return random.randint(0, kLineLength), random.randint(0, kLineLength)
def GenerateInputs(self):
left_length, right_length = self.GenerateInputLengths()
return GenRandom(left_length), GenRandom(right_length)
# Subclasses should not override anything below.
def EmitOne(self):
left_str, right_str = self.GenerateInputs()
left_num = int(left_str, kBase)
right_num = int(right_str, kBase)
result_num = self.GenerateResult(left_num, right_num)
result_str = Format(result_num, kBase)
return ("{\n a: \"%s\",\n b: \"%s\",\n r: \"%s\"\n}" %
(left_str, right_str, result_str))
def EmitTestCore(self):
return """\
var a = BigInt.parseInt(d.a, %(base)d);
var b = BigInt.parseInt(d.b, %(base)d);
var r = a %(op)s b;
if (d.r !== r.toString(%(base)d)) {
print("Input A: " + a.toString(%(base)d));
print("Input B: " + b.toString(%(base)d));
print("Result: " + r.toString(%(base)d));
print("Expected: " + d.r);
print("Op: %(op)s");
error_count++;
}""" % {"op": self.GetOpString(), "base": kBase}
class Neg(UnaryOp):
def GetOpString(self): return "-"
def GenerateResult(self, x): return -x
class BitNot(UnaryOp):
def GetOpString(self): return "~"
def GenerateResult(self, x): return ~x
class Inc(UnaryOp):
def GetOpString(self): return "++"
def GenerateResult(self, x): return x + 1
class Dec(UnaryOp):
def GetOpString(self): return "--"
def GenerateResult(self, x): return x - 1
class Add(BinaryOp):
def GetOpString(self): return "+"
def GenerateResult(self, a, b): return a + b
class Sub(BinaryOp):
def GetOpString(self): return "-"
def GenerateResult(self, a, b): return a - b
class Mul(BinaryOp):
def GetOpString(self): return "*"
def GenerateResult(self, a, b): return a * b
def GenerateInputLengths(self):
left_length = random.randint(1, kLineLength)
return left_length, kLineLength - left_length
class Div(BinaryOp):
def GetOpString(self): return "/"
def GenerateResult(self, a, b):
result = abs(a) / abs(b)
if (a < 0) != (b < 0): result = -result
return result
def GenerateInputLengths(self):
# Let the left side be longer than the right side with high probability,
# because that case is more interesting.
min_left = kLineLength * 6 / 10
max_right = kLineLength * 7 / 10
return random.randint(min_left, kLineLength), random.randint(1, max_right)
class Mod(Div): # Sharing GenerateInputLengths.
def GetOpString(self): return "%"
def GenerateResult(self, a, b):
result = a % b
if a < 0 and result > 0:
result -= abs(b)
if a > 0 and result < 0:
result += abs(b)
return result
class Shl(BinaryOp):
def GetOpString(self): return "<<"
def GenerateInputsInternal(self, small_shift_positive):
left_length = random.randint(0, kLineLength - 1)
left = GenRandom(left_length)
small_shift = random.randint(0, 1) == 0
if small_shift:
right_length = 1 + int(math.log((kLineLength - left_length), kBase))
neg = kNo if small_shift_positive else kYes
else:
right_length = random.randint(0, 3)
neg = kYes if small_shift_positive else kNo
right = GenRandom(right_length, negative=neg)
return left, right
def GenerateInputs(self): return self.GenerateInputsInternal(True)
def GenerateResult(self, a, b):
if b < 0: return a >> -b
return a << b
class Sar(Shl): # Sharing GenerateInputsInternal.
def GetOpString(self): return ">>"
def GenerateInputs(self):
return self.GenerateInputsInternal(False)
def GenerateResult(self, a, b):
if b < 0: return a << -b
return a >> b
class BitAnd(BinaryOp):
def GetOpString(self): return "&"
def GenerateResult(self, a, b): return a & b
class BitOr(BinaryOp):
def GetOpString(self): return "|"
def GenerateResult(self, a, b): return a | b
class BitXor(BinaryOp):
def GetOpString(self): return "^"
def GenerateResult(self, a, b): return a ^ b
OPS = {
"add": Add,
"sub": Sub,
"mul": Mul,
"div": Div,
"mod": Mod,
"inc": Inc,
"dec": Dec,
"neg": Neg,
"not": BitNot,
"shl": Shl,
"sar": Sar,
"and": BitAnd,
"or": BitOr,
"xor": BitXor
}
OPS_NAMES = ", ".join(sorted(OPS.keys()))
def RunOne(op, num_inputs, binary):
return OPS[op]().RunTest(num_inputs, binary)
def WrapRunOne(args):
return RunOne(*args)
def RunAll(args):
for op in args.op:
for r in xrange(args.runs):
yield (op, args.num_inputs, args.binary)
def Main():
parser = argparse.ArgumentParser(
description="Helper for generating or running BigInt tests.")
parser.add_argument(
"action", help="Action to perform: 'generate' or 'stress'")
parser.add_argument(
"op", nargs="+",
help="Operation(s) to test, one or more of: %s. In 'stress' mode, "
"special op 'all' tests all ops." % OPS_NAMES)
parser.add_argument(
"-n", "--num-inputs", type=int, default=-1,
help="Number of input/output sets in each generated test. Defaults to "
"%d for 'generate' and '%d' for 'stress' mode." %
(kNumInputsGenerate, kNumInputsStress))
stressopts = parser.add_argument_group("'stress' mode arguments")
stressopts.add_argument(
"-r", "--runs", type=int, default=1000,
help="Number of tests (with NUM_INPUTS each) to generate and run. "
"Default: %(default)s.")
stressopts.add_argument(
"-b", "--binary", default="out/x64.debug/d8",
help="The 'd8' binary to use. Default: %(default)s.")
args = parser.parse_args()
for op in args.op:
if op not in OPS.keys() and op != "all":
print("Invalid op '%s'. See --help." % op)
return 1
if len(args.op) == 1 and args.op[0] == "all":
args.op = OPS.keys()
if args.action == "generate":
if args.num_inputs < 0: args.num_inputs = kNumInputsGenerate
for op in args.op:
OPS[op]().PrintTest(args.num_inputs)
elif args.action == "stress":
if args.num_inputs < 0: args.num_inputs = kNumInputsStress
result = 0
pool = multiprocessing.Pool(multiprocessing.cpu_count())
for r in pool.imap_unordered(WrapRunOne, RunAll(args)):
result = result or r
return result
else:
print("Invalid action '%s'. See --help." % args.action)
return 1
if __name__ == "__main__":
sys.exit(Main())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment