js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-elem-ary-rest-iter.js
raw symbols SCIP| 1 | // This file was procedurally generated from the following sources: |
| 2 | // - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case |
| 3 | // - src/dstr-binding/default/gen-meth.template |
| 4 | /*--- |
| 5 | description: BindingElement with array binding pattern and initializer is not used (generator method) |
| 6 | esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation |
| 7 | features: [generators, destructuring-binding] |
| 8 | flags: [generated] |
| 9 | info: | |
| 10 | GeneratorMethod : |
| 11 | * PropertyName ( StrictFormalParameters ) { GeneratorBody } |
| 12 | |
| 13 | 1. Let propKey be the result of evaluating PropertyName. |
| 14 | 2. ReturnIfAbrupt(propKey). |
| 15 | 3. If the function code for this GeneratorMethod is strict mode code, |
| 16 | let strict be true. Otherwise let strict be false. |
| 17 | 4. Let scope be the running execution context's LexicalEnvironment. |
| 18 | 5. Let closure be GeneratorFunctionCreate(Method, |
| 19 | StrictFormalParameters, GeneratorBody, scope, strict). |
| 20 | [...] |
| 21 | |
| 22 | 9.2.1 [[Call]] ( thisArgument, argumentsList) |
| 23 | |
| 24 | [...] |
| 25 | 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). |
| 26 | [...] |
| 27 | |
| 28 | 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) |
| 29 | |
| 30 | 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). |
| 31 | [...] |
| 32 | |
| 33 | 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) |
| 34 | |
| 35 | [...] |
| 36 | 23. Let iteratorRecord be Record {[[iterator]]: |
| 37 | CreateListIterator(argumentsList), [[done]]: false}. |
| 38 | 24. If hasDuplicates is true, then |
| 39 | [...] |
| 40 | 25. Else, |
| 41 | b. Let formalStatus be IteratorBindingInitialization for formals with |
| 42 | iteratorRecord and env as arguments. |
| 43 | [...] |
| 44 | |
| 45 | 13.3.3.6 Runtime Semantics: IteratorBindingInitialization |
| 46 | |
| 47 | BindingElement : BindingPatternInitializer opt |
| 48 | |
| 49 | 1. If iteratorRecord.[[done]] is false, then |
| 50 | a. Let next be IteratorStep(iteratorRecord.[[iterator]]). |
| 51 | [...] |
| 52 | e. Else, |
| 53 | i. Let v be IteratorValue(next). |
| 54 | [...] |
| 55 | 4. Return the result of performing BindingInitialization of BindingPattern |
| 56 | with v and environment as the arguments. |
| 57 | ---*/ |
| 58 | var values = [2, 1, 3]; |
| 59 | var initCount = 0; |
| 60 | |
| 61 | var callCount = 0; |
| 62 | var obj = { |
| 63 | *method([[...x] = function() { initCount += 1; }()]) { |
| 64 | assert(Array.isArray(x)); |
| 65 | assert.sameValue(x[0], 2); |
| 66 | assert.sameValue(x[1], 1); |
| 67 | assert.sameValue(x[2], 3); |
| 68 | assert.sameValue(x.length, 3); |
| 69 | assert.notSameValue(x, values); |
| 70 | assert.sameValue(initCount, 0); |
| 71 | callCount = callCount + 1; |
| 72 | } |
| 73 | }; |
| 74 | |
| 75 | obj.method([values]).next(); |
| 76 | assert.sameValue(callCount, 1, 'generator method invoked exactly once'); |
| 77 | |
| 78 | reportCompare(0, 0); |