BigInt.parseInt tests (#1208)

* BigInt.parseInt tests

* update for PR#1208

* fix copyright notices
This commit is contained in:
Robin Templeton 2017-10-17 12:40:22 -04:00 committed by Leo Balter
parent 8837686ca5
commit 72fb638ca7
50 changed files with 2106 additions and 1 deletions

View File

@ -0,0 +1,49 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: 01234567890 parsed in different radices
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to the
specified radix. Leading white space in string is ignored. If radix is
undefined or 0, it is assumed to be 10 except when the number begins
with the code unit pairs 0x or 0X, in which case a radix of 16 is
assumed. If radix is 16, the number may also optionally begin with the
code unit pairs 0x or 0X.
[...]
NOTE: parseInt may interpret only a leading portion of string as an
integer value; it ignores any code units that cannot be interpreted as
part of the notation of an integer, and no indication is given that
any such code units were ignored.
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("01234567890", 2), 1n);
assert.sameValue(BigInt.parseInt("01234567890", 3), 5n);
assert.sameValue(BigInt.parseInt("01234567890", 4), 27n);
assert.sameValue(BigInt.parseInt("01234567890", 5), 194n);
assert.sameValue(BigInt.parseInt("01234567890", 6), 1865n);
assert.sameValue(BigInt.parseInt("01234567890", 7), 22875n);
assert.sameValue(BigInt.parseInt("01234567890", 8), 342391n);
assert.sameValue(BigInt.parseInt("01234567890", 9), 6053444n);
assert.sameValue(BigInt.parseInt("01234567890", 10), 1234567890n);

View File

@ -0,0 +1,41 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Boolean argument
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
1. Let inputString be ? ToString(string).
2. Let S be a newly created substring of inputString consisting of
the first code unit that is not a StrWhiteSpaceChar and all code
units following that code unit. (In other words, remove leading
white space.) If inputString does not contain any such code unit,
let S be the empty string.
[...]
11. If S contains a code unit that is not a radix-R digit, let Z be
the substring of S consisting of all code units before the first
such code unit; otherwise, let Z be S.
12. If Z is empty, return NaN.
features: [BigInt, arrow-function]
---*/
assert.throws(SyntaxError, () => BigInt.parseInt(true));
assert.throws(SyntaxError, () => BigInt.parseInt(false));
assert.throws(SyntaxError, () => BigInt.parseInt(new Boolean(true)));
assert.throws(SyntaxError, () => BigInt.parseInt(new Boolean(false)));

View File

@ -0,0 +1,35 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Number argument
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
1. Let inputString be ? ToString(string).
features: [BigInt, arrow-function]
---*/
assert.sameValue(BigInt.parseInt(-1), -1n);
assert.throws(SyntaxError, () => BigInt.parseInt(Infinity));
assert.throws(SyntaxError, () => BigInt.parseInt(NaN));
assert.sameValue(BigInt.parseInt(-0), 0n);
assert.sameValue(BigInt.parseInt(new Number(-1)), -1n);
assert.throws(SyntaxError, () => BigInt.parseInt(new Number(Infinity)));
assert.throws(SyntaxError, () => BigInt.parseInt(new Number(NaN)));
assert.sameValue(BigInt.parseInt(new Number(-0)), 0n);

View File

@ -0,0 +1,50 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Argument converted using ToPrimitive with hint Number
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
1. Let inputString be ? ToString(string).
features: [BigInt, arrow-function]
---*/
var object = {valueOf() {return 1}};
assert.throws(SyntaxError, () => BigInt.parseInt(object));
var object = {valueOf() {return 1}, toString() {return 0}};
assert.sameValue(BigInt.parseInt(object), 0n);
var object = {valueOf() {return 1}, toString() {return {}}};
assert.sameValue(BigInt.parseInt(object), 1n);
var object = {valueOf() {throw new Test262Error()}, toString() {return 1}};
assert.sameValue(BigInt.parseInt(object), 1n);
var object = {toString() {return 1}};
assert.sameValue(BigInt.parseInt(object), 1n);
var object = {valueOf() {return {}}, toString() {return 1}};
assert.sameValue(BigInt.parseInt(object), 1n);
var object = {valueOf() {return 1}, toString() {throw new Test262Error()}};
assert.throws(Test262Error, () => BigInt.parseInt(object));
var object = {valueOf() {return {}}, toString() {return {}}};
assert.throws(TypeError, () => BigInt.parseInt(object));

View File

@ -0,0 +1,32 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: String object argument
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
1. Let inputString be ? ToString(string).
features: [BigInt, arrow-function]
---*/
assert.sameValue(BigInt.parseInt(new String("-1")), -1n);
assert.throws(SyntaxError, () => BigInt.parseInt(new String("Infinity")));
assert.throws(SyntaxError, () => BigInt.parseInt(new String("NaN")));
assert.throws(SyntaxError, () => BigInt.parseInt(new String("true")));
assert.throws(SyntaxError, () => BigInt.parseInt(new String("false")));

View File

@ -0,0 +1,39 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Undefined or null argument
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
2. Let S be a newly created substring of inputString consisting of
the first code unit that is not a StrWhiteSpaceChar and all code
units following that code unit. (In other words, remove leading
white space.) If inputString does not contain any such code unit,
let S be the empty string.
[...]
11. If S contains a code unit that is not a radix-R digit, let Z be
the substring of S consisting of all code units before the first
such code unit; otherwise, let Z be S.
12. If Z is empty, return NaN.
features: [BigInt, arrow-function]
---*/
assert.throws(SyntaxError, () => BigInt.parseInt(undefined));
assert.throws(SyntaxError, () => BigInt.parseInt(null));

View File

@ -0,0 +1,62 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Negative binary argument with radix 2
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
The parseInt function is the %parseInt% intrinsic object. When the
parseInt function is called, the following steps are taken:
[...]
4. If S is not empty and the first code unit of S is the code unit
0x002D (HYPHEN-MINUS), let sign be -1.
[...]
16. Return sign × number.
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("-1", 2), -1n);
assert.sameValue(BigInt.parseInt("-11", 2), -3n);
assert.sameValue(BigInt.parseInt("-111", 2), -7n);
assert.sameValue(BigInt.parseInt("-1111", 2), -15n);
assert.sameValue(BigInt.parseInt("-11111", 2), -31n);
assert.sameValue(BigInt.parseInt("-111111", 2), -63n);
assert.sameValue(BigInt.parseInt("-1111111", 2), -127n);
assert.sameValue(BigInt.parseInt("-11111111", 2), -255n);
assert.sameValue(BigInt.parseInt("-111111111", 2), -511n);
assert.sameValue(BigInt.parseInt("-1111111111", 2), -1023n);
assert.sameValue(BigInt.parseInt("-11111111111", 2), -2047n);
assert.sameValue(BigInt.parseInt("-111111111111", 2), -4095n);
assert.sameValue(BigInt.parseInt("-1111111111111", 2), -8191n);
assert.sameValue(BigInt.parseInt("-11111111111111", 2), -16383n);
assert.sameValue(BigInt.parseInt("-111111111111111", 2), -32767n);
assert.sameValue(BigInt.parseInt("-1111111111111111", 2), -65535n);
assert.sameValue(BigInt.parseInt("-11111111111111111", 2), -131071n);
assert.sameValue(BigInt.parseInt("-111111111111111111", 2), -262143n);
assert.sameValue(BigInt.parseInt("-1111111111111111111", 2), -524287n);
assert.sameValue(BigInt.parseInt("-11111111111111111111", 2), -1048575n);

View File

@ -0,0 +1,53 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Binary string argument with radix 2
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("1", 2), 1n);
assert.sameValue(BigInt.parseInt("11", 2), 3n);
assert.sameValue(BigInt.parseInt("111", 2), 7n);
assert.sameValue(BigInt.parseInt("1111", 2), 15n);
assert.sameValue(BigInt.parseInt("11111", 2), 31n);
assert.sameValue(BigInt.parseInt("111111", 2), 63n);
assert.sameValue(BigInt.parseInt("1111111", 2), 127n);
assert.sameValue(BigInt.parseInt("11111111", 2), 255n);
assert.sameValue(BigInt.parseInt("111111111", 2), 511n);
assert.sameValue(BigInt.parseInt("1111111111", 2), 1023n);
assert.sameValue(BigInt.parseInt("11111111111", 2), 2047n);
assert.sameValue(BigInt.parseInt("111111111111", 2), 4095n);
assert.sameValue(BigInt.parseInt("1111111111111", 2), 8191n);
assert.sameValue(BigInt.parseInt("11111111111111", 2), 16383n);
assert.sameValue(BigInt.parseInt("111111111111111", 2), 32767n);
assert.sameValue(BigInt.parseInt("1111111111111111", 2), 65535n);
assert.sameValue(BigInt.parseInt("11111111111111111", 2), 131071n);
assert.sameValue(BigInt.parseInt("111111111111111111", 2), 262143n);
assert.sameValue(BigInt.parseInt("1111111111111111111", 2), 524287n);
assert.sameValue(BigInt.parseInt("11111111111111111111", 2), 1048575n);

View File

@ -0,0 +1,51 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Negative decimal string argument with radix 10
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
4. If S is not empty and the first code unit of S is the code unit
0x002D (HYPHEN-MINUS), let sign be -1.
[...]
16. Return sign × number.
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("-1", 10), -1n);
assert.sameValue(BigInt.parseInt("-10", 10), -10n);
assert.sameValue(BigInt.parseInt("-100", 10), -100n);
assert.sameValue(BigInt.parseInt("-1000", 10), -1000n);
assert.sameValue(BigInt.parseInt("-10000", 10), -10000n);
assert.sameValue(BigInt.parseInt("-100000", 10), -100000n);
assert.sameValue(BigInt.parseInt("-1000000", 10), -1000000n);
assert.sameValue(BigInt.parseInt("-10000000", 10), -10000000n);
assert.sameValue(BigInt.parseInt("-100000000", 10), -100000000n);
assert.sameValue(BigInt.parseInt("-1000000000", 10), -1000000000n);
assert.sameValue(BigInt.parseInt("-10000000000", 10), -10000000000n);
assert.sameValue(BigInt.parseInt("-100000000000", 10), -100000000000n);
assert.sameValue(BigInt.parseInt("-1000000000000", 10), -1000000000000n);
assert.sameValue(BigInt.parseInt("-10000000000000", 10), -10000000000000n);
assert.sameValue(BigInt.parseInt("-100000000000000", 10), -100000000000000n);
assert.sameValue(BigInt.parseInt("-1000000000000000", 10), -1000000000000000n);
assert.sameValue(BigInt.parseInt("-10000000000000000", 10), -10000000000000000n);
assert.sameValue(BigInt.parseInt("-100000000000000000", 10), -100000000000000000n);
assert.sameValue(BigInt.parseInt("-1000000000000000000", 10), -1000000000000000000n);
assert.sameValue(BigInt.parseInt("-10000000000000000000", 10), -10000000000000000000n);

View File

@ -0,0 +1,44 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: SyntaxError thrown for invalid strings
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
2. Let S be a newly created substring of inputString consisting of
the first code unit that is not a StrWhiteSpaceChar and all code
units following that code unit. (In other words, remove leading
white space.) If inputString does not contain any such code unit,
let S be the empty string.
[...]
11. If S contains a code unit that is not a radix-R digit, let Z be
the substring of S consisting of all code units before the first
such code unit; otherwise, let Z be S.
12. If Z is empty, return NaN.
features: [BigInt, arrow-function]
---*/
for (var i = 2; i <= 36; i++) {
assert.throws(SyntaxError, () => BigInt.parseInt("$0x", i), "$0x radix " + i);
assert.throws(SyntaxError, () => BigInt.parseInt("$0X", i), "$0X radix " + i);
assert.throws(SyntaxError, () => BigInt.parseInt("$$$", i), "$$$ radix " + i);
assert.throws(SyntaxError, () => BigInt.parseInt("", i), "the empty string, radix " + i);
assert.throws(SyntaxError, () => BigInt.parseInt(" ", i), "a string with a single space, radix " + i);
}

View File

@ -0,0 +1,42 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: SyntaxError thrown for invalid strings
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
2. Let S be a newly created substring of inputString consisting of
the first code unit that is not a StrWhiteSpaceChar and all code
units following that code unit. (In other words, remove leading
white space.) If inputString does not contain any such code unit,
let S be the empty string.
[...]
11. If S contains a code unit that is not a radix-R digit, let Z be
the substring of S consisting of all code units before the first
such code unit; otherwise, let Z be S.
12. If Z is empty, return NaN.
features: [BigInt, arrow-function]
---*/
assert.throws(SyntaxError, () => BigInt.parseInt("$0x"), "$0x");
assert.throws(SyntaxError, () => BigInt.parseInt("$0X"), "$0X");
assert.throws(SyntaxError, () => BigInt.parseInt("$$$"), "$$$");
assert.throws(SyntaxError, () => BigInt.parseInt(""), "the empty string");
assert.throws(SyntaxError, () => BigInt.parseInt(" "), "a string with a single space");

View File

@ -0,0 +1,68 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: String argument with hexadecimal prefix and zero radix
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("0x0", 0), 0x0n);
assert.sameValue(BigInt.parseInt("0x1", 0), 0x1n);
assert.sameValue(BigInt.parseInt("0x2", 0), 0x2n);
assert.sameValue(BigInt.parseInt("0x3", 0), 0x3n);
assert.sameValue(BigInt.parseInt("0x4", 0), 0x4n);
assert.sameValue(BigInt.parseInt("0x5", 0), 0x5n);
assert.sameValue(BigInt.parseInt("0x6", 0), 0x6n);
assert.sameValue(BigInt.parseInt("0x7", 0), 0x7n);
assert.sameValue(BigInt.parseInt("0x8", 0), 0x8n);
assert.sameValue(BigInt.parseInt("0x9", 0), 0x9n);
assert.sameValue(BigInt.parseInt("0xA", 0), 0xAn);
assert.sameValue(BigInt.parseInt("0xB", 0), 0xBn);
assert.sameValue(BigInt.parseInt("0xC", 0), 0xCn);
assert.sameValue(BigInt.parseInt("0xD", 0), 0xDn);
assert.sameValue(BigInt.parseInt("0xE", 0), 0xEn);
assert.sameValue(BigInt.parseInt("0xF", 0), 0xFn);
assert.sameValue(BigInt.parseInt("0xE", 0), 0xEn);
assert.sameValue(BigInt.parseInt("0xABCDEF", 0), 0xABCDEFn);

View File

@ -0,0 +1,68 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: String argument with hexadecimal prefix and zero radix
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("0X0", 0), 0x0n);
assert.sameValue(BigInt.parseInt("0X1"), 0x1n);
assert.sameValue(BigInt.parseInt("0X2"), 0x2n);
assert.sameValue(BigInt.parseInt("0X3"), 0x3n);
assert.sameValue(BigInt.parseInt("0X4"), 0x4n);
assert.sameValue(BigInt.parseInt("0X5"), 0x5n);
assert.sameValue(BigInt.parseInt("0X6"), 0x6n);
assert.sameValue(BigInt.parseInt("0X7"), 0x7n);
assert.sameValue(BigInt.parseInt("0X8"), 0x8n);
assert.sameValue(BigInt.parseInt("0X9"), 0x9n);
assert.sameValue(BigInt.parseInt("0XA"), 0xAn);
assert.sameValue(BigInt.parseInt("0XB"), 0xBn);
assert.sameValue(BigInt.parseInt("0XC"), 0xCn);
assert.sameValue(BigInt.parseInt("0XD"), 0xDn);
assert.sameValue(BigInt.parseInt("0XE"), 0xEn);
assert.sameValue(BigInt.parseInt("0XF"), 0xFn);
assert.sameValue(BigInt.parseInt("0XE"), 0xEn);
assert.sameValue(BigInt.parseInt("0XABCDEF"), 0xABCDEFn);

View File

@ -0,0 +1,53 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Hexadecimal string argument with radix 16
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("0x1", 16), 1n);
assert.sameValue(BigInt.parseInt("0X10", 16), 16n);
assert.sameValue(BigInt.parseInt("0x100", 16), 256n);
assert.sameValue(BigInt.parseInt("0X1000", 16), 4096n);
assert.sameValue(BigInt.parseInt("0x10000", 16), 65536n);
assert.sameValue(BigInt.parseInt("0X100000", 16), 1048576n);
assert.sameValue(BigInt.parseInt("0x1000000", 16), 16777216n);
assert.sameValue(BigInt.parseInt("0x10000000", 16), 268435456n);
assert.sameValue(BigInt.parseInt("0x100000000", 16), 4294967296n);
assert.sameValue(BigInt.parseInt("0x1000000000", 16), 68719476736n);
assert.sameValue(BigInt.parseInt("0x10000000000", 16), 1099511627776n);
assert.sameValue(BigInt.parseInt("0x100000000000", 16), 17592186044416n);
assert.sameValue(BigInt.parseInt("0x1000000000000", 16), 281474976710656n);
assert.sameValue(BigInt.parseInt("0x10000000000000", 16), 4503599627370496n);
assert.sameValue(BigInt.parseInt("0x100000000000000", 16), 72057594037927936n);
assert.sameValue(BigInt.parseInt("0x1000000000000000", 16), 1152921504606846976n);
assert.sameValue(BigInt.parseInt("0x10000000000000000", 16), 18446744073709551616n);
assert.sameValue(BigInt.parseInt("0x100000000000000000", 16), 295147905179352825856n);
assert.sameValue(BigInt.parseInt("0x1000000000000000000", 16), 4722366482869645213696n);
assert.sameValue(BigInt.parseInt("0x10000000000000000000", 16), 75557863725914323419136n);

View File

@ -0,0 +1,36 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Leading whitespace (U+000D)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt, arrow-function]
---*/
assert.sameValue(BigInt.parseInt("\u000D1"), 1n);
assert.sameValue(BigInt.parseInt("\u000D\u000D-1"), -1n);
assert.throws(SyntaxError, () => BigInt.parseInt("\u000D"));

View File

@ -0,0 +1,36 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Leading whitespace (U+000C)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt, arrow-function]
---*/
assert.sameValue(BigInt.parseInt("\u000C1"), 1n);
assert.sameValue(BigInt.parseInt("\u000C\u000C-1"), -1n);
assert.throws(SyntaxError, () => BigInt.parseInt("\u000C"));

View File

@ -0,0 +1,36 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Leading whitespace (U+000A)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt, arrow-function]
---*/
assert.sameValue(BigInt.parseInt("\u000A1"), 1n);
assert.sameValue(BigInt.parseInt("\u000A\u000A-1"), -1n);
assert.throws(SyntaxError, () => BigInt.parseInt("\u000A"));

View File

@ -0,0 +1,36 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Leading whitespace (U+2028)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt, arrow-function]
---*/
assert.sameValue(BigInt.parseInt("\u20281"), 1n);
assert.sameValue(BigInt.parseInt("\u2028\u2028-1"), -1n);
assert.throws(SyntaxError, () => BigInt.parseInt("\u2028"));

View File

@ -0,0 +1,36 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Leading whitespace (U+00A0)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt, arrow-function]
---*/
assert.sameValue(BigInt.parseInt("\u00A01"), 1n);
assert.sameValue(BigInt.parseInt("\u00A0\u00A0-1"), -1n);
assert.throws(SyntaxError, () => BigInt.parseInt("\u00A0"));

View File

@ -0,0 +1,36 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Leading whitespace (U+2029)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt, arrow-function]
---*/
assert.sameValue(BigInt.parseInt("\u20291"), 1n);
assert.sameValue(BigInt.parseInt("\u2029\u2029-1"), -1n);
assert.throws(SyntaxError, () => BigInt.parseInt("\u2029"));

View File

@ -0,0 +1,39 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Leading whitespace (U+0020)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt, arrow-function]
---*/
assert.sameValue(BigInt.parseInt("\u00201"), 1n);
assert.sameValue(BigInt.parseInt("\u0020\u0020-1"), -1n);
assert.sameValue(BigInt.parseInt(" 1"), 1n);
assert.sameValue(BigInt.parseInt(" 1"), 1n);
assert.sameValue(BigInt.parseInt(" \u0020 \u0020-1"), -1n)
assert.throws(SyntaxError, () => BigInt.parseInt("\u0020"));

View File

@ -0,0 +1,39 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Leading whitespace (U+0009)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt, arrow-function]
---*/
assert.sameValue(BigInt.parseInt("\u00091"), 1n);
assert.sameValue(BigInt.parseInt("\u0009\u0009-1"), -1n);
assert.sameValue(BigInt.parseInt(" 1"), 1n);
assert.sameValue(BigInt.parseInt(" 1"), 1n);
assert.sameValue(BigInt.parseInt(" \u0009 \u0009-1"), -1n);
assert.throws(SyntaxError, () => BigInt.parseInt("\u0009"));

View File

@ -0,0 +1,42 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Leading non-whitespace (U+180E)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
1. Let inputString be ? ToString(string).
2. Let S be a newly created substring of inputString consisting of
the first code unit that is not a StrWhiteSpaceChar and all code
units following that code unit. (In other words, remove leading
white space.) If inputString does not contain any such code unit,
let S be the empty string.
[...]
11. If S contains a code unit that is not a radix-R digit, let Z be
the substring of S consisting of all code units before the first
such code unit; otherwise, let Z be S.
12. If Z is empty, return NaN.
features: [BigInt, arrow-function]
---*/
var mongolianVowelSeparator = "\u180E";
assert.throws(SyntaxError, () => BigInt.parseInt(mongolianVowelSeparator + "1"), "Single leading U+180E");
assert.throws(SyntaxError, () => BigInt.parseInt(mongolianVowelSeparator + mongolianVowelSeparator + mongolianVowelSeparator + "1"), "Multiple leading U+180E");
assert.throws(SyntaxError, () => BigInt.parseInt(mongolianVowelSeparator), "Only U+180E");

View File

@ -0,0 +1,36 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Leading whitespace (U+000B)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt, arrow-function]
---*/
assert.sameValue(BigInt.parseInt("\u000B1"), 1n);
assert.sameValue(BigInt.parseInt("\u000B\u000B-1"), -1n);
assert.throws(SyntaxError, () => BigInt.parseInt("\u000B"));

View File

@ -0,0 +1,40 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Leading whitespace
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt, arrow-function]
---*/
var uspU = ["\u1680", "\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200A", "\u202F", "\u205F", "\u3000"];
for (var index = 0; index < uspU.length; index++) {
assert.sameValue(BigInt.parseInt(uspU[index] + "1"), 1n);
assert.sameValue(BigInt.parseInt(uspU[index] + uspU[index] + uspU[index] + "1"), 1n);
assert.throws(SyntaxError, () => BigInt.parseInt(uspU[index]));
}

View File

@ -0,0 +1,32 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: BigInt.parseInt.length property descriptor
info: >
BigInt.parseInt ( string , radix )
17 ECMAScript Standard Built-in Objects
Every built-in function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this
value is equal to the largest number of named arguments shown in the
subclause headings for the function description. Optional parameters
(which are indicated with brackets: [ ]) or rest parameters (which
are shown using the form «...name») are not included in the default
argument count.
Unless otherwise specified, the length property of a built-in
function object has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [BigInt]
---*/
verifyProperty(BigInt.parseInt, "length", {
value: 2,
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,67 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Mixed-case digits and sign
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to the
specified radix. Leading white space in string is ignored. If radix is
undefined or 0, it is assumed to be 10 except when the number begins
with the code unit pairs 0x or 0X, in which case a radix of 16 is
assumed. If radix is 16, the number may also optionally begin with the
code unit pairs 0x or 0X.
The parseInt function is the %parseInt% intrinsic object. When the
parseInt function is called, the following steps are taken:
[...]
4. If S is not empty and the first code unit of S is the code unit
0x002D (HYPHEN-MINUS), let sign be -1.
[...]
16. Return sign × number.
features: [BigInt]
---*/
var R_digit1 = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
var R_digit2 = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
for (var i = 2; i <= 36; i++) {
for (var j = 0; j < 10; j++) {
var str = "+";
var sign = 1;
if (j % 2 !== 0) {
str = "-";
sign= -1;
}
var num = 0;
var pow = 1;
var k0 = Math.max(2, i - j);
for (var k = k0; k <= i; k++) {
if (k % 2 === 0) {
str = str + R_digit1[k - 2];
} else {
str = str + R_digit2[k - 2];
}
num = num + (i + (k0 - k) - 1) * pow;
pow = pow * i;
}
assert.sameValue(BigInt.parseInt(str, i), BigInt(num * sign));
}
}

View File

@ -0,0 +1,53 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Mixed-case digits
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to the
specified radix. Leading white space in string is ignored. If radix is
undefined or 0, it is assumed to be 10 except when the number begins
with the code unit pairs 0x or 0X, in which case a radix of 16 is
assumed. If radix is 16, the number may also optionally begin with the
code unit pairs 0x or 0X.
features: [BigInt]
---*/
var R_digit1 = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
var R_digit2 = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
for (var i = 2; i <= 36; i++) {
for (var j = 0; j < 10; j++) {
var str = "";
var num = 0;
var pow = 1;
var k0 = Math.max(2, i - j);
for (var k = k0; k <= i; k++) {
if (k % 2 === 0) {
str = str + R_digit1[k - 2];
} else {
str = str + R_digit2[k - 2];
}
num = num + (i + (k0 - k) - 1) * pow;
pow = pow * i;
}
assert.sameValue(BigInt.parseInt(str, i), BigInt(num));
}
}

View File

@ -0,0 +1,31 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: BigInt.parseInt.name property descriptor
info: >
BigInt.parseInt ( string , radix )
17 ECMAScript Standard Built-in Objects
Every built-in function object, including constructors, that is not
identified as an anonymous function has a name property whose value
is a String. Unless otherwise specified, this value is the name that
is given to the function in this specification. For functions that
are specified as properties of objects, the name value is the
property name string used to access the function. [...]
Unless otherwise specified, the name property of a built-in function
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [BigInt]
---*/
verifyProperty(BigInt.parseInt, "name", {
value: "parseInt",
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: BigInt.parseInt.prototype is undefined
BigInt.parseInt ( string , radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
9.3 Built-in Function Objects
Built-in functions that are not constructors do not have a prototype
property unless otherwise specified in the description of a
particular function.
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt.prototype, undefined);

View File

@ -0,0 +1,22 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: BigInt.parseInt is not a constructor
info: >
BigInt.parseInt ( string , radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
9.3 Built-in Function Objects
Built-in function objects that are not identified as constructors do
not implement the [[Construct]] internal method unless otherwise
specified in the description of a particular function.
features: [BigInt, arrow-function]
---*/
assert.throws(TypeError, () => new BigInt.parseInt());

View File

@ -0,0 +1,34 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: String argument with octal prefix
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to
the specified radix. Leading white space in string is ignored. If
radix is undefined or 0, it is assumed to be 10 except when the
number begins with the code unit pairs 0x or 0X, in which case a
radix of 16 is assumed. If radix is 16, the number may also
optionally begin with the code unit pairs 0x or 0X.
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("010"), 10n, "parseInt should no longer accept octal");

View File

@ -1,4 +1,4 @@
// Copyright (C) 2017 Robin Templeton. All rights reserved.
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---

View File

@ -0,0 +1,19 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: BigInt.parseInt property descriptor
info: >
BigInt.parseInt ( string, radix )
17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js]
features: [BigInt]
---*/
verifyProperty(BigInt, "parseInt", {
writable: true,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,41 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Invalid radix (37)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
8. If R 0, then
a. If R < 2 or R > 36, return NaN.
features: [BigInt, arrow-function]
---*/
assert.throws(SyntaxError, () => BigInt.parseInt("0", 37), "0");
assert.throws(SyntaxError, () => BigInt.parseInt("1", 37), "1");
assert.throws(SyntaxError, () => BigInt.parseInt("2", 37), "2");
assert.throws(SyntaxError, () => BigInt.parseInt("3", 37), "3");
assert.throws(SyntaxError, () => BigInt.parseInt("4", 37), "4");
assert.throws(SyntaxError, () => BigInt.parseInt("5", 37), "5");
assert.throws(SyntaxError, () => BigInt.parseInt("6", 37), "6");
assert.throws(SyntaxError, () => BigInt.parseInt("7", 37), "7");
assert.throws(SyntaxError, () => BigInt.parseInt("8", 37), "8");
assert.throws(SyntaxError, () => BigInt.parseInt("9", 37), "9");
assert.throws(SyntaxError, () => BigInt.parseInt("10", 37), "10");
assert.throws(SyntaxError, () => BigInt.parseInt("11", 37), "11");

View File

@ -0,0 +1,39 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Boolean radix
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
6. Let R be ? ToInt32(radix).
7. Let stripPrefix be true.
8. If R 0, then
a. If R < 2 or R > 36, return NaN.
b. If R 16, let stripPrefix be false.
9. Else R = 0,
a. Let R be 10.
[...]
features: [BigInt, arrow-function]
---*/
assert.sameValue(BigInt.parseInt("11", false), 11n);
assert.throws(SyntaxError, () => BigInt.parseInt("11", true));
assert.sameValue(BigInt.parseInt("11", new Boolean(false)), 11n);
assert.throws(SyntaxError, () => BigInt.parseInt("11", new Boolean(true)));

View File

@ -0,0 +1,42 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Radix converted using ToInt32
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
6. Let R be ? ToInt32(radix).
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("11", 2.1), 0b11n);
assert.sameValue(BigInt.parseInt("11", 2.5), 0b11n);
assert.sameValue(BigInt.parseInt("11", 2.9), 0b11n);
assert.sameValue(BigInt.parseInt("11", 2.000000000001), 0b11n);
assert.sameValue(BigInt.parseInt("11", 2.999999999999), 0b11n);
assert.sameValue(BigInt.parseInt("11", 4294967298), 0b11n);
assert.sameValue(BigInt.parseInt("11", 4294967296), 11n);
assert.throws(SyntaxError, () => BigInt.parseInt("11", -2147483650), "-2147483650");
assert.sameValue(BigInt.parseInt("11", -4294967294), 0b11n);
assert.sameValue(BigInt.parseInt("11", NaN), 11n);
assert.sameValue(BigInt.parseInt("11", +0), 11n);
assert.sameValue(BigInt.parseInt("11", -0), 11n);
assert.sameValue(BigInt.parseInt("11", Number.POSITIVE_INFINITY), 11n);
assert.sameValue(BigInt.parseInt("11", Number.NEGATIVE_INFINITY), 11n);

View File

@ -0,0 +1,30 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Number object radix
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
6. Let R be ? ToInt32(radix).
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("11", new Number(2)), 0b11n);
assert.sameValue(BigInt.parseInt("11", new Number(Infinity)), 11n);

View File

@ -0,0 +1,41 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Invalid radix (1)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
8. If R 0, then
a. If R < 2 or R > 36, return NaN.
features: [BigInt, arrow-function]
---*/
assert.throws(SyntaxError, () => BigInt.parseInt("0", 1), "0");
assert.throws(SyntaxError, () => BigInt.parseInt("1", 1), "1");
assert.throws(SyntaxError, () => BigInt.parseInt("2", 1), "2");
assert.throws(SyntaxError, () => BigInt.parseInt("3", 1), "3");
assert.throws(SyntaxError, () => BigInt.parseInt("4", 1), "4");
assert.throws(SyntaxError, () => BigInt.parseInt("5", 1), "5");
assert.throws(SyntaxError, () => BigInt.parseInt("6", 1), "6");
assert.throws(SyntaxError, () => BigInt.parseInt("7", 1), "7");
assert.throws(SyntaxError, () => BigInt.parseInt("8", 1), "8");
assert.throws(SyntaxError, () => BigInt.parseInt("9", 1), "9");
assert.throws(SyntaxError, () => BigInt.parseInt("10", 1), "10");
assert.throws(SyntaxError, () => BigInt.parseInt("11", 1), "11");

View File

@ -0,0 +1,51 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Radix converted using ToInt32
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
6. Let R be ? ToInt32(radix).
features: [BigInt, arrow-function]
---*/
var object = {valueOf() {return 2}};
assert.sameValue(BigInt.parseInt("11", object), 0b11n);
var object = {valueOf() {return 2}, toString() {return 1}};
assert.sameValue(BigInt.parseInt("11", object), 0b11n);
var object = {valueOf() {return 2}, toString() {return {}}};
assert.sameValue(BigInt.parseInt("11", object), 0b11n);
var object = {valueOf() {return 2}, toString() {throw new Test262Error()}};
assert.sameValue(BigInt.parseInt("11", object), 0b11n);
var object = {toString() {return 2}};
assert.sameValue(BigInt.parseInt("11", object), 0b11n);
var object = {valueOf() {return {}}, toString() {return 2}}
assert.sameValue(BigInt.parseInt("11", object), 0b11n);
var object = {valueOf() {throw new Test262Error()}, toString() {return 2}};
assert.throws(Test262Error, () => BigInt.parseInt("11", object));
var object = {valueOf() {return {}}, toString() {return {}}};
assert.throws(TypeError, () => BigInt.parseInt("11", object));

View File

@ -0,0 +1,34 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: String radix
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
6. Let R be ? ToInt32(radix).
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("11", "2"), 0b11n);
assert.sameValue(BigInt.parseInt("11", "0"), 11n);
assert.sameValue(BigInt.parseInt("11", ""), 11n);
assert.sameValue(BigInt.parseInt("11", new String("2")), 0b11n);
assert.sameValue(BigInt.parseInt("11", new String("Infinity")), 11n);
assert.sameValue(BigInt.parseInt("11", new String("")), 11n);

View File

@ -0,0 +1,33 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Radix is undefined or null
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
6. Let R be ? ToInt32(radix).
[...]
9. Else R = 0,
a. Let R be 10.
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("11", undefined), 11n);
assert.sameValue(BigInt.parseInt("11", null), 11n);

View File

@ -0,0 +1,56 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Radix is undefined
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
6. Let R be ? ToInt32(radix).
[...]
9. Else R = 0,
a. Let R be 10.
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("0"), 0n);
assert.sameValue(BigInt.parseInt("1"), 1n);
assert.sameValue(BigInt.parseInt("2"), 2n);
assert.sameValue(BigInt.parseInt("3"), 3n);
assert.sameValue(BigInt.parseInt("4"), 4n);
assert.sameValue(BigInt.parseInt("5"), 5n);
assert.sameValue(BigInt.parseInt("6"), 6n);
assert.sameValue(BigInt.parseInt("7"), 7n);
assert.sameValue(BigInt.parseInt("8"), 8n);
assert.sameValue(BigInt.parseInt("9"), 9n);
assert.sameValue(BigInt.parseInt("10"), 10n);
assert.sameValue(BigInt.parseInt("11"), 11n);
assert.sameValue(BigInt.parseInt("9999"), 9999n);

View File

@ -0,0 +1,56 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Radix is zero
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
[...]
6. Let R be ? ToInt32(radix).
[...]
9. Else R = 0,
a. Let R be 10.
features: [BigInt]
---*/
assert.sameValue(BigInt.parseInt("0", 0), 0n);
assert.sameValue(BigInt.parseInt("1", 0), 1n);
assert.sameValue(BigInt.parseInt("2", 0), 2n);
assert.sameValue(BigInt.parseInt("3", 0), 3n);
assert.sameValue(BigInt.parseInt("4", 0), 4n);
assert.sameValue(BigInt.parseInt("5", 0), 5n);
assert.sameValue(BigInt.parseInt("6", 0), 6n);
assert.sameValue(BigInt.parseInt("7", 0), 7n);
assert.sameValue(BigInt.parseInt("8", 0), 8n);
assert.sameValue(BigInt.parseInt("9", 0), 9n);
assert.sameValue(BigInt.parseInt("10", 0), 10n);
assert.sameValue(BigInt.parseInt("11", 0), 11n);
assert.sameValue(BigInt.parseInt("9999", 0), 9999n);

View File

@ -0,0 +1,85 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Trailing non-digit UTF-16 code point
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to the
specified radix. Leading white space in string is ignored. If radix is
undefined or 0, it is assumed to be 10 except when the number begins
with the code unit pairs 0x or 0X, in which case a radix of 16 is
assumed. If radix is 16, the number may also optionally begin with the
code unit pairs 0x or 0X.
[...]
NOTE: parseInt may interpret only a leading portion of string as an
integer value; it ignores any code units that cannot be interpreted as
part of the notation of an integer, and no indication is given that
any such code units were ignored.
includes: [decimalToHexString.js]
features: [BigInt]
---*/
var errorCount = 0;
var count = 0;
var indexP;
var indexO = 0;
for (var index = 0; index <= 65535; index++) {
if ((index < 0x0030) || (index > 0x0039) &&
(index < 0x0041) || (index > 0x005A) &&
(index < 0x0061) || (index > 0x007A)) {
var hex = decimalToHexString(index);
if (BigInt.parseInt("1Z" + String.fromCharCode(index), 36) !== 71n) {
if (indexO === 0) {
indexO = index;
} else {
if ((index - indexP) !== 1) {
if ((indexP - indexO) !== 0) {
var hexP = decimalToHexString(indexP);
var hexO = decimalToHexString(indexO);
$ERROR('#' + hexO + '-' + hexP + ' ');
}
else {
var hexP = decimalToHexString(indexP);
$ERROR('#' + hexP + ' ');
}
indexO = index;
}
}
indexP = index;
errorCount++;
}
count++;
}
}
if (errorCount > 0) {
if ((indexP - indexO) !== 0) {
var hexP = decimalToHexString(indexP);
var hexO = decimalToHexString(indexO);
$ERROR('#' + hexO + '-' + hexP + ' ');
} else {
var hexP = decimalToHexString(indexP);
$ERROR('#' + hexP + ' ');
}
$ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');
}

View File

@ -0,0 +1,44 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Single digit and invalid trailing digit (lowercase)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to the
specified radix. Leading white space in string is ignored. If radix is
undefined or 0, it is assumed to be 10 except when the number begins
with the code unit pairs 0x or 0X, in which case a radix of 16 is
assumed. If radix is 16, the number may also optionally begin with the
code unit pairs 0x or 0X.
[...]
NOTE: parseInt may interpret only a leading portion of string as an
integer value; it ignores any code units that cannot be interpreted as
part of the notation of an integer, and no indication is given that
any such code units were ignored.
features: [BigInt]
---*/
var R_digit = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
for (var i = 2; i <= 35; i++) {
assert.sameValue(BigInt.parseInt(R_digit[i - 2] + R_digit[i - 1], i), BigInt(i - 1));
}

View File

@ -0,0 +1,44 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Single digit with trailing invalid digit (uppercase)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to the
specified radix. Leading white space in string is ignored. If radix is
undefined or 0, it is assumed to be 10 except when the number begins
with the code unit pairs 0x or 0X, in which case a radix of 16 is
assumed. If radix is 16, the number may also optionally begin with the
code unit pairs 0x or 0X.
[...]
NOTE: parseInt may interpret only a leading portion of string as an
integer value; it ignores any code units that cannot be interpreted as
part of the notation of an integer, and no indication is given that
any such code units were ignored.
features: [BigInt]
---*/
var R_digit = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
for (var i = 2; i <= 35; i++) {
assert.sameValue(BigInt.parseInt(R_digit[i - 2] + R_digit[i - 1], i), BigInt(i - 1));
}

View File

@ -0,0 +1,43 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: 10 with trailing non-digit
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to the
specified radix. Leading white space in string is ignored. If radix is
undefined or 0, it is assumed to be 10 except when the number begins
with the code unit pairs 0x or 0X, in which case a radix of 16 is
assumed. If radix is 16, the number may also optionally begin with the
code unit pairs 0x or 0X.
[...]
NOTE: parseInt may interpret only a leading portion of string as an
integer value; it ignores any code units that cannot be interpreted as
part of the notation of an integer, and no indication is given that
any such code units were ignored.
features: [BigInt]
---*/
for (var i = 2; i <= 36; i++) {
assert.sameValue(BigInt.parseInt("10$1", i), BigInt(i));
}

View File

@ -0,0 +1,44 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Single digit with trailing non-digit (lowercase)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to the
specified radix. Leading white space in string is ignored. If radix is
undefined or 0, it is assumed to be 10 except when the number begins
with the code unit pairs 0x or 0X, in which case a radix of 16 is
assumed. If radix is 16, the number may also optionally begin with the
code unit pairs 0x or 0X.
[...]
NOTE: parseInt may interpret only a leading portion of string as an
integer value; it ignores any code units that cannot be interpreted as
part of the notation of an integer, and no indication is given that
any such code units were ignored.
features: [BigInt]
---*/
var R_digit = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
for (var i = 2; i <= 36; i++) {
assert.sameValue(BigInt.parseInt(R_digit[i - 2] + "$", i), BigInt(i - 1));
}

View File

@ -0,0 +1,44 @@
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-bigint-parseint-string-radix
description: Single digit with trailing non-digit (uppercase)
info: >
BigInt.parseInt ( string, radix )
The parseInt function produces a BigInt value dictated by
interpretation of the contents of the string argument according to
the specified radix.
The algorithm is the same as 18.2.5 but with the following edits:
* For all cases which result in returning NaN, throw a SyntaxError
exception.
* For all cases which result in returning -0, return 0n.
* Replace the second to last step, which casts mathInt to a Number,
with casting mathInt to a BigInt.
18.2.5 parseInt ( string, radix )
The parseInt function produces an integer value dictated by
interpretation of the contents of the string argument according to the
specified radix. Leading white space in string is ignored. If radix is
undefined or 0, it is assumed to be 10 except when the number begins
with the code unit pairs 0x or 0X, in which case a radix of 16 is
assumed. If radix is 16, the number may also optionally begin with the
code unit pairs 0x or 0X.
[...]
NOTE: parseInt may interpret only a leading portion of string as an
integer value; it ignores any code units that cannot be interpreted as
part of the notation of an integer, and no indication is given that
any such code units were ignored.
features: [BigInt]
---*/
var R_digit = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
for (var i = 2; i <= 36; i++) {
assert.sameValue(BigInt.parseInt(R_digit[i - 2] + "$", i), BigInt(i - 1));
}