| function shouldThrow(func, errorMessage) { |
| if (String(error) !== errorMessage) |
| throw new Error(`bad error: ${error}`); |
| throw new Error('not thrown'); |
| var proxy1 = new Proxy({}, { |
| set: (_, key) => key !== "length", |
| Array.prototype.unshift.call(proxy1); |
| }, "TypeError: Proxy object's 'set' trap returned falsy value for property 'length'"); |
| var obj2 = Object.defineProperty({}, "length", { |
| var proxy2 = new Proxy(obj2, { |
| Array.prototype.shift.call(proxy2); |
| }, "TypeError: Proxy handler's 'set' on a non-configurable and non-writable property on 'target' should either return false or be the same value already on the 'target'"); |
| var obj3 = Object.defineProperty({}, "length", { |
| var proxy3 = new Proxy(obj3, { |
| Array.prototype.pop.call(proxy3); |
| }, "TypeError: Proxy handler's 'set' method on a non-configurable accessor property without a setter should return false"); |