-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
413 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt.asIntN | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.sameValue(BigInt.asIntN(1, 3n), -1n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt.asUintN | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.sameValue(BigInt.asUintN(1, 3n), 1n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: Prototype of BigInt constructor | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.sameValue(Object.getPrototypeOf(BigInt), Function.prototype); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt constructor | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.throws(TypeError, () => new BigInt(0)); | ||
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt string parsing | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.throws(SyntaxError, () => BigInt.parseInt("")); | ||
assert.throws(SyntaxError, () => BigInt.parseInt("@")); | ||
assert.throws(SyntaxError, () => BigInt.parseInt("1", 1)); | ||
assert.throws(SyntaxError, () => BigInt.parseInt("1", 37)); | ||
assert.sameValue(BigInt.parseInt("0xf", 0), 0xfn); | ||
assert.sameValue(BigInt.parseInt("-0"), 0n); | ||
assert.sameValue(BigInt.parseInt(" 0@"), 0n); | ||
assert.sameValue(BigInt.parseInt("kf12oikf12oikf12oi", 36), | ||
5849853453554480289462428370n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt prototype object attributes | ||
esid: pending | ||
features: [BigInt] | ||
includes: [propertyHelper.js] | ||
---*/ | ||
|
||
verifyNotWritable(BigInt, "prototype"); | ||
verifyNotEnumerable(BigInt, "prototype"); | ||
verifyNotConfigurable(BigInt, "prototype"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: Prototype of BigInt.prototype | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.sameValue(Object.getPrototypeOf(BigInt.prototype), Object.prototype); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt toString method | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
const n = 1234567890n; | ||
const strs = { | ||
2: "1001001100101100000001011010010", | ||
3: "10012001001112202200", | ||
4: "1021211200023102", | ||
5: "10012022133030", | ||
6: "322301024030", | ||
7: "42410440203", | ||
8: "11145401322", | ||
9: "3161045680", | ||
10: "1234567890", | ||
11: "583977146", | ||
12: "2a5555016", | ||
13: "168a0865a", | ||
14: "b9d6b5aa", | ||
15: "735b7d60", | ||
16: "499602d2", | ||
17: "30288g3a", | ||
18: "20568ad0", | ||
19: "174b57c7", | ||
20: "j5g0jea", | ||
21: "e8605e3", | ||
22: "ajc3e26", | ||
23: "87ifcgi", | ||
24: "6b1230i", | ||
25: "51ac8ff", | ||
26: "3pnfhma", | ||
27: "3511eki", | ||
28: "2fkfbqa", | ||
29: "225ep2g", | ||
30: "1ko4m30", | ||
31: "1c3ou0k", | ||
32: "14pc0mi", | ||
33: "vi0m56", | ||
34: "r5spaa", | ||
35: "nhokia", | ||
36: "kf12oi" | ||
}; | ||
|
||
assert.throws(TypeError, () => BigInt.prototype.toString.call(null)); | ||
assert.sameValue(n.toString(), n.toString(10)); | ||
assert.sameValue(n.toString(undefined), n.toString(10)); | ||
for (let radix of [1, 37, NaN, 0, Infinity]) { | ||
assert.throws(RangeError, () => n.toString(radix)); | ||
assert.throws(RangeError, () => n.toString(-radix)); | ||
} | ||
for (let i = 2; i < 37; i++) { | ||
for (let x of [n, Object(n)]) { | ||
assert.sameValue(x.toString(i), strs[i]); | ||
assert.sameValue(x.toString(i + 0.5), strs[i]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt valueOf method and thisBigIntValue operation | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.sameValue(BigInt.prototype.valueOf.call(0n), 0n); | ||
assert.sameValue(BigInt.prototype.valueOf.call(Object(0n)), 0n); | ||
assert.throws(TypeError, () => BigInt.prototype.valueOf.call(null)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: JSON serialization of BigInt values | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.throws(TypeError, () => JSON.stringify(0n)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt to Number conversion | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.sameValue(Number(0n), 0); | ||
assert.sameValue(+(new Number(0n)), +(new Number(0))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: Conversion of BigInt values to Objects | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert(Object(0n) instanceof BigInt); | ||
assert.sameValue(Object(0n).valueOf(), 0n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: RequireObjectCoercible for BigInt values | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
try { | ||
let {} = 0n; | ||
} catch (e) { | ||
$ERROR('Expected RequireObjectCoercible to succeed for BigInt values'); | ||
} | ||
|
||
assert.sameValue(Object.setPrototypeOf(0n, null), 0n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: ToString for BigInt values | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
const ToString = (x) => x + ""; | ||
|
||
assert.sameValue(ToString(-1n), "-1"); | ||
assert.sameValue(ToString(0n), "0"); | ||
assert.sameValue(ToString(1n), "1"); | ||
assert.sameValue(ToString(1234567890n), "1234567890"); | ||
assert.sameValue(ToString(-1234567890n), "-1234567890"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt division | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.throws(RangeError, () => 1n / 0n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt equality | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert("x" != 0n); | ||
assert(0n != "x"); | ||
assert(true != 0n); | ||
assert(false != 1n); | ||
assert(0n != true); | ||
assert(1n != false); | ||
assert(0n != NaN); | ||
assert(0n != Infinity); | ||
assert(0n != -Infinity); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt equality | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert("" == 0n); | ||
assert("0" == 0n); | ||
assert(0n == ""); | ||
assert(0n == "0"); | ||
assert(true == 1n); | ||
assert(false == 0n); | ||
assert(1n == true); | ||
assert(0n == false); | ||
assert(0n == 0); | ||
assert(0 == 0n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt exponentiation | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.throws(RangeError, () => 1n ** -1n); | ||
assert.sameValue(0n ** 0n, 1n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt comparison | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert(1n >= 0); | ||
assert(1 >= 0n); | ||
assert(1n >= 1); | ||
assert(1 >= 1n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt comparison | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert(1 > 0n); | ||
assert(1n > 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt comparison | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert(0n <= 1); | ||
assert(0 <= 1n); | ||
assert(1n <= 1); | ||
assert(1 <= 1n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt comparison | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert(0n < 1); | ||
assert(0 < 1n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: Conversion of BigInt values to booleans | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.sameValue(!!0n, false, "Expected ToBoolean(0n) to be false"); | ||
assert.sameValue(!!1n, true, "Expected ToBoolean(1n) to be true"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: BigInt modulus | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.throws(RangeError, () => 1n % 0n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: Conversion of BigInt values to numbers | ||
esid: pending | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.throws(TypeError, () => +0n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (C) 2017 Robin Templeton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: Binary BigInt literal containing an invalid digit | ||
esid: pending | ||
features: [BigInt] | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
---*/ | ||
|
||
0b2n; |
Oops, something went wrong.