ladybird/Userland/Libraries/LibJS/Tests/regress/allow-await-in-a-func-def-assigned-to-default-param.js
Aliaksandr Kalenik 10064d0e1a LibJS: Reset in_formal_parameter_context after entering a new function
Fixes a bug when "'Await' expression is not allowed in formal parameters
of an async function" is thrown for "await" encountered in a function
definition assigned to a default function parameter.

Fixes loading of https://excalidraw.com/
2024-09-08 17:44:39 +02:00

23 lines
594 B
JavaScript

test('Do not throw syntax error when "await" is used in an arrow function definition assigned to a default function parameter', async () => {
async function f(
g = async () => {
await 1;
}
) {
return await g();
}
expect(await f()).toBe(1);
});
test('Do not throw syntax error when "await" is used in a function definition assigned to a default function parameter', async () => {
async function f(
g = async function () {
await 1;
}
) {
return await g();
}
expect(await f()).toBe(1);
});