tor-browser

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

yield-star-next-not-callable-boolean-throw.js (1793B)


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