1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:57:35 +00:00

LibJS: Parse generator functions in object literals

Also add some parser tests
This commit is contained in:
Ali Mohammad Pur 2021-06-14 14:52:59 +04:30 committed by Linus Groh
parent 2661a88108
commit d374295a26
3 changed files with 34 additions and 5 deletions

View file

@ -21,3 +21,21 @@ describe("parsing freestanding generators", () => {
*bar; }`).toEval();
});
});
describe("parsing object literal generator functions", () => {
test("simple", () => {
expect(`x = { *foo() { } }`).toEval();
expect(`x = { * foo() { } }`).toEval();
expect(`x = { *
foo() { } }`).toEval();
});
test("yield", () => {
expect(`x = { foo() { yield; } }`).toEval();
expect(`x = { *foo() { yield; } }`).toEval();
expect(`x = { *foo() { yield 42; } }`).toEval();
expect(`x = { foo() { yield 42; } }`).not.toEval();
expect(`x = { *foo() { yield (yield); } }`).toEval();
expect(`x = { *
foo() { yield (yield); } }`).toEval();
});
});