nested-yield.js (937B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 //----------------------------------------------------------------------------- 7 var summary = "YieldExpression is and contains an AssignmentExpression"; 8 var actual, expect; 9 10 printStatus(summary); 11 12 /************** 13 * BEGIN TEST * 14 **************/ 15 16 var failed = false; 17 18 function* gen() 19 { 20 yield (yield (yield 7)); 21 } 22 23 var it = gen(); 24 25 try 26 { 27 if (it.next().value != 7) 28 throw "7 not yielded"; 29 if (it.next(17).value != 17) 30 throw "passed-in 17 not yielded"; 31 if (it.next(undefined).value !== undefined) 32 throw "should be able to yield undefined"; 33 34 it.next(); 35 } 36 catch (e) 37 { 38 failed = e; 39 } 40 41 expect = false; 42 actual = failed; 43 44 reportCompare(expect, actual, summary);