tor-browser

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

named-dflt-ary-ptrn-rest-id-elision.js (1679B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/dstr-binding/ary-ptrn-rest-id-elision.case
      4 // - src/dstr-binding/default/async-gen-func-named-expr-dflt.template
      5 /*---
      6 description: Rest element following elision elements (async generator named function expression (default parameter))
      7 esid: sec-asyncgenerator-definitions-evaluation
      8 features: [async-iteration]
      9 flags: [generated, async]
     10 info: |
     11    AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier
     12        ( FormalParameters ) { AsyncGeneratorBody }
     13 
     14        [...]
     15        7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters,
     16           AsyncGeneratorBody, funcEnv, strict).
     17        [...]
     18 
     19 
     20    13.3.3.6 Runtime Semantics: IteratorBindingInitialization
     21    ArrayBindingPattern : [ Elisionopt BindingRestElement ]
     22    1. If Elision is present, then
     23       a. Let status be the result of performing
     24          IteratorDestructuringAssignmentEvaluation of Elision with
     25          iteratorRecord as the argument.
     26       b. ReturnIfAbrupt(status).
     27    2. Return the result of performing IteratorBindingInitialization for
     28       BindingRestElement with iteratorRecord and environment as arguments.
     29 ---*/
     30 var values = [1, 2, 3, 4, 5];
     31 
     32 
     33 var callCount = 0;
     34 var f;
     35 f = async function* h([ , , ...x] = values) {
     36  assert(Array.isArray(x));
     37  assert.sameValue(x.length, 3);
     38  assert.sameValue(x[0], 3);
     39  assert.sameValue(x[1], 4);
     40  assert.sameValue(x[2], 5);
     41  assert.notSameValue(x, values);
     42  callCount = callCount + 1;
     43 };
     44 
     45 f().next().then(() => {
     46    assert.sameValue(callCount, 1, 'invoked exactly once');
     47 }).then($DONE, $DONE);