tor-browser

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

async-gen-yield-identifier-non-strict.js (1172B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/async-generators/yield-identifier-non-strict.case
      4 // - src/async-generators/non-strict/async-obj-method.template
      5 /*---
      6 description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Generator method - valid for non-strict only cases)
      7 esid: prod-AsyncGeneratorMethod
      8 features: [async-iteration]
      9 flags: [generated, noStrict, async]
     10 info: |
     11    Async Generator Function Definitions
     12 
     13    AsyncGeneratorMethod :
     14      async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
     15 
     16 ---*/
     17 
     18 
     19 var callCount = 0;
     20 
     21 var gen = {
     22  async *method() {
     23    callCount += 1;
     24    return (function(arg) {
     25        var yield = arg + 1;
     26        return yield;
     27      }(yield))
     28  }
     29 }.method;
     30 
     31 var iter = gen();
     32 
     33 var item = iter.next();
     34 
     35 item.then(({ done, value }) => {
     36  assert.sameValue(done, false);
     37  assert.sameValue(value, undefined);
     38 });
     39 
     40 item = iter.next(42);
     41 
     42 item.then(({ done, value }) => {
     43  assert.sameValue(done, true);
     44  assert.sameValue(value, 43);
     45 }).then($DONE, $DONE);
     46 
     47 assert.sameValue(callCount, 1);