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-get-abrupt.js (1874B)


      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-obj-method.template
      5 /*---
      6 description: Abrupt completion while getting [Symbol.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    ...
     31 
     32    GetMethod ( V, P )
     33 
     34    ...
     35    2. Let func be ? GetV(V, P).
     36    ...
     37 
     38 ---*/
     39 var reason = {};
     40 var obj = {
     41  get [Symbol.iterator]() {
     42    throw new Test262Error('it should not get Symbol.iterator');
     43  },
     44  get [Symbol.asyncIterator]() {
     45    throw reason;
     46  }
     47 };
     48 
     49 
     50 var callCount = 0;
     51 
     52 var gen = {
     53  async *method() {
     54    callCount += 1;
     55    yield* obj;
     56      throw new Test262Error('abrupt completion closes iter');
     57 
     58  }
     59 }.method;
     60 
     61 var iter = gen();
     62 
     63 iter.next().then(() => {
     64  throw new Test262Error('Promise incorrectly fulfilled.');
     65 }, v => {
     66  assert.sameValue(v, reason, "reject reason");
     67 
     68  iter.next().then(({ done, value }) => {
     69    assert.sameValue(done, true, 'the iterator is completed');
     70    assert.sameValue(value, undefined, 'value is undefined');
     71  }).then($DONE, $DONE);
     72 }).catch($DONE);
     73 
     74 assert.sameValue(callCount, 1);