tor-browser

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

yield-star-getiter-async-get-abrupt.js (2021B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/async-generators/yield-star-getiter-async-get-abrupt.case
      4 // - src/async-generators/default/async-class-expr-method.template
      5 /*---
      6 description: Abrupt completion while getting [Symbol.asyncIterator] (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      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    1. Let exprRef be the result of evaluating AssignmentExpression.
     26    2. Let value be ? GetValue(exprRef).
     27    3. Let generatorKind be ! GetGeneratorKind().
     28    4. Let iterator be ? GetIterator(value, generatorKind).
     29    ...
     30 
     31    GetIterator ( obj [ , hint ] )
     32 
     33    ...
     34    3. If hint is async,
     35      a. Set method to ? GetMethod(obj, @@asyncIterator).
     36    ...
     37 
     38    GetMethod ( V, P )
     39 
     40    ...
     41    2. Let func be ? GetV(V, P).
     42    ...
     43 
     44 ---*/
     45 var reason = {};
     46 var obj = {
     47  get [Symbol.iterator]() {
     48    throw new Test262Error('it should not get Symbol.iterator');
     49  },
     50  get [Symbol.asyncIterator]() {
     51    throw reason;
     52  }
     53 };
     54 
     55 
     56 
     57 var callCount = 0;
     58 
     59 var C = class { async *gen() {
     60    callCount += 1;
     61    yield* obj;
     62      throw new Test262Error('abrupt completion closes iter');
     63 
     64 }}
     65 
     66 var gen = C.prototype.gen;
     67 
     68 var iter = gen();
     69 
     70 iter.next().then(() => {
     71  throw new Test262Error('Promise incorrectly fulfilled.');
     72 }, v => {
     73  assert.sameValue(v, reason, "reject reason");
     74 
     75  iter.next().then(({ done, value }) => {
     76    assert.sameValue(done, true, 'the iterator is completed');
     77    assert.sameValue(value, undefined, 'value is undefined');
     78  }).then($DONE, $DONE);
     79 }).catch($DONE);
     80 
     81 assert.sameValue(callCount, 1);