tor-browser

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

async-func-dstr-let-obj-ptrn-rest-skip-non-enumerable.js (2100B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case
      4 // - src/dstr-binding-for-await/default/for-await-of-async-func-let.template
      5 /*---
      6 description: Rest object doesn't contain non-enumerable properties (for-await-of statement)
      7 esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
      8 features: [object-rest, destructuring-binding, async-iteration]
      9 flags: [generated, async]
     10 includes: [propertyHelper.js]
     11 info: |
     12    IterationStatement :
     13        for await ( ForDeclaration of AssignmentExpression ) Statement
     14 
     15    [...]
     16    2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult,
     17        lexicalBinding, labelSet, async).
     18 
     19    13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
     20 
     21    [...]
     22    4. Let destructuring be IsDestructuring of lhs.
     23    [...]
     24    6. Repeat
     25       [...]
     26       j. If destructuring is false, then
     27          [...]
     28       k. Else
     29          i. If lhsKind is assignment, then
     30             [...]
     31          ii. Else if lhsKind is varBinding, then
     32              [...]
     33          iii. Else,
     34               1. Assert: lhsKind is lexicalBinding.
     35               2. Assert: lhs is a ForDeclaration.
     36               3. Let status be the result of performing BindingInitialization
     37                  for lhs passing nextValue and iterationEnv as arguments.
     38          [...]
     39 ---*/
     40 var o = {a: 3, b: 4};
     41 Object.defineProperty(o, "x", { value: 4, enumerable: false });
     42 
     43 var iterCount = 0;
     44 
     45 async function fn() {
     46  for await (let {...rest} of [o]) {
     47    assert.sameValue(rest.a, 3);
     48    assert.sameValue(rest.b, 4);
     49    assert.sameValue(rest.x, undefined);
     50 
     51    verifyProperty(rest, "a", {
     52      enumerable: true,
     53      writable: true,
     54      configurable: true,
     55      value: 3
     56    });
     57 
     58    verifyProperty(rest, "b", {
     59      enumerable: true,
     60      writable: true,
     61      configurable: true,
     62      value: 4
     63    });
     64 
     65    iterCount += 1;
     66  }
     67 }
     68 
     69 fn()
     70  .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
     71  .then($DONE, $DONE);