tor-browser

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

async-gen-yield-star-getiter-sync-not-callable-object-throw.js (1906B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/async-generators/yield-star-getiter-sync-not-callable-object-throw.case
      4 // - src/async-generators/default/async-obj-method.template
      5 /*---
      6 description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Async generator method)
      7 esid: prod-AsyncGeneratorMethod
      8 features: [Symbol.iterator, 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    4. If IsCallable(func) is false, throw a TypeError exception.
     40    ...
     41 
     42 ---*/
     43 var obj = {
     44  [Symbol.iterator]: {}
     45 };
     46 
     47 
     48 var callCount = 0;
     49 
     50 var gen = {
     51  async *method() {
     52    callCount += 1;
     53    yield* obj;
     54      throw new Test262Error('abrupt completion closes iter');
     55 
     56  }
     57 }.method;
     58 
     59 var iter = gen();
     60 
     61 iter.next().then(() => {
     62  throw new Test262Error('Promise incorrectly fulfilled.');
     63 }, v => {
     64  assert.sameValue(v.constructor, TypeError, "TypeError");
     65 
     66  iter.next().then(({ done, value }) => {
     67    assert.sameValue(done, true, 'the iterator is completed');
     68    assert.sameValue(value, undefined, 'value is undefined');
     69  }).then($DONE, $DONE);
     70 }).catch($DONE);
     71 
     72 assert.sameValue(callCount, 1);