summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Symbol/toPrimitive-undefined-or-null.js
blob: f43642e0f89c51af7666621e5d0d949a7d8f0021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
for (let method of [undefined, null]) {
    let obj = {
        [Symbol.toPrimitive]: method,
        toString: () => "pass",
    };
    assertEq("" + obj, "pass");
}

for (let method of [true, false, 0, 123, "", "abc", Symbol(), {}]) {
    let obj = {
        [Symbol.toPrimitive]: method,
        toString: () => "pass",
    };
    assertThrowsInstanceOf(() => "" + obj, TypeError);
}

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