forked from babel/babel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bd3cdd
commit fa7852c
Showing
17 changed files
with
160 additions
and
41 deletions.
There are no files selected for viewing
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
8 changes: 4 additions & 4 deletions
8
...l-plugin-proposal-async-generator-functions/test/fixtures/for-await/async-arrow/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
8 changes: 4 additions & 4 deletions
8
...l-async-generator-functions/test/fixtures/for-await/async-function-no-transform/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
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
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
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
6 changes: 6 additions & 0 deletions
6
...-proposal-async-generator-functions/test/fixtures/for-await/lhs-member-expression/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,6 @@ | ||
return async function () { | ||
let obj = {}; | ||
for await (obj.x of [1, 2]); | ||
|
||
expect(obj.x).toBe(2); | ||
}(); |
3 changes: 3 additions & 0 deletions
3
...proposal-async-generator-functions/test/fixtures/for-await/lhs-member-expression/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,3 @@ | ||
(async function () { | ||
for await (obj.x of y) {} | ||
})(); |
5 changes: 5 additions & 0 deletions
5
...osal-async-generator-functions/test/fixtures/for-await/lhs-member-expression/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,5 @@ | ||
{ | ||
"parserOpts": { | ||
"allowReturnOutsideFunction": true | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...roposal-async-generator-functions/test/fixtures/for-await/lhs-member-expression/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,25 @@ | ||
babelHelpers.asyncToGenerator(function* () { | ||
var _iteratorAbruptCompletion = false; | ||
var _didIteratorError = false; | ||
|
||
var _iteratorError; | ||
|
||
try { | ||
for (var _iterator = babelHelpers.asyncIterator(y), _step; _iteratorAbruptCompletion = !(_step = yield _iterator.next()).done; _iteratorAbruptCompletion = false) { | ||
obj.x = _step.value; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (_iteratorAbruptCompletion && _iterator.return != null) { | ||
yield _iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
})(); |
31 changes: 31 additions & 0 deletions
31
...lugin-proposal-async-generator-functions/test/fixtures/for-await/step-single-tick/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,31 @@ | ||
let resolve; | ||
let promise = new Promise((r) => (resolve = r)); | ||
let iterable = { | ||
[Symbol.asyncIterator || "@@asyncIterator"]() { | ||
return { | ||
next: () => promise, | ||
}; | ||
}, | ||
}; | ||
|
||
let values = []; | ||
|
||
return Promise.all([ | ||
async function () { | ||
for await (let value of iterable) { | ||
values.push(value); | ||
} | ||
}(), | ||
async function () { | ||
resolve({ value: 0, done: false }); | ||
promise = new Promise((r) => (resolve = r)); | ||
|
||
await null; | ||
resolve({ value: 1, done: false }); | ||
promise = new Promise((r) => (resolve = r)); | ||
|
||
resolve({ value: undefined, done: true }); | ||
}(), | ||
]).then(() => { | ||
expect(values).toEqual([0, 1]); | ||
}); |
5 changes: 5 additions & 0 deletions
5
...-proposal-async-generator-functions/test/fixtures/for-await/step-single-tick/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,5 @@ | ||
{ | ||
"parserOpts": { | ||
"allowReturnOutsideFunction": true | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...-proposal-async-generator-functions/test/fixtures/for-await/step-value-is-promise/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,22 @@ | ||
let steps = [ | ||
{ done: false, value: Promise.resolve(1) }, | ||
{ done: true, value: undefined } | ||
]; | ||
|
||
let iterable = { | ||
[Symbol.asyncIterator || "@@asyncIterator"]() { | ||
return { | ||
next: () => steps.shift(), | ||
}; | ||
}, | ||
}; | ||
|
||
let values = []; | ||
|
||
return async function () { | ||
let value; | ||
for await (value of iterable); | ||
|
||
expect(value).toBeInstanceOf(Promise); | ||
await expect(value).resolves.toBe(1); | ||
}(); |
5 changes: 5 additions & 0 deletions
5
...osal-async-generator-functions/test/fixtures/for-await/step-value-is-promise/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,5 @@ | ||
{ | ||
"parserOpts": { | ||
"allowReturnOutsideFunction": true | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ync-generator-functions/test/fixtures/for-await/step-value-not-accessed-when-done/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,18 @@ | ||
let gotValue = false; | ||
|
||
let iterable = { | ||
[Symbol.asyncIterator || "@@asyncIterator"]() { | ||
return { | ||
next: () => Promise.resolve({ | ||
get value() { gotValue = true }, | ||
done: true | ||
}) | ||
}; | ||
}, | ||
}; | ||
|
||
return async function () { | ||
for await (let value of iterable) {} | ||
|
||
expect(gotValue).toBe(false); | ||
}(); |
5 changes: 5 additions & 0 deletions
5
...enerator-functions/test/fixtures/for-await/step-value-not-accessed-when-done/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,5 @@ | ||
{ | ||
"parserOpts": { | ||
"allowReturnOutsideFunction": true | ||
} | ||
} |
11 changes: 5 additions & 6 deletions
11
...s/babel-plugin-proposal-async-generator-functions/test/fixtures/regression/5880/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