generator.js (504B)
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: 13.6.4.13 5 description: > 6 Generator function should return valid iterable objects. 7 features: [generators] 8 ---*/ 9 10 function* values() { 11 yield 2; 12 yield 4; 13 yield 8; 14 } 15 var iterable = values(); 16 var expected = [2, 4, 8]; 17 var i = 0; 18 19 for (var x of iterable) { 20 assert.sameValue(x, expected[i]); 21 i++; 22 } 23 24 assert.sameValue(i, 3); 25 26 reportCompare(0, 0);