v8/test/mjsunit/harmony/bigint/regressions.js
Mathias Bynens f7d357b20a Remove always-true --harmony-bigint runtime flag
It was shipped in Chrome 67.

Bug: v8:6791, v8:8238
Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;luci.chromium.try:linux_chromium_rel_ng;luci.v8.try:v8_linux_noi18n_rel_ng;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I94d8f0aa18570452403a35dea270b18f155c970a
Reviewed-on: https://chromium-review.googlesource.com/1253604
Reviewed-by: Georg Neis <neis@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56310}
2018-10-01 11:31:13 +00:00

40 lines
1.3 KiB
JavaScript

// 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.
var a = 5n;
var b = a / -1n;
assertEquals(5n, a);
assertEquals(-5n, b);
assertEquals(5n, 5n / 1n);
assertEquals(5n, -5n / -1n);
assertEquals(-5n, -5n / 1n);
assertEquals(0n, 5n % 1n);
assertEquals(0n, -5n % 1n);
assertEquals(0n, 5n % -1n);
assertEquals(0n, -5n % -1n);
assertTrue(0n === 0n);
// crbug.com/818277: Must throw without DCHECK failures.
// In order to run acceptably fast in Debug mode, this test assumes that
// we allow at least 2 billion bits in a BigInt.
var close_to_limit = 2n ** 2000000000n;
assertThrows(() => close_to_limit ** 100n, RangeError);
// Check boundary conditions of the power-of-two fast path.
// The following "max" constants are just under BigInt::kMaxLengthBits
// and replicate the computation of that constant.
var kMaxInt = 2n ** 31n - 1n;
var max64 = kMaxInt - 64n - 2n;
var max32 = kMaxInt - 32n - 2n;
// Platform independence trick: at least one of the two operations will throw!
assertThrows(() => { var a = 2n ** max32; var b = 2n ** max64; }, RangeError);
(function() {
function Constructor() { }
Constructor.prototype = 5n;
assertThrows(() => ({}) instanceof Constructor, TypeError);
})();