constructor-from-decimal-string.js (1023B)
1 // Copyright (C) 2017 Caio Lima. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 description: String should be parsed to BigInt according StringToBigInt 6 esid: sec-string-to-bigint 7 info: | 8 ToBigInt ( argument ) 9 10 String: 11 12 Let n be StringToBigInt(prim). 13 If n is NaN, throw a SyntaxError exception. 14 Return n. 15 16 StringToBigInt ( argument ) 17 18 Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity, decimal points, or exponents. 19 20 features: [BigInt] 21 ---*/ 22 23 assert.sameValue(BigInt("10"), 10n); 24 assert.sameValue(BigInt("18446744073709551616"), 18446744073709551616n); 25 assert.sameValue(BigInt("7"), 7n); 26 assert.sameValue(BigInt("88"), 88n); 27 assert.sameValue(BigInt("900"), 900n); 28 29 assert.sameValue(BigInt("-10"), -10n); 30 assert.sameValue(BigInt("-18446744073709551616"), -18446744073709551616n); 31 assert.sameValue(BigInt("-7"), -7n); 32 assert.sameValue(BigInt("-88"), -88n); 33 assert.sameValue(BigInt("-900"), -900n); 34 35 reportCompare(0, 0);