tor-browser

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

invoked-as-function-multiple-arguments.js (1083B)


      1 // |reftest| async
      2 // Copyright (C) 2018 Valerie Young. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 /*---
      5 esid: sec-asyncgeneratorfunction
      6 description: >
      7    When invoked via the function invocation pattern with multiple arguments,
      8    the AsyncGeneratorFunction intrinsic creates a valid generator whose body is the
      9    last argument evaluated as source code and whose formal parameters are
     10    defined by the preceding arguments.
     11 features: [async-iteration]
     12 flags: [async]
     13 ---*/
     14 
     15 var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor;
     16 
     17 var g = AsyncGeneratorFunction('x', 'y', 'yield x + y;');
     18 var iter = g(2, 3);
     19 
     20 iter.next().then(function(result) {
     21  assert.sameValue(result.value, 5, 'First result `value`');
     22  assert.sameValue(result.done, false, 'First result `done` flag');
     23 }).then(undefined, $DONE)
     24 
     25 iter.next().then(function(result) {
     26  assert.sameValue(result.value, undefined, 'Final result `value`');
     27  assert.sameValue(result.done, true, 'Final result `done` flag');
     28 }).then($DONE, $DONE)