tor-browser

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

async-gen-yield-star-expr-abrupt.js (1367B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/async-generators/yield-star-expr-abrupt.case
      4 // - src/async-generators/default/async-obj-method.template
      5 /*---
      6 description: Abrupt completion while getting yield* operand (Async generator method)
      7 esid: prod-AsyncGeneratorMethod
      8 features: [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    ...
     22 
     23 ---*/
     24 var obj = {};
     25 var abrupt = function() {
     26  throw obj;
     27 };
     28 
     29 
     30 var callCount = 0;
     31 
     32 var gen = {
     33  async *method() {
     34    callCount += 1;
     35    yield* abrupt();
     36      throw new Test262Error('abrupt completion closes iter');
     37 
     38  }
     39 }.method;
     40 
     41 var iter = gen();
     42 
     43 iter.next().then(() => {
     44  throw new Test262Error('Promise incorrectly fulfilled.');
     45 }, v => {
     46  assert.sameValue(v, obj, "reject reason");
     47 
     48  iter.next().then(({ done, value }) => {
     49    assert.sameValue(done, true, 'the iterator is completed');
     50    assert.sameValue(value, undefined, 'value is undefined');
     51  }).then($DONE, $DONE);
     52 }).catch($DONE);
     53 
     54 assert.sameValue(callCount, 1);