blob: 807798af81e7ef1d92ba4f99ce6bb48d292d9d06 [file] [log] [blame]
function assert(cond, msg = "") {
if (!cond)
throw new Error(msg);
}
noInline(assert);
function shouldThrowSyntaxError(str) {
var hadError = false;
try {
eval(str);
} catch (e) {
if (e instanceof SyntaxError)
hadError = true;
}
assert(hadError, "Did not throw syntax error");
}
noInline(shouldThrowSyntaxError);
shouldThrowSyntaxError("var f = new Function('}{')");
shouldThrowSyntaxError("var f = new Function('}}{{')");
var GeneratorFunction = function*(){}.constructor;
shouldThrowSyntaxError("var f = new GeneratorFunction('}{')");
shouldThrowSyntaxError("var f = new GeneratorFunction('}}{{')");