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