tor-browser

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

invoked-as-function-single-argument.js (1013B)


      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 a single argument,
      8    the AsyncGeneratorFunction intrinsic creates a valid async generator whose body is the
      9    first argument evaluated as source code.
     10 features: [async-iteration]
     11 flags: [async]
     12 ---*/
     13 
     14 var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor;
     15 
     16 var g = AsyncGeneratorFunction('yield 1;');
     17 var iter = g();
     18 var result;
     19 
     20 
     21 iter.next().then(function(result) {
     22  assert.sameValue(result.value, 1, 'First result `value`');
     23  assert.sameValue(result.done, false, 'First result `done` flag');
     24 }).then(undefined, $DONE)
     25 
     26 iter.next().then(function(result) {
     27  assert.sameValue(result.value, undefined, 'Final result `value`');
     28  assert.sameValue(result.done, true, 'Final result `done` flag');
     29 }).then($DONE, $DONE)