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-symbol-throw.js (1960B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/async-generators/yield-star-getiter-sync-not-callable-symbol-throw.case
      4 // - src/async-generators/default/async-expression.template
      5 /*---
      6 description: Throws a TypeError on a non-callable [Symbol.iterator] (symbol) (Unnamed async generator expression)
      7 esid: prod-AsyncGeneratorExpression
      8 features: [Symbol.iterator, Symbol.asyncIterator, async-iteration]
      9 flags: [generated, async]
     10 info: |
     11    Async Generator Function Definitions
     12 
     13    AsyncGeneratorExpression :
     14      async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) {
     15        AsyncGeneratorBody }
     16 
     17 
     18    YieldExpression: yield * AssignmentExpression
     19 
     20    1. Let exprRef be the result of evaluating AssignmentExpression.
     21    2. Let value be ? GetValue(exprRef).
     22    3. Let generatorKind be ! GetGeneratorKind().
     23    4. Let iterator be ? GetIterator(value, generatorKind).
     24    ...
     25 
     26    GetIterator ( obj [ , hint ] )
     27 
     28    ...
     29    3. If hint is async,
     30      a. Set method to ? GetMethod(obj, @@asyncIterator).
     31      b. If method is undefined,
     32        i. Let syncMethod be ? GetMethod(obj, @@iterator).
     33    ...
     34 
     35    GetMethod ( V, P )
     36 
     37    ...
     38    2. Let func be ? GetV(V, P).
     39    ...
     40    4. If IsCallable(func) is false, throw a TypeError exception.
     41    ...
     42 
     43 ---*/
     44 var obj = {
     45  [Symbol.iterator]: Symbol.iterator
     46 };
     47 
     48 
     49 
     50 var callCount = 0;
     51 
     52 var gen = async function *() {
     53  callCount += 1;
     54  yield* obj;
     55    throw new Test262Error('abrupt completion closes iter');
     56 
     57 };
     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);