tor-browser

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

yield-star-getiter-sync-not-callable-string-throw.js (2053B)


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