Debian Codegraph @

js/src/tests/test262/language/statements/async-generator/yield-star-expr-abrupt.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/async-generators/yield-star-expr-abrupt.case
4 // - src/async-generators/default/async-declaration.template
5 /*---
6 description: Abrupt completion while getting yield* operand (Async generator Function declaration)
7 esid: prod-AsyncGeneratorDeclaration
8 features: [async-iteration]
9 flags: [generated, async]
10 info: |
11 Async Generator Function Definitions
12
13 AsyncGeneratorDeclaration:
14 async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) {
15 AsyncGeneratorBody }
16
17
18 YieldExpression: yield * AssignmentExpression
19
20 1. Let exprRef be the result of evaluating AssignmentExpression.
21 2. Let value be ? GetValue(exprRef).
22 ...
23
24 ---*/
25 var obj = {};
26 var abrupt = function() {
27 throw obj;
28 };
29
30
31
32 var callCount = 0;
33
34 async function *gen() {
35 callCount += 1;
36 yield* abrupt();
37 throw new Test262Error('abrupt completion closes iter');
38
39 }
40
41 var iter = gen();
42
43 iter.next().then(() => {
44 throw new Test262Error('Promise incorrectly fulfilled.');
45 }, v => {
46 assert.sameValue(v, obj, "reject reason");
47
48 iter.next().then(({ done, value }) => {
49 assert.sameValue(done, true, 'the iterator is completed');
50 assert.sameValue(value, undefined, 'value is undefined');
51 }).then($DONE, $DONE);
52 }).catch($DONE);
53
54 assert.sameValue(callCount, 1);