Debian Codegraph @

js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-dflt-ary-ptrn-elision.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/dstr-binding/ary-ptrn-elision.case
4 // - src/dstr-binding/default/async-gen-method-dflt.template
5 /*---
6 description: Elision advances iterator (async generator method (default parameter))
7 esid: sec-asyncgenerator-definitions-propertydefinitionevaluation
8 features: [generators, async-iteration]
9 flags: [generated, async]
10 info: |
11 AsyncGeneratorMethod :
12 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters )
13 { AsyncGeneratorBody }
14
15 1. Let propKey be the result of evaluating PropertyName.
16 2. ReturnIfAbrupt(propKey).
17 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true.
18 Otherwise let strict be false.
19 4. Let scope be the running execution context's LexicalEnvironment.
20 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters,
21 AsyncGeneratorBody, scope, strict).
22 [...]
23
24
25 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
26
27 ArrayBindingPattern : [ Elision ]
28
29 1. Return the result of performing
30 IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
31 as the argument.
32
33 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
34
35 Elision : ,
36
37 1. If iteratorRecord.[[done]] is false, then
38 a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
39 b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
40 c. ReturnIfAbrupt(next).
41 d. If next is false, set iteratorRecord.[[done]] to true.
42 2. Return NormalCompletion(empty).
43
44 ---*/
45 var first = 0;
46 var second = 0;
47 function* g() {
48 first += 1;
49 yield;
50 second += 1;
51 };
52
53
54 var callCount = 0;
55 var obj = {
56 async *method([,] = g()) {
57 assert.sameValue(first, 1);
58 assert.sameValue(second, 0);
59 callCount = callCount + 1;
60 }
61 };
62
63 obj.method().next().then(() => {
64 assert.sameValue(callCount, 1, 'invoked exactly once');
65 }).then($DONE, $DONE);