-
Notifications
You must be signed in to change notification settings - Fork 480
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
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
test/language/statements/async-generator/yield-star-promise-not-unwrapped.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,41 @@ | ||
// Copyright (C) 2022 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-generator-function-definitions-runtime-semantics-evaluation | ||
description: > | ||
`yield*` in an async generator does not await promises returned by a manually implemented async iterator. | ||
flags: [async] | ||
features: [async-iteration] | ||
---*/ | ||
|
||
var innerPromise = Promise.resolve("unwrapped value"); | ||
|
||
var asyncIter = { | ||
[Symbol.asyncIterator]() { | ||
return this; | ||
}, | ||
next() { | ||
return { | ||
done: false, | ||
value: innerPromise, | ||
}; | ||
}, | ||
get return() { | ||
throw new Test262Error(".return should not be accessed"); | ||
}, | ||
get throw() { | ||
throw new Test262Error(".throw should not be accessed"); | ||
}, | ||
}; | ||
|
||
async function* f() { | ||
yield* asyncIter; | ||
} | ||
|
||
f() | ||
.next() | ||
.then(v => { | ||
assert.sameValue(v.value, innerPromise, "yield* should not unwrap promises from manually-implemented async iterators"); | ||
}) | ||
.then($DONE, $DONE) |