tor-browser

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

expression-await-thenable-as-yield-operand.js (902B)


      1 // |reftest| async
      2 // Copyright 2017 the V8 project authors. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 author: Caitlin Potter <caitp@igalia.com>
      7 esid: sec-generator-function-definitions
      8 description: >
      9  AwaitExpressions are valid operands to yield expressions.
     10 flags: [async]
     11 features: [async-iteration]
     12 ---*/
     13 
     14 var thenable = {
     15  then: function(resolve, reject) {
     16    resolve("a");
     17  }
     18 };
     19 
     20 var iter = (async function*() {
     21  yield await thenable;
     22 })();
     23 
     24 iter.next().then(function(result) {
     25  assert.sameValue(result.value, "a", 'First result `value`');
     26  assert.sameValue(result.done, false, 'First result `done` flag');
     27 }).then(undefined, $DONE);
     28 
     29 iter.next().then(function(result) {
     30  assert.sameValue(result.value, undefined, 'Second result `value`');
     31  assert.sameValue(result.done, true, 'Second result `done` flag');
     32 }).then($DONE, $DONE);