1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

LibJS: Handle escaped keywords in more cases and handle 'await' labels

This commit is contained in:
davidot 2021-09-18 23:02:50 +02:00 committed by Linus Groh
parent 79caca8ca2
commit 4428e494b0
3 changed files with 53 additions and 10 deletions

View file

@ -110,6 +110,28 @@ test("can use certain 'keywords' as labels", () => {
expect(`const: { break const; }`).not.toEval();
});
test("can use certain 'keywords' even in strict mode", () => {
"use strict";
let i = 0;
await: {
i++;
break await;
expect().fail();
}
async: {
i++;
break async;
expect().fail();
}
expect(i).toBe(2);
expect(`'use strict'; let: { break let; }`).not.toEval();
expect(`'use strict'; l\u0065t: { break l\u0065t; }`).not.toEval();
});
test("invalid label usage", () => {
expect(() =>
eval(`