tor-browser

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

named-dflt-ary-init-iter-no-close.js (1482B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/dstr-binding/ary-init-iter-no-close.case
      4 // - src/dstr-binding/default/async-gen-func-named-expr-dflt.template
      5 /*---
      6 description: Iterator is not closed when exhausted by pattern evaluation (async generator named function expression (default parameter))
      7 esid: sec-asyncgenerator-definitions-evaluation
      8 features: [Symbol.iterator, 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.5 Runtime Semantics: BindingInitialization
     21 
     22    BindingPattern : ArrayBindingPattern
     23 
     24    [...]
     25    4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator,
     26       result).
     27    [...]
     28 
     29 ---*/
     30 var doneCallCount = 0;
     31 var iter = {};
     32 iter[Symbol.iterator] = function() {
     33  return {
     34    next: function() {
     35      return { value: null, done: true };
     36    },
     37    return: function() {
     38      doneCallCount += 1;
     39      return {};
     40    }
     41  };
     42 };
     43 
     44 
     45 var callCount = 0;
     46 var f;
     47 f = async function* h([x] = iter) {
     48  assert.sameValue(doneCallCount, 0);
     49  callCount = callCount + 1;
     50 };
     51 
     52 f().next().then(() => {
     53    assert.sameValue(callCount, 1, 'invoked exactly once');
     54 }).then($DONE, $DONE);