| 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 |
/*--- |
| 5 |
description: Strict equality comparison of BigInt values |
| 6 |
esid: sec-strict-equality-comparison |
| 7 |
info: | |
| 8 |
1. If Type(x) is different from Type(y), return false. |
| 9 |
2. If Type(x) is Number or BigInt, then |
| 10 |
a. Return ! Type(x)::equal(x, y). |
| 11 |
|
| 12 |
sec-numeric-types-bigint-equal |
| 13 |
BigInt::equal (x, y) |
| 14 |
|
| 15 |
The abstract operation BigInt::equal with two arguments x and y of BigInt type returns true if x and y have the same mathematical integer value and false otherwise. |
| 16 |
|
| 17 |
features: [BigInt] |
| 18 |
---*/ |
| 19 |
|
| 20 |
assert.sameValue(0n === 0n, true, "0n === 0n"); |
| 21 |
assert.sameValue(1n === 1n, true, "1n === 1n"); |
| 22 |
assert.sameValue(-1n === -1n, true, "-1n === -1n"); |
| 23 |
assert.sameValue(0n === -0n, true, "0n === -0n"); |
| 24 |
assert.sameValue(-0n === 0n, true, "-0n === 0n"); |
| 25 |
assert.sameValue(0n === 1n, false, "0n === 1n"); |
| 26 |
assert.sameValue(1n === 0n, false, "1n === 0n"); |
| 27 |
assert.sameValue(0n === -1n, false, "0n === -1n"); |
| 28 |
assert.sameValue(-1n === 0n, false, "-1n === 0n"); |
| 29 |
assert.sameValue(1n === -1n, false, "1n === -1n"); |
| 30 |
assert.sameValue(-1n === 1n, false, "-1n === 1n"); |
| 31 |
assert.sameValue(0x1fffffffffffff01n === 0x1fffffffffffff01n, true, "0x1fffffffffffff01n === 0x1fffffffffffff01n"); |
| 32 |
assert.sameValue(0x1fffffffffffff01n === 0x1fffffffffffff02n, false, "0x1fffffffffffff01n === 0x1fffffffffffff02n"); |
| 33 |
assert.sameValue(0x1fffffffffffff02n === 0x1fffffffffffff01n, false, "0x1fffffffffffff02n === 0x1fffffffffffff01n"); |
| 34 |
assert.sameValue(-0x1fffffffffffff01n === -0x1fffffffffffff01n, true, "-0x1fffffffffffff01n === -0x1fffffffffffff01n"); |
| 35 |
assert.sameValue(-0x1fffffffffffff01n === -0x1fffffffffffff02n, false, "-0x1fffffffffffff01n === -0x1fffffffffffff02n"); |
| 36 |
assert.sameValue(-0x1fffffffffffff02n === -0x1fffffffffffff01n, false, "-0x1fffffffffffff02n === -0x1fffffffffffff01n"); |
| 37 |
assert.sameValue(0x10000000000000000n === 0n, false, "0x10000000000000000n === 0n"); |
| 38 |
assert.sameValue(0n === 0x10000000000000000n, false, "0n === 0x10000000000000000n"); |
| 39 |
assert.sameValue(0x10000000000000000n === 1n, false, "0x10000000000000000n === 1n"); |
| 40 |
assert.sameValue(1n === 0x10000000000000000n, false, "1n === 0x10000000000000000n"); |
| 41 |
assert.sameValue(0x10000000000000000n === -1n, false, "0x10000000000000000n === -1n"); |
| 42 |
assert.sameValue(-1n === 0x10000000000000000n, false, "-1n === 0x10000000000000000n"); |
| 43 |
assert.sameValue(0x10000000000000001n === 0n, false, "0x10000000000000001n === 0n"); |
| 44 |
assert.sameValue(0n === 0x10000000000000001n, false, "0n === 0x10000000000000001n"); |
| 45 |
assert.sameValue(-0x10000000000000000n === 0n, false, "-0x10000000000000000n === 0n"); |
| 46 |
assert.sameValue(0n === -0x10000000000000000n, false, "0n === -0x10000000000000000n"); |
| 47 |
assert.sameValue(-0x10000000000000000n === 1n, false, "-0x10000000000000000n === 1n"); |
| 48 |
assert.sameValue(1n === -0x10000000000000000n, false, "1n === -0x10000000000000000n"); |
| 49 |
assert.sameValue(-0x10000000000000000n === -1n, false, "-0x10000000000000000n === -1n"); |
| 50 |
assert.sameValue(-1n === -0x10000000000000000n, false, "-1n === -0x10000000000000000n"); |
| 51 |
assert.sameValue(-0x10000000000000001n === 0n, false, "-0x10000000000000001n === 0n"); |
| 52 |
assert.sameValue(0n === -0x10000000000000001n, false, "0n === -0x10000000000000001n"); |
| 53 |
assert.sameValue(0x10000000000000000n === 0x100000000n, false, "0x10000000000000000n === 0x100000000n"); |
| 54 |
assert.sameValue(0x100000000n === 0x10000000000000000n, false, "0x100000000n === 0x10000000000000000n"); |