constructor-integer.js (1619B)
1 // Copyright (C) 2018 Igalia, S.L. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 description: BigInt constructor called with integer argument 6 esid: sec-bigint-constructor-number-value 7 info: | 8 BigInt ( value ) 9 10 ... 11 3. If Type(prim) is Number, return ? NumberToBigInt(prim). 12 13 NumberToBigInt ( number ) 14 15 ... 16 3. Return a BigInt representing the mathematical value of number. 17 features: [BigInt] 18 ---*/ 19 20 assert.sameValue( 21 BigInt(Number.MAX_SAFE_INTEGER), 9007199254740991n, 22 "BigInt(Number.MAX_SAFE_INTEGER) === 9007199254740991n" 23 ); 24 25 assert.sameValue( 26 BigInt(-Number.MAX_SAFE_INTEGER), -9007199254740991n, 27 "BigInt(-Number.MAX_SAFE_INTEGER) === -9007199254740991n" 28 ); 29 30 assert.sameValue( 31 BigInt(Number.MAX_SAFE_INTEGER + 1), 9007199254740992n, 32 "BigInt(Number.MAX_SAFE_INTEGER + 1) === 9007199254740992n" 33 ); 34 35 assert.sameValue( 36 BigInt(-Number.MAX_SAFE_INTEGER - 1), -9007199254740992n, 37 "BigInt(-Number.MAX_SAFE_INTEGER - 1) === -9007199254740992n" 38 ); 39 40 assert.sameValue( 41 BigInt(Number.MAX_SAFE_INTEGER + 2), 9007199254740992n, 42 "BigInt(Number.MAX_SAFE_INTEGER + 2) === 9007199254740992n" 43 ); 44 45 assert.sameValue( 46 BigInt(-Number.MAX_SAFE_INTEGER - 2), -9007199254740992n, 47 "BigInt(-Number.MAX_SAFE_INTEGER - 2) === -9007199254740992n" 48 ); 49 50 assert.sameValue( 51 BigInt(Number.MAX_SAFE_INTEGER + 3), 9007199254740994n, 52 "BigInt(Number.MAX_SAFE_INTEGER + 3) === 9007199254740994n" 53 ); 54 55 assert.sameValue( 56 BigInt(-Number.MAX_SAFE_INTEGER - 3), -9007199254740994n, 57 "BigInt(-Number.MAX_SAFE_INTEGER - 3) === -9007199254740994n" 58 ); 59 60 reportCompare(0, 0);