Debian Codegraph @

js/src/tests/test262/language/statements/async-generator/yield-star-normal-notdone-iter-value-throws.js

raw
1 // |reftest| async
2 // Copyright (C) 2019 André Bargull. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-generator-function-definitions-runtime-semantics-evaluation
7 description: >
8 Abrupt completion when calling IteratorValue is propagated when received.[[Type]] is normal.
9 info: |
10 14.4.14 Runtime Semantics: Evaluation
11 YieldExpression : yield* AssignmentExpression
12
13 ...
14 7. Repeat,
15 a. If received.[[Type]] is normal, then
16 ...
17 vi. If generatorKind is async, then set received to AsyncGeneratorYield(? IteratorValue(innerResult)).
18 ...
19
20 flags: [async]
21 features: [async-iteration]
22 ---*/
23
24 var token = {};
25
26 var asyncIter = {
27 [Symbol.asyncIterator]() {
28 return this;
29 },
30 next() {
31 return {
32 done: false,
33 get value() {
34 throw token;
35 }
36 };
37 }
38 };
39
40 async function* f() {
41 var thrown;
42 try {
43 yield* asyncIter;
44 } catch (e) {
45 thrown = e;
46 }
47 return thrown;
48 }
49
50 var iter = f();
51
52 iter.next().then(({value}) => {
53 assert.sameValue(value, token);
54 }).then($DONE, $DONE);