Debian Codegraph @

js/src/tests/test262/language/statements/async-generator/dstr/ary-init-iter-close.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/dstr-binding/ary-init-iter-close.case
4 // - src/dstr-binding/default/async-gen-func-decl.template
5 /*---
6 description: Iterator is closed when not exhausted by pattern evaluation (async generator function declaration)
7 esid: sec-asyncgenerator-definitions-instantiatefunctionobject
8 features: [Symbol.iterator, async-iteration]
9 flags: [generated, async]
10 info: |
11 AsyncGeneratorDeclaration : async [no LineTerminator here] function * BindingIdentifier
12 ( FormalParameters ) { AsyncGeneratorBody }
13
14 [...]
15 3. Let F be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters, AsyncGeneratorBody,
16 scope, strict).
17 [...]
18
19
20 13.3.3.5 Runtime Semantics: BindingInitialization
21
22 BindingPattern : ArrayBindingPattern
23
24 [...]
25 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
26 result).
27 [...]
28
29 ---*/
30 var doneCallCount = 0;
31 var iter = {};
32 iter[Symbol.iterator] = function() {
33 return {
34 next: function() {
35 return { value: null, done: false };
36 },
37 return: function() {
38 doneCallCount += 1;
39 return {};
40 }
41 };
42 };
43
44
45 var callCount = 0;
46 async function* f([x]) {
47 assert.sameValue(doneCallCount, 1);
48 callCount = callCount + 1;
49 };
50 f(iter).next().then(() => {
51 assert.sameValue(callCount, 1, 'invoked exactly once');
52 }).then($DONE, $DONE);