packages/babel-plugin-transform-classes/test/fixtures/spec/delete-super-property-to-property-key/exec.js
raw| 1 | // [Symbol.toPrimitive] must be called if exist |
| 2 | var counter = 0; |
| 3 | expect(() => { |
| 4 | (new class { |
| 5 | f() { |
| 6 | delete super[{ |
| 7 | [Symbol.toPrimitive]: function() { ++counter; return 0; }, |
| 8 | }]; |
| 9 | } |
| 10 | }).f(); |
| 11 | }).toThrow(ReferenceError); |
| 12 | expect(counter).toBe(1); |
| 13 | |
| 14 | // [Symbol.toPrimitive] must return a primitive value |
| 15 | expect(() => { |
| 16 | (new class { |
| 17 | f() { |
| 18 | delete super[{ |
| 19 | [Symbol.toPrimitive]: function() { return {}; }, |
| 20 | }]; |
| 21 | } |
| 22 | }).f(); |
| 23 | }).toThrow(TypeError); |