summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Symbol/comparisons.js
blob: d2105c8a1aa62d19a757494cd2ccb492289df9b9 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/ */

var symbols = [
    Symbol(),
    Symbol("0"),
    Symbol.for("snowman"),
    Symbol.iterator
];

var values = [
    undefined, null, 0, 3.14, -0, NaN, "", "alphabet", Symbol("0"),
    {}, []
];

for (var comparator of ["==", "!=", "===", "!=="]) {
    var f = Function("a, b", "return a " + comparator + " b;");
    var expected = (comparator[0] == '!');
    for (var a of symbols) {
        for (var b of values)
            assertEq(f(a, b), expected);
    }
}

for (var comparator of ["<", "<=", ">", ">="]) {
    var f = Function("a, b", "return a " + comparator + " b;");
    for (var a of symbols) {
        for (var b of values)
            assertThrowsInstanceOf(() => f(a, b), TypeError);
    }
}

if (typeof reportCompare === "function")
    reportCompare(0, 0);