tor-browser

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

async-gen-yield-star-getiter-async-null-sync-get-abrupt.js (2004B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case
      4 // - src/async-generators/default/async-obj-method.template
      5 /*---
      6 description: Abrupt completion while getting @@iterator after null @@asyncIterator (Async generator method)
      7 esid: prod-AsyncGeneratorMethod
      8 features: [Symbol.iterator, Symbol.asyncIterator, async-iteration]
      9 flags: [generated, async]
     10 info: |
     11    Async Generator Function Definitions
     12 
     13    AsyncGeneratorMethod :
     14      async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
     15 
     16 
     17    YieldExpression: yield * AssignmentExpression
     18 
     19    1. Let exprRef be the result of evaluating AssignmentExpression.
     20    2. Let value be ? GetValue(exprRef).
     21    3. Let generatorKind be ! GetGeneratorKind().
     22    4. Let iterator be ? GetIterator(value, generatorKind).
     23    ...
     24 
     25    GetIterator ( obj [ , hint ] )
     26 
     27    ...
     28    3. If hint is async,
     29      a. Set method to ? GetMethod(obj, @@asyncIterator).
     30      b. If method is undefined,
     31        i. Let syncMethod be ? GetMethod(obj, @@iterator).
     32    ...
     33 
     34    GetMethod ( V, P )
     35 
     36    ...
     37    2. Let func be ? GetV(V, P).
     38    ...
     39 
     40 ---*/
     41 var calls = 0;
     42 var reason = {};
     43 var obj = {
     44  get [Symbol.iterator]() {
     45    throw reason;
     46  },
     47  get [Symbol.asyncIterator]() {
     48    calls += 1;
     49    return null;
     50  }
     51 };
     52 
     53 
     54 var callCount = 0;
     55 
     56 var gen = {
     57  async *method() {
     58    callCount += 1;
     59    yield* obj;
     60      throw new Test262Error('abrupt completion closes iter');
     61 
     62  }
     63 }.method;
     64 
     65 var iter = gen();
     66 
     67 iter.next().then(() => {
     68  throw new Test262Error('Promise incorrectly fulfilled.');
     69 }, v => {
     70  assert.sameValue(v, reason, 'reject reason');
     71  assert.sameValue(calls, 1);
     72 
     73  iter.next().then(({ done, value }) => {
     74    assert.sameValue(done, true, 'the iterator is completed');
     75    assert.sameValue(value, undefined, 'value is undefined');
     76  }).then($DONE, $DONE);
     77 }).catch($DONE);
     78 
     79 assert.sameValue(callCount, 1);