bigint-and-number.js (2236B)
1 // Copyright (C) 2017 Josh Wolfe. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 description: Non-strict equality comparison of BigInt and Number values 5 esid: sec-abstract-equality-comparison 6 info: | 7 12. If Type(x) is BigInt and Type(y) is Number, or if Type(x) is Number and Type(y) is BigInt, 8 b. If the mathematical value of x is equal to the mathematical value of y, return true, otherwise return false. 9 10 features: [BigInt] 11 ---*/ 12 assert.sameValue(0n == 0, true, 'The result of (0n == 0) is true'); 13 assert.sameValue(0 == 0n, true, 'The result of (0 == 0n) is true'); 14 assert.sameValue(0n == -0, true, 'The result of (0n == -0) is true'); 15 assert.sameValue(-0 == 0n, true, 'The result of (-0 == 0n) is true'); 16 assert.sameValue(0n == 0.000000000001, false, 'The result of (0n == 0.000000000001) is false'); 17 assert.sameValue(0.000000000001 == 0n, false, 'The result of (0.000000000001 == 0n) is false'); 18 assert.sameValue(0n == 1, false, 'The result of (0n == 1) is false'); 19 assert.sameValue(1 == 0n, false, 'The result of (1 == 0n) is false'); 20 assert.sameValue(1n == 0, false, 'The result of (1n == 0) is false'); 21 assert.sameValue(0 == 1n, false, 'The result of (0 == 1n) is false'); 22 assert.sameValue(1n == 0.999999999999, false, 'The result of (1n == 0.999999999999) is false'); 23 assert.sameValue(0.999999999999 == 1n, false, 'The result of (0.999999999999 == 1n) is false'); 24 assert.sameValue(1n == 1, true, 'The result of (1n == 1) is true'); 25 assert.sameValue(1 == 1n, true, 'The result of (1 == 1n) is true'); 26 assert.sameValue(0n == Number.MIN_VALUE, false, 'The result of (0n == Number.MIN_VALUE) is false'); 27 assert.sameValue(Number.MIN_VALUE == 0n, false, 'The result of (Number.MIN_VALUE == 0n) is false'); 28 29 assert.sameValue( 30 0n == -Number.MIN_VALUE, 31 false, 32 'The result of (0n == -Number.MIN_VALUE) is false' 33 ); 34 35 assert.sameValue( 36 -Number.MIN_VALUE == 0n, 37 false, 38 'The result of (-Number.MIN_VALUE == 0n) is false' 39 ); 40 41 assert.sameValue( 42 -10n == Number.MIN_VALUE, 43 false, 44 'The result of (-10n == Number.MIN_VALUE) is false' 45 ); 46 47 assert.sameValue( 48 Number.MIN_VALUE == -10n, 49 false, 50 'The result of (Number.MIN_VALUE == -10n) is false' 51 ); 52 53 reportCompare(0, 0);