summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/cacheir/symbol-loose-equal-incompatible.js
blob: b1232c2e2c7d50f0e9fd49c358090b03fcfd2d05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Test loose equality comparison between Symbols and String/Boolean/Int32/Double/BigInt.

var xs = [
  Symbol(), Symbol(), Symbol(), Symbol(),
  Symbol(), Symbol(), Symbol(), Symbol(),
];

var ys = [
  "", "test", true, false,
  123, 123.5, NaN, 456n,
];

function testLooseEqual() {
  for (var i = 0; i < 100; ++i) {
    var j = i % xs.length;
    var x = xs[j];
    var y = ys[j];

    assertEq(x == y, false);
    assertEq(y == x, false);
  }
}
testLooseEqual();

function testLooseNotEqual() {
  for (var i = 0; i < 100; ++i) {
    var j = i % xs.length;
    var x = xs[j];
    var y = ys[j];

    assertEq(x != y, true);
    assertEq(y != x, true);
  }
}
testLooseNotEqual();