1 // Copyright (C) 2017 Caio Lima. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
5 description: String should be parsed to BigInt according StringToBigInt
6 esid: sec-string-to-bigint
12 Let n be StringToBigInt(prim).
13 If n is NaN, throw a SyntaxError exception.
16 StringToBigInt ( argument )
18 Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity, decimal points, or exponents.
23 assert.sameValue(BigInt("0b1111"), 15n);
24 assert.sameValue(BigInt("0b10"), 2n);
25 assert.sameValue(BigInt("0b0"), 0n);
26 assert.sameValue(BigInt("0b1"), 1n);
28 let binaryString = "0b1";
29 for (let i = 0; i < 128; i++)
32 assert.sameValue(BigInt(binaryString), 340282366920938463463374607431768211456n);
34 assert.sameValue(BigInt("0B1111"), 15n);
35 assert.sameValue(BigInt("0B10"), 2n);
36 assert.sameValue(BigInt("0B0"), 0n);
37 assert.sameValue(BigInt("0B1"), 1n);
40 for (let i = 0; i < 128; i++)
43 assert.sameValue(BigInt(binaryString), 340282366920938463463374607431768211456n);