Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
include generators for do expression
- Loading branch information
Showing
8 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...ges/babel-plugin-proposal-do-expressions/test/fixtures/do-expressions/await-yield/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
async function* asyncGenerator(x) { | ||
const y = do { | ||
let z; | ||
yield 3; | ||
yield await x; | ||
}; | ||
|
||
return y; | ||
} | ||
|
||
const promise = Promise.resolve(5); | ||
const gen = asyncGenerator(promise); | ||
expect(gen.next()).resolves.toMatchObject({ value: 3, done: false }); | ||
expect(gen.next()).resolves.toMatchObject({ value: 5, done: false }); | ||
expect(gen.next(10)).resolves.toMatchObject({ value: 10, done: true }); |
8 changes: 8 additions & 0 deletions
8
...es/babel-plugin-proposal-do-expressions/test/fixtures/do-expressions/await-yield/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
async function* asyncGenerator(x) { | ||
const y = do { | ||
let z; | ||
yield await x; | ||
}; | ||
|
||
return y; | ||
} |
3 changes: 3 additions & 0 deletions
3
...abel-plugin-proposal-do-expressions/test/fixtures/do-expressions/await-yield/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"minNodeVersion": "10.0.0" | ||
} |
7 changes: 7 additions & 0 deletions
7
...s/babel-plugin-proposal-do-expressions/test/fixtures/do-expressions/await-yield/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
async function* asyncGenerator(x) { | ||
const y = yield* await async function* () { | ||
let z; | ||
return yield await x; | ||
}(); | ||
return y; | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/babel-plugin-proposal-do-expressions/test/fixtures/do-expressions/yield/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function * generator() { | ||
yield 1; | ||
const y = do { | ||
let z; | ||
yield 2; | ||
}; | ||
|
||
return y; | ||
} | ||
|
||
const gen = generator(); | ||
expect(gen.next().value).toBe(1); | ||
expect(gen.next().value).toBe(2); | ||
expect(gen.next(3).value).toBe(3); |
8 changes: 8 additions & 0 deletions
8
packages/babel-plugin-proposal-do-expressions/test/fixtures/do-expressions/yield/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function * g() { | ||
const y = do { | ||
let z; | ||
yield 1; | ||
}; | ||
|
||
return y; | ||
} |
3 changes: 3 additions & 0 deletions
3
...ages/babel-plugin-proposal-do-expressions/test/fixtures/do-expressions/yield/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"minNodeVersion": "8.0.0" | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/babel-plugin-proposal-do-expressions/test/fixtures/do-expressions/yield/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function* g() { | ||
const y = yield* function* () { | ||
let z; | ||
return yield 1; | ||
}(); | ||
return y; | ||
} |