tor-browser

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

yield-star-next-not-callable-symbol-throw.js (1649B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/async-generators/yield-star-next-not-callable-symbol-throw.case
      4 // - src/async-generators/default/async-declaration.template
      5 /*---
      6 description: Not-callable next value in a yield star position - symbol (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 obj = {
     28  get [Symbol.iterator]() {
     29    throw new Test262Error('it should not get Symbol.iterator');
     30  },
     31  [Symbol.asyncIterator]() {
     32    return {
     33      next: Symbol('oi')
     34    };
     35  }
     36 };
     37 
     38 
     39 
     40 var callCount = 0;
     41 
     42 async function *gen() {
     43  callCount += 1;
     44  yield* obj;
     45    throw new Test262Error('abrupt completion closes iter');
     46 
     47 }
     48 
     49 var iter = gen();
     50 
     51 iter.next().then(() => {
     52  throw new Test262Error('Promise incorrectly fulfilled.');
     53 }, v => {
     54  assert.sameValue(v.constructor, TypeError, "TypeError");
     55 
     56  iter.next().then(({ done, value }) => {
     57    assert.sameValue(done, true, 'the iterator is completed');
     58    assert.sameValue(value, undefined, 'value is undefined');
     59  }).then($DONE, $DONE);
     60 }).catch($DONE);
     61 
     62 assert.sameValue(callCount, 1);