async-gen-meth-ary-init-iter-no-close.js (2437B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/dstr-binding/ary-init-iter-no-close.case 4 // - src/dstr-binding/default/cls-expr-async-gen-meth.template 5 /*--- 6 description: Iterator is not closed when exhausted by pattern evaluation (class expression method) 7 esid: sec-class-definitions-runtime-semantics-evaluation 8 features: [Symbol.iterator, async-iteration] 9 flags: [generated, async] 10 info: | 11 ClassExpression : class BindingIdentifieropt ClassTail 12 13 1. If BindingIdentifieropt is not present, let className be undefined. 14 2. Else, let className be StringValue of BindingIdentifier. 15 3. Let value be the result of ClassDefinitionEvaluation of ClassTail 16 with argument className. 17 [...] 18 19 14.5.14 Runtime Semantics: ClassDefinitionEvaluation 20 21 21. For each ClassElement m in order from methods 22 a. If IsStatic of m is false, then 23 i. Let status be the result of performing 24 PropertyDefinitionEvaluation for m with arguments proto and 25 false. 26 [...] 27 28 Runtime Semantics: PropertyDefinitionEvaluation 29 30 AsyncGeneratorMethod : 31 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) 32 { AsyncGeneratorBody } 33 34 1. Let propKey be the result of evaluating PropertyName. 35 2. ReturnIfAbrupt(propKey). 36 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. 37 Otherwise let strict be false. 38 4. Let scope be the running execution context's LexicalEnvironment. 39 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, 40 AsyncGeneratorBody, scope, strict). 41 [...] 42 43 44 13.3.3.5 Runtime Semantics: BindingInitialization 45 46 BindingPattern : ArrayBindingPattern 47 48 [...] 49 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, 50 result). 51 [...] 52 53 ---*/ 54 var doneCallCount = 0; 55 var iter = {}; 56 iter[Symbol.iterator] = function() { 57 return { 58 next: function() { 59 return { value: null, done: true }; 60 }, 61 return: function() { 62 doneCallCount += 1; 63 return {}; 64 } 65 }; 66 }; 67 68 69 var callCount = 0; 70 var C = class { 71 async *method([x]) { 72 assert.sameValue(doneCallCount, 0); 73 callCount = callCount + 1; 74 } 75 }; 76 77 new C().method(iter).next().then(() => { 78 assert.sameValue(callCount, 1, 'invoked exactly once'); 79 }).then($DONE, $DONE);