tor-browser

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

yield-star-next-call-value-get-abrupt.js (1937B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/async-generators/yield-star-next-call-value-get-abrupt.case
      4 // - src/async-generators/default/async-declaration.template
      5 /*---
      6 description: Abrupt completion while getting value (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        iii. If generatorKind is async, then set innerResult to
     25             ? Await(innerResult).
     26        ...
     27        vi. If done is true, then
     28           1. Return ? IteratorValue(innerResult).
     29    ...
     30 
     31 ---*/
     32 var reason = {};
     33 var obj = {
     34  get [Symbol.iterator]() {
     35    throw new Test262Error('it should not get Symbol.iterator');
     36  },
     37  [Symbol.asyncIterator]() {
     38    return {
     39      next() {
     40        return {
     41          done: true,
     42          get value() {
     43            throw reason;
     44          }
     45        };
     46      }
     47    };
     48  }
     49 };
     50 
     51 
     52 
     53 var callCount = 0;
     54 
     55 async function *gen() {
     56  callCount += 1;
     57  yield* obj;
     58    throw new Test262Error('abrupt completion closes iter');
     59 
     60 }
     61 
     62 var iter = gen();
     63 
     64 iter.next().then(() => {
     65  throw new Test262Error('Promise incorrectly fulfilled.');
     66 }, v => {
     67  assert.sameValue(v, reason, "reject reason");
     68 
     69  iter.next().then(({ done, value }) => {
     70    assert.sameValue(done, true, 'the iterator is completed');
     71    assert.sameValue(value, undefined, 'value is undefined');
     72  }).then($DONE, $DONE);
     73 }).catch($DONE);
     74 
     75 assert.sameValue(callCount, 1);