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