Debian Codegraph @

js/src/tests/test262/language/statements/async-generator/yield-star-throw-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 throw.
9 info: |
10 14.4.14 Runtime Semantics: Evaluation
11 YieldExpression : yield* AssignmentExpression
12
13 ...
14 7. Repeat,
15 ...
16 b. Else if received.[[Type]] is throw, then
17 ...
18 ii. If throw is not undefined, then
19 ...
20 7. If generatorKind is async, then set received to AsyncGeneratorYield(? IteratorValue(innerResult)).
21 ...
22
23 flags: [async]
24 features: [async-iteration]
25 ---*/
26
27 var token = {};
28
29 var asyncIter = {
30 [Symbol.asyncIterator]() {
31 return this;
32 },
33 next() {
34 return {
35 done: false,
36 value: undefined,
37 };
38 },
39 throw() {
40 return {
41 done: false,
42 get value() {
43 throw token;
44 }
45 };
46 }
47 };
48
49 async function* f() {
50 var thrown;
51 try {
52 yield* asyncIter;
53 } catch (e) {
54 thrown = e;
55 }
56 return thrown;
57 }
58
59 var iter = f();
60
61 iter.next().then(() => {
62 iter.throw().then(({value}) => {
63 assert.sameValue(value, token);
64 }).then($DONE, $DONE);
65 }).catch($DONE);