async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js (1991B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case 4 // - src/dstr-binding/default/async-gen-method-dflt.template 5 /*--- 6 description: SingleNameBinding assigns `name` to "anonymous" classes (async generator method (default parameter)) 7 esid: sec-asyncgenerator-definitions-propertydefinitionevaluation 8 features: [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 SingleNameBinding : BindingIdentifier Initializeropt 28 29 [...] 30 6. If Initializer is present and v is undefined, then 31 a. Let defaultValue be the result of evaluating Initializer. 32 b. Let v be GetValue(defaultValue). 33 c. ReturnIfAbrupt(v). 34 d. If IsAnonymousFunctionDefinition(Initializer) is true, then 35 [...] 36 7. If environment is undefined, return PutValue(lhs, v). 37 8. Return InitializeReferencedBinding(lhs, v). 38 ---*/ 39 40 41 var callCount = 0; 42 var obj = { 43 async *method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { 44 assert.sameValue(cls.name, 'cls'); 45 assert.notSameValue(xCls.name, 'xCls'); 46 assert.notSameValue(xCls2.name, 'xCls2'); 47 callCount = callCount + 1; 48 } 49 }; 50 51 obj.method().next().then(() => { 52 assert.sameValue(callCount, 1, 'invoked exactly once'); 53 }).then($DONE, $DONE);