From 2be5f094cb3daefc9de0c2b2c202be85a3f59b87 Mon Sep 17 00:00:00 2001 From: paoloricciuti Date: Fri, 10 May 2024 13:32:35 +0200 Subject: [PATCH] chore: add test for nested blocks --- .../expected-transforms/statements-in-blocks/code.js | 12 ++++++++++++ .../statements-in-blocks/transform.js | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/lib/tests/expected-transforms/statements-in-blocks/code.js b/src/lib/tests/expected-transforms/statements-in-blocks/code.js index 4102eee..90f7a24 100644 --- a/src/lib/tests/expected-transforms/statements-in-blocks/code.js +++ b/src/lib/tests/expected-transforms/statements-in-blocks/code.js @@ -63,4 +63,16 @@ task(async ()=>{ if(await Promise.resolve(true)){ console.log(await Promise.resolve()); }else console.log(await Promise.resolve()); + + // nested test + for(const x of await Promise.resolve([])){ + console.log(await Promise.resolve("for of")); + while(await Promise.resolve(true)){ + console.log(await Promise.resolve("while")); + for(const xx in await Promise.resolve({})){ + console.log(await Promise.resolve("for in")); + + } + } + } }); \ No newline at end of file diff --git a/src/lib/tests/expected-transforms/statements-in-blocks/transform.js b/src/lib/tests/expected-transforms/statements-in-blocks/transform.js index 57534e1..9ad9336 100644 --- a/src/lib/tests/expected-transforms/statements-in-blocks/transform.js +++ b/src/lib/tests/expected-transforms/statements-in-blocks/transform.js @@ -81,4 +81,16 @@ task(async function* () { if (yield Promise.resolve(true)) { console.log(yield Promise.resolve()); } else console.log(yield Promise.resolve()); + + for (const x of yield Promise.resolve([])) { + console.log(yield Promise.resolve("for of")); + + while (yield Promise.resolve(true)) { + console.log(yield Promise.resolve("while")); + + for (const xx in yield Promise.resolve({})) { + console.log(yield Promise.resolve("for in")); + } + } + } }); \ No newline at end of file