tor-browser

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

async-gen-meth-dflt-ary-ptrn-rest-ary-elem.js (2491B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/dstr-binding/ary-ptrn-rest-ary-elem.case
      4 // - src/dstr-binding/default/async-gen-method-dflt.template
      5 /*---
      6 description: Rest element containing an array BindingElementList pattern (async generator method (default parameter))
      7 esid: sec-asyncgenerator-definitions-propertydefinitionevaluation
      8 features: [async-iteration]
      9 flags: [generated, async]
     10 info: |
     11    AsyncGeneratorMethod :
     12        async [no LineTerminator here] * PropertyName ( UniqueFormalParameters )
     13            { AsyncGeneratorBody }
     14 
     15    1. Let propKey be the result of evaluating PropertyName.
     16    2. ReturnIfAbrupt(propKey).
     17    3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true.
     18       Otherwise let strict be false.
     19    4. Let scope be the running execution context's LexicalEnvironment.
     20    5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters,
     21       AsyncGeneratorBody, scope, strict).
     22    [...]
     23 
     24 
     25    13.3.3.6 Runtime Semantics: IteratorBindingInitialization
     26 
     27    BindingRestElement : ... BindingPattern
     28 
     29    1. Let A be ArrayCreate(0).
     30    [...]
     31    3. Repeat
     32       [...]
     33       b. If iteratorRecord.[[done]] is true, then
     34          i. Return the result of performing BindingInitialization of
     35             BindingPattern with A and environment as the arguments.
     36       [...]
     37 
     38    13.3.3.6 Runtime Semantics: IteratorBindingInitialization
     39 
     40    SingleNameBinding : BindingIdentifier Initializeropt
     41 
     42    [...]
     43    4. If iteratorRecord.[[done]] is false, then
     44       a. Let next be IteratorStep(iteratorRecord.[[iterator]]).
     45       b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
     46       c. ReturnIfAbrupt(next).
     47       d. If next is false, set iteratorRecord.[[done]] to true.
     48       e. Else,
     49          [...]
     50          i. Let v be IteratorValue(next).
     51          ii. If v is an abrupt completion, set
     52              iteratorRecord.[[done]] to true.
     53          iii. ReturnIfAbrupt(v).
     54    5. If iteratorRecord.[[done]] is true, let v be undefined.
     55    [...]
     56    8. Return InitializeReferencedBinding(lhs, v).
     57 ---*/
     58 
     59 
     60 var callCount = 0;
     61 var obj = {
     62  async *method([...[x, y, z]] = [3, 4, 5]) {
     63    assert.sameValue(x, 3);
     64    assert.sameValue(y, 4);
     65    assert.sameValue(z, 5);
     66    callCount = callCount + 1;
     67  }
     68 };
     69 
     70 obj.method().next().then(() => {
     71    assert.sameValue(callCount, 1, 'invoked exactly once');
     72 }).then($DONE, $DONE);