blob: f004ceab03fbcbcc47d2629a31a2fec33f7d3ee0 [file] [log] [blame]
function shouldThrow(func, errorMessage) {
let errorThrown = false;
try {
func();
} catch (error) {
errorThrown = true;
if (String(error) !== errorMessage)
throw new Error(`Bad error: ${error}`);
}
if (!errorThrown)
throw new Error('Not thrown!');
}
const obj = {};
const s = [0.1].toLocaleString().padEnd(2 ** 31 - 1, "ab");
Object.defineProperty(obj, "foo", {value: s, writable: false, enumerable: true, configurable: false});
shouldThrow(() => {
Object.defineProperty(obj, "foo", {value: "bar"});
}, "RangeError: Out of memory");