| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/dstr-binding/obj-ptrn-rest-getter.case |
| 3 |
// - src/dstr-binding/default/gen-meth.template |
| 4 |
/*--- |
| 5 |
description: Getter is called when obj is being deconstructed to a rest Object (generator method) |
| 6 |
esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation |
| 7 |
es6id: 14.4.13 |
| 8 |
features: [object-rest, generators, destructuring-binding] |
| 9 |
flags: [generated] |
| 10 |
includes: [propertyHelper.js] |
| 11 |
info: | |
| 12 |
GeneratorMethod : |
| 13 |
* PropertyName ( StrictFormalParameters ) { GeneratorBody } |
| 14 |
|
| 15 |
1. Let propKey be the result of evaluating PropertyName. |
| 16 |
2. ReturnIfAbrupt(propKey). |
| 17 |
3. If the function code for this GeneratorMethod is strict mode code, |
| 18 |
let strict be true. Otherwise let strict be false. |
| 19 |
4. Let scope be the running execution context's LexicalEnvironment. |
| 20 |
5. Let closure be GeneratorFunctionCreate(Method, |
| 21 |
StrictFormalParameters, GeneratorBody, scope, strict). |
| 22 |
[...] |
| 23 |
|
| 24 |
9.2.1 [[Call]] ( thisArgument, argumentsList) |
| 25 |
|
| 26 |
[...] |
| 27 |
7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). |
| 28 |
[...] |
| 29 |
|
| 30 |
9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) |
| 31 |
|
| 32 |
1. Let status be FunctionDeclarationInstantiation(F, argumentsList). |
| 33 |
[...] |
| 34 |
|
| 35 |
9.2.12 FunctionDeclarationInstantiation(func, argumentsList) |
| 36 |
|
| 37 |
[...] |
| 38 |
23. Let iteratorRecord be Record {[[iterator]]: |
| 39 |
CreateListIterator(argumentsList), [[done]]: false}. |
| 40 |
24. If hasDuplicates is true, then |
| 41 |
[...] |
| 42 |
25. Else, |
| 43 |
b. Let formalStatus be IteratorBindingInitialization for formals with |
| 44 |
iteratorRecord and env as arguments. |
| 45 |
[...] |
| 46 |
---*/ |
| 47 |
var count = 0; |
| 48 |
|
| 49 |
var callCount = 0; |
| 50 |
var obj = { |
| 51 |
*method({...x}) { |
| 52 |
assert.sameValue(count, 1); |
| 53 |
|
| 54 |
verifyProperty(x, "v", { |
| 55 |
enumerable: true, |
| 56 |
writable: true, |
| 57 |
configurable: true, |
| 58 |
value: 2 |
| 59 |
}); |
| 60 |
callCount = callCount + 1; |
| 61 |
} |
| 62 |
}; |
| 63 |
|
| 64 |
obj.method({ get v() { count++; return 2; } }).next(); |
| 65 |
assert.sameValue(callCount, 1, 'generator method invoked exactly once'); |