tests/auto/qml/ecmascripttests/test262/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elision.js
raw symbols SCIP| 1 | // This file was procedurally generated from the following sources: |
| 2 | // - src/dstr-binding/ary-ptrn-rest-ary-elision.case |
| 3 | // - src/dstr-binding/default/cls-decl-meth-static-dflt.template |
| 4 | /*--- |
| 5 | description: Rest element containing an elision (static class expression method (default parameter)) |
| 6 | esid: sec-runtime-semantics-bindingclassdeclarationevaluation |
| 7 | es6id: 14.5.15 |
| 8 | features: [generators, destructuring-binding, default-parameters] |
| 9 | flags: [generated] |
| 10 | info: | |
| 11 | ClassDeclaration : class BindingIdentifier ClassTail |
| 12 | |
| 13 | 1. Let className be StringValue of BindingIdentifier. |
| 14 | 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with |
| 15 | argument className. |
| 16 | [...] |
| 17 | |
| 18 | 14.5.14 Runtime Semantics: ClassDefinitionEvaluation |
| 19 | |
| 20 | 21. For each ClassElement m in order from methods |
| 21 | a. If IsStatic of m is false, then |
| 22 | b. Else, |
| 23 | Let status be the result of performing PropertyDefinitionEvaluation for |
| 24 | m with arguments F and false. |
| 25 | [...] |
| 26 | |
| 27 | 14.3.8 Runtime Semantics: DefineMethod |
| 28 | |
| 29 | MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } |
| 30 | |
| 31 | [...] |
| 32 | 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, |
| 33 | scope, strict). If functionPrototype was passed as a parameter then pass its |
| 34 | value as the functionPrototype optional argument of FunctionCreate. |
| 35 | [...] |
| 36 | |
| 37 | 9.2.1 [[Call]] ( thisArgument, argumentsList) |
| 38 | |
| 39 | [...] |
| 40 | 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). |
| 41 | [...] |
| 42 | |
| 43 | 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) |
| 44 | |
| 45 | 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). |
| 46 | [...] |
| 47 | |
| 48 | 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) |
| 49 | |
| 50 | [...] |
| 51 | 23. Let iteratorRecord be Record {[[iterator]]: |
| 52 | CreateListIterator(argumentsList), [[done]]: false}. |
| 53 | 24. If hasDuplicates is true, then |
| 54 | [...] |
| 55 | 25. Else, |
| 56 | b. Let formalStatus be IteratorBindingInitialization for formals with |
| 57 | iteratorRecord and env as arguments. |
| 58 | [...] |
| 59 | |
| 60 | 13.3.3.6 Runtime Semantics: IteratorBindingInitialization |
| 61 | |
| 62 | BindingRestElement : ... BindingPattern |
| 63 | |
| 64 | 1. Let A be ArrayCreate(0). |
| 65 | [...] |
| 66 | 3. Repeat |
| 67 | [...] |
| 68 | b. If iteratorRecord.[[done]] is true, then |
| 69 | i. Return the result of performing BindingInitialization of |
| 70 | BindingPattern with A and environment as the arguments. |
| 71 | [...] |
| 72 | |
| 73 | 13.3.3.6 Runtime Semantics: IteratorBindingInitialization |
| 74 | |
| 75 | ArrayBindingPattern : [ Elision ] |
| 76 | |
| 77 | 1. Return the result of performing |
| 78 | IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord |
| 79 | as the argument. |
| 80 | |
| 81 | 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation |
| 82 | |
| 83 | Elision : , |
| 84 | |
| 85 | 1. If iteratorRecord.[[done]] is false, then |
| 86 | a. Let next be IteratorStep(iteratorRecord.[[iterator]]). |
| 87 | b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. |
| 88 | c. ReturnIfAbrupt(next). |
| 89 | d. If next is false, set iteratorRecord.[[done]] to true. |
| 90 | 2. Return NormalCompletion(empty). |
| 91 | |
| 92 | ---*/ |
| 93 | var first = 0; |
| 94 | var second = 0; |
| 95 | function* g() { |
| 96 | first += 1; |
| 97 | yield; |
| 98 | second += 1; |
| 99 | }; |
| 100 | |
| 101 | var callCount = 0; |
| 102 | class C { |
| 103 | static method([...[,]] = g()) { |
| 104 | assert.sameValue(first, 1); |
| 105 | assert.sameValue(second, 1); |
| 106 | callCount = callCount + 1; |
| 107 | } |
| 108 | }; |
| 109 | |
| 110 | C.method(); |
| 111 | assert.sameValue(callCount, 1, 'method invoked exactly once'); |