tor-browser

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

yield-star-next-get-abrupt.js (1643B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/async-generators/yield-star-next-get-abrupt.case
      4 // - src/async-generators/default/async-declaration.template
      5 /*---
      6 description: Abrupt completion while getting next (Async generator Function declaration)
      7 esid: prod-AsyncGeneratorDeclaration
      8 features: [Symbol.iterator, Symbol.asyncIterator, async-iteration]
      9 flags: [generated, async]
     10 info: |
     11    Async Generator Function Definitions
     12 
     13    AsyncGeneratorDeclaration:
     14      async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) {
     15        AsyncGeneratorBody }
     16 
     17 
     18    YieldExpression: yield * AssignmentExpression
     19    ...
     20    6. Repeat
     21      a. If received.[[Type]] is normal, then
     22        ii. Let innerResult be ? Invoke(iterator, "next",
     23            « received.[[Value]] »).
     24    ...
     25 
     26 ---*/
     27 var reason = {};
     28 var obj = {
     29  get [Symbol.iterator]() {
     30    throw new Test262Error('it should not get Symbol.iterator');
     31  },
     32  [Symbol.asyncIterator]() {
     33    return {
     34      get next() {
     35        throw reason;
     36      }
     37    };
     38  }
     39 };
     40 
     41 
     42 
     43 var callCount = 0;
     44 
     45 async function *gen() {
     46  callCount += 1;
     47  yield* obj;
     48    throw new Test262Error('abrupt completion closes iter');
     49 
     50 }
     51 
     52 var iter = gen();
     53 
     54 iter.next().then(() => {
     55  throw new Test262Error('Promise incorrectly fulfilled.');
     56 }, v => {
     57  assert.sameValue(v, reason, "reject reason");
     58 
     59  iter.next().then(({ done, value }) => {
     60    assert.sameValue(done, true, 'the iterator is completed');
     61    assert.sameValue(value, undefined, 'value is undefined');
     62  }).then($DONE, $DONE);
     63 }).catch($DONE);
     64 
     65 assert.sameValue(callCount, 1);