Skip to content
Snippets Groups Projects
Commit bf1b79d6 authored by Robin Templeton's avatar Robin Templeton
Browse files

remove IsSafeInteger checks for BigInt

parent 08cc5a8f
No related branches found
No related tags found
No related merge requests found
// Copyright (C) 2017 Robin Templeton. All rights reserved.
// Copyright (C) 2018 Igalia, S.L. 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
description: BigInt constructor called with integer argument
esid: sec-bigint-constructor
info: |
BigInt ( value )
...
3. If Type(prim) is Number, return ? NumberToBigInt(prim).
...
NumberToBigInt ( number )
2. If IsSafeInteger(number) is false, throw a RangeError exception.
...
3. Return a BigInt representing the mathematical value of number.
features: [BigInt]
---*/
assert.sameValue(BigInt(Number.MAX_SAFE_INTEGER), 9007199254740991n);
assert.sameValue(BigInt(-Number.MAX_SAFE_INTEGER), -9007199254740991n);
var pos = Math.pow(2, 53);
var neg = -pos;
assert.sameValue(BigInt(pos), 9007199254740992n,
"BigInt(2**53) === 9007199254740992n");
assert.sameValue(BigInt(neg), -9007199254740992n,
"BigInt(2**53) === -9007199254740992n");
// Copyright (C) 2017 Robin Templeton. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: BigInt throws a RangeError if value is not a safe integer.
esid: sec-bigint-constructor
info: |
BigInt ( value )
...
2. Let prim be ? ToPrimitive(value, hint Number).
3. If Type(prim) is Number, return ? NumberToBigInt(prim).
...
NumberToBigInt ( number )
...
2. If IsSafeInteger(number) is false, throw a RangeError exception.
...
IsSafeInteger ( number )
...
3. Let integer be ToInteger(number).
4. If integer is not equal to number, return false.
5. If abs(integer) ≤ 2**53-1, return true.
6. Otherwise, return false.
features: [BigInt]
---*/
var pos = Math.pow(2, 53);
var neg = -pos;
assert.throws(RangeError, function() {
BigInt(pos);
});
assert.throws(RangeError, function() {
BigInt(neg);
});
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// Copyright (C) 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
......@@ -20,7 +20,7 @@ values.forEach(function(value, i) {
() => sample.setBigInt64(0, BigInt(value), false),
"value: " + value);
return;
} else if (!Number.isInteger(value) || value > 9007199254740991) {
} else if (!Number.isInteger(value)) {
assert.throws(RangeError,
() => sample.setBigInt64(0, BigInt(value), false),
"value " + value);
......
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