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);
|