| 1 |
// Copyright (C) 2017 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
path: language/expressions/object/dstr-async-gen-meth-dflt- |
| 6 |
name: async generator method (default parameter) |
| 7 |
esid: sec-asyncgenerator-definitions-propertydefinitionevaluation |
| 8 |
features: [async-iteration] |
| 9 |
info: | |
| 10 |
AsyncGeneratorMethod : |
| 11 |
async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) |
| 12 |
{ AsyncGeneratorBody } |
| 13 |
|
| 14 |
1. Let propKey be the result of evaluating PropertyName. |
| 15 |
2. ReturnIfAbrupt(propKey). |
| 16 |
3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. |
| 17 |
Otherwise let strict be false. |
| 18 |
4. Let scope be the running execution context's LexicalEnvironment. |
| 19 |
5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, |
| 20 |
AsyncGeneratorBody, scope, strict). |
| 21 |
[...] |
| 22 |
flags: [async] |
| 23 |
---*/ |
| 24 |
|
| 25 |
var callCount = 0; |
| 26 |
var obj = { |
| 27 |
async *method(/*{ elems }*/ = /*{ vals }*/) { |
| 28 |
/*{ body }*/ |
| 29 |
callCount = callCount + 1; |
| 30 |
} |
| 31 |
}; |
| 32 |
|
| 33 |
obj.method().next().then(() => { |
| 34 |
assert.sameValue(callCount, 1, 'invoked exactly once'); |
| 35 |
}).then($DONE, $DONE); |