mirror of https://github.com/tc39/test262.git
Merge pull request #1514 from cxielarko/remove-issafeinteger
remove IsSafeInteger checks for BigInt
This commit is contained in:
commit
1155332c93
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
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 )
|
||||
|
||||
...
|
||||
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");
|
|
@ -1,20 +0,0 @@
|
|||
// 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);
|
|
@ -1,40 +0,0 @@
|
|||
// 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);
|
||||
});
|
|
@ -1,4 +1,4 @@
|
|||
// 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);
|
||||
|
|
Loading…
Reference in New Issue