tor-browser

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

async-gen-decl-dstr-array-elem-init-fn-name-arrow.js (2069B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/dstr-assignment-for-await/array-elem-init-fn-name-arrow.case
      4 // - src/dstr-assignment-for-await/default/async-gen-decl.template
      5 /*---
      6 description: Assignment of function `name` attribute (ArrowFunction) (for-await-of statement in an async generator declaration)
      7 esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
      8 features: [destructuring-binding, async-iteration]
      9 flags: [generated, async]
     10 includes: [propertyHelper.js]
     11 info: |
     12    IterationStatement :
     13      for await ( LeftHandSideExpression of AssignmentExpression ) Statement
     14 
     15    1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
     16       AssignmentExpression, iterate).
     17    2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
     18       keyResult, assignment, labelSet).
     19 
     20    13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
     21 
     22    [...]
     23    5. If destructuring is true and if lhsKind is assignment, then
     24       a. Assert: lhs is a LeftHandSideExpression.
     25       b. Let assignmentPattern be the parse of the source text corresponding to
     26          lhs using AssignmentPattern as the goal symbol.
     27    [...]
     28 
     29    AssignmentElement[Yield] : DestructuringAssignmentTarget Initializeropt
     30    [...] 7. If Initializer is present and value is undefined and
     31       IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of
     32       DestructuringAssignmentTarget are both true, then
     33       a. Let hasNameProperty be ? HasOwnProperty(v, "name").
     34       b. If hasNameProperty is false, perform SetFunctionName(v, GetReferencedName(lref)).
     35 
     36 ---*/
     37 let arrow;
     38 
     39 let iterCount = 0;
     40 async function * fn() {
     41  for await ([ arrow = () => {} ] of [[]]) {
     42    verifyProperty(arrow, 'name', {
     43      enumerable: false,
     44      writable: false,
     45      configurable: true,
     46      value: 'arrow'
     47    });
     48 
     49    iterCount += 1;
     50  }
     51 }
     52 
     53 let promise = fn().next();
     54 
     55 promise
     56  .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
     57  .then($DONE, $DONE);