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 (960B)


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