test262/test/language/expressions/equals/bigint-and-boolean.js

31 lines
1.9 KiB
JavaScript

// Copyright (C) 2017 Josh Wolfe. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Non-strict equality comparison of BigInt and Boolean values
esid: sec-abstract-equality-comparison
info: |
8. If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y.
9. If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).
...
12. If Type(x) is BigInt and Type(y) is Number, or if Type(x) is Number and Type(y) is BigInt,
...
b. If the mathematical value of x is equal to the mathematical value of y, return true, otherwise return false.
features: [BigInt]
---*/
assert.sameValue(-1n == false, false, 'The result of (-1n == false) is false');
assert.sameValue(false == -1n, false, 'The result of (false == -1n) is false');
assert.sameValue(-1n == true, false, 'The result of (-1n == true) is false');
assert.sameValue(true == -1n, false, 'The result of (true == -1n) is false');
assert.sameValue(0n == false, true, 'The result of (0n == false) is true');
assert.sameValue(false == 0n, true, 'The result of (false == 0n) is true');
assert.sameValue(0n == true, false, 'The result of (0n == true) is false');
assert.sameValue(true == 0n, false, 'The result of (true == 0n) is false');
assert.sameValue(1n == false, false, 'The result of (1n == false) is false');
assert.sameValue(false == 1n, false, 'The result of (false == 1n) is false');
assert.sameValue(1n == true, true, 'The result of (1n == true) is true');
assert.sameValue(true == 1n, true, 'The result of (true == 1n) is true');
assert.sameValue(2n == false, false, 'The result of (2n == false) is false');
assert.sameValue(false == 2n, false, 'The result of (false == 2n) is false');
assert.sameValue(2n == true, false, 'The result of (2n == true) is false');
assert.sameValue(true == 2n, false, 'The result of (true == 2n) is false');