blob: d4d3f641beb7ac730215543d9cbd225775333c8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// |reftest| async
// Copyright (C) 2020 Alexey Shvayka. 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: >
If iterator's "return" method is missing,
received value is awaited before forwarded to the runtime.
info: |
YieldExpression : yield * AssignmentExpression
[...]
7. Repeat,
[...]
c. Else,
i. Assert: received.[[Type]] is return.
ii. Let return be ? GetMethod(iterator, "return").
iii. If return is undefined, then
1. If generatorKind is async, then set received.[[Value]] to ? Await(received.[[Value]]).
2. Return Completion(received).
features: [Symbol.asyncIterator, async-iteration]
flags: [async]
---*/
var asyncIterable = {
[Symbol.asyncIterator]: function() {
return this;
},
next: function() {
return {value: 1, done: false};
},
};
async function* asyncGenerator() {
yield* asyncIterable;
}
var asyncIterator = asyncGenerator();
asyncIterator.next().then(function() {
var promise = Promise.resolve(2).then(() => 3);
return asyncIterator.return(promise).then(function(result) {
assert.sameValue(result.value, 3);
assert.sameValue(result.done, true);
});
}).then($DONE, $DONE);
|