blob: 2024068ee83d958ad1c2f4a73b481c2005b36a89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
test("basic functionality", () => {
const o = {
[Symbol.toPrimitive]: hint => {
lastHint = hint;
},
};
let lastHint;
// Calls ToPrimitive abstract operation with 'string' hint
String(o);
expect(lastHint).toBe("string");
// Calls ToPrimitive abstract operation with 'number' hint
+o;
expect(lastHint).toBe("number");
// Calls ToPrimitive abstract operation with 'default' hint
"" + o;
expect(lastHint).toBe("default");
});
|