mirror of
https://github.com/hanzoai/babel.git
synced 2026-10-30 14:46:06 +00:00
Co-authored-by: Nicolò Ribaudo <[email protected]> Fixes https://github.com/babel/babel/issues/15169
24 lines
494 B
JavaScript
24 lines
494 B
JavaScript
// [Symbol.toPrimitive] must be called if exist
|
|
var counter = 0;
|
|
expect(() => {
|
|
(new class {
|
|
f() {
|
|
delete super[{
|
|
[Symbol.toPrimitive]: function() { ++counter; return 0; },
|
|
}];
|
|
}
|
|
}).f();
|
|
}).toThrow(ReferenceError);
|
|
expect(counter).toBe(1);
|
|
|
|
// [Symbol.toPrimitive] must return a primitive value
|
|
expect(() => {
|
|
(new class {
|
|
f() {
|
|
delete super[{
|
|
[Symbol.toPrimitive]: function() { return {}; },
|
|
}];
|
|
}
|
|
}).f();
|
|
}).toThrow(TypeError);
|