Skip to content
Snippets Groups Projects
Unverified Commit 350d2c70 authored by Rick Waldron's avatar Rick Waldron Committed by GitHub
Browse files

Merge pull request #1302 from rwaldron/bigint-fixups

Bigint fixups
parents 1f1d2d27 a7fbcf3d
No related branches found
No related tags found
No related merge requests found
// Copyright (C) 2017 Robin Templeton. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Throws a TypeError if BigInt is called with a new target
esid: sec-bigint-constructor
info: |
...
3. If Type(prim) is Number, return ? NumberToBigInt(prim).
...
NumberToBigInt ( number )
2. If IsSafeInteger(number) is false, throw a RangeError exception.
features: [BigInt]
---*/
assert.sameValue(BigInt(Number.MAX_SAFE_INTEGER), 9007199254740991n);
assert.sameValue(BigInt(-Number.MAX_SAFE_INTEGER), -9007199254740991n);
......@@ -6,7 +6,6 @@ description: Throws a TypeError if BigInt is called with a new target
esid: sec-bigint-constructor
info: |
1. If NewTarget is not undefined, throw a TypeError exception.
2. Let prim be ? ToPrimitive(value, hint Number).
...
features: [BigInt]
---*/
......@@ -15,19 +14,8 @@ assert.throws(TypeError, function() {
new BigInt();
});
assert.throws(TypeError, function() {
new BigInt(NaN);
});
assert.throws(TypeError, function() {
new BigInt({
valueOf: function() { throw new Test262Error("unreachable"); }
});
});
for (let x of [NaN, Infinity, 0.5, 2**53]) {
assert.throws(RangeError, () => BigInt(x));
assert.throws(RangeError, () => BigInt(-x));
}
assert.sameValue(BigInt(9007199254740991), 9007199254740991n);
assert.sameValue(BigInt(-9007199254740991), -9007199254740991n);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment