tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

gen-meth-dflt-ary-ptrn-rest-ary-elision.js (3063B)


      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/gen-method-dflt.template
      4 /*---
      5 description: Rest element containing an elision (generator method (default parameter))
      6 esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation
      7 features: [generators, destructuring-binding, default-parameters]
      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    BindingRestElement : ... BindingPattern
     48 
     49    1. Let A be ArrayCreate(0).
     50    [...]
     51    3. Repeat
     52       [...]
     53       b. If iteratorRecord.[[done]] is true, then
     54          i. Return the result of performing BindingInitialization of
     55             BindingPattern with A and environment as the arguments.
     56       [...]
     57 
     58    13.3.3.6 Runtime Semantics: IteratorBindingInitialization
     59 
     60    ArrayBindingPattern : [ Elision ]
     61 
     62    1. Return the result of performing
     63       IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord
     64       as the argument.
     65 
     66    12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
     67 
     68    Elision : ,
     69 
     70    1. If iteratorRecord.[[done]] is false, then
     71       a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
     72       b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
     73       c. ReturnIfAbrupt(next).
     74       d. If next is false, set iteratorRecord.[[done]] to true.
     75    2. Return NormalCompletion(empty).
     76 
     77 ---*/
     78 var first = 0;
     79 var second = 0;
     80 function* g() {
     81  first += 1;
     82  yield;
     83  second += 1;
     84 };
     85 
     86 var callCount = 0;
     87 var obj = {
     88  *method([...[,]] = g()) {
     89    assert.sameValue(first, 1);
     90    assert.sameValue(second, 1);
     91    callCount = callCount + 1;
     92  }
     93 };
     94 
     95 obj.method().next();
     96 assert.sameValue(callCount, 1, 'generator method invoked exactly once');
     97 
     98 reportCompare(0, 0);