Skip to content
Snippets Groups Projects
Commit 422f91e8 authored by Daniel Ehrenberg's avatar Daniel Ehrenberg Committed by Rick Waldron
Browse files

Remove BigInt.parseInt tests

BigInt.parseInt will be removed in
https://github.com/tc39/proposal-bigint/pull/101

This patch removes the associated test262 tests.
parent 7446e885
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 903 deletions
// 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);
// 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)));
// 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);
// 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));
// 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")));
// 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));
// 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);
// 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);
// 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);
// 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);
}
// 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");
// 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);
// 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);
// 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);
// 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"));
// 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"));
// 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"));
// 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"));
// 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"));
// 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"));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment