Replace SpiderMonkey-specific parseModule in async-functions/async-contains-unicode-escape.js and fix a test bug

This commit is contained in:
André Bargull 2025-04-30 14:16:45 +02:00 committed by Philip Chimento
parent d90061929a
commit 7ec30cc749
2 changed files with 19 additions and 12 deletions

View File

@ -0,0 +1,17 @@
// Copyright (C) 2024 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: |
async/await containing escapes
esid: pending
negative:
phase: parse
type: SyntaxError
flags:
- module
---*/
$DONOTEVALUATE();
export default \u0061sync function f() {}

View File

@ -2,22 +2,15 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
flags:
- noStrict
description: |
async/await containing escapes
esid: pending
---*/
// Using "eval" as the argument name is fugly, but it means evals below are
// *direct* evals, and so their effects in the unescaped case won't extend
// past each separate |test| call (as would happen if we used a different name
// that made each eval into an indirect eval, affecting code in the global
// scope).
function test(code, eval)
function test(code)
{
var unescaped = code.replace("###", "async");
var escaped = code.replace("###", "\\u0061");
var escaped = code.replace("###", "\\u0061sync");
assert.throws(SyntaxError, () => eval(escaped));
eval(unescaped);
@ -34,9 +27,6 @@ test("var x = ### (y) => {}", eval);
test("({ ### x() {} })", eval);
test("var x = ### function f() {}", eval);
if (typeof parseModule === "function")
test("export default ### function f() {}", parseModule);
assert.throws(SyntaxError, () => eval("async await => 1;"));
assert.throws(SyntaxError, () => eval("async aw\\u0061it => 1;"));