blob: 7ff492342cc3219d7ca62870c1a62a3e9e90bbc2 [file] [log] [blame] [edit]
function shouldThrow(func, errorMessage) {
var errorThrown = false;
var error = null;
try {
func();
} catch (e) {
errorThrown = true;
error = e;
}
if (!errorThrown)
throw new Error('not thrown');
if (String(error) !== errorMessage)
throw new Error(`bad error: ${String(error)}`);
}
var object = { };
object.object = object;
shouldThrow(() => {
JSON.stringify(object);
}, `TypeError: JSON.stringify cannot serialize cyclic structures.`);