1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_8/genexps/regress-667131.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +//----------------------------------------------------------------------------- 1.11 +var BUGNUMBER = 667131; 1.12 +var summary = 'yield ignored if maybeNoteLegacyGenerator called too late'; 1.13 +var actual = ''; 1.14 +var expect = ''; 1.15 + 1.16 +function testGenerator(f, desc) { 1.17 + reportCompare(f.isGenerator(), true, desc + ": is generator"); 1.18 + reportCompare(typeof f(), "object", desc + ": calling doesn't crash"); 1.19 +} 1.20 + 1.21 +function reported1() { 1.22 + (function(){})([yield[]], ("")) 1.23 +} 1.24 + 1.25 +function reported2() { 1.26 + (function(){})(let(w = "") yield, (e)) 1.27 +} 1.28 + 1.29 +function simplified1() { 1.30 + print([yield], (0)) 1.31 +} 1.32 + 1.33 +function simplified2() { 1.34 + print(let(w) yield, (0)) 1.35 +} 1.36 + 1.37 +function f1(a) { [x for (x in yield) for (y in (a))] } 1.38 +function f2(a) { [x for (x in yield) if (y in (a))] } 1.39 +function f3(a) { ([x for (x in yield) for (y in (a))]) } 1.40 +function f4(a) { ([x for (x in yield) if (y in (a))]) } 1.41 + 1.42 +function f7() { print({a:yield},(0)) } 1.43 + 1.44 +function f8() { ([yield], (0)) } 1.45 +function f9() { (let(w)yield, (0)) } 1.46 + 1.47 +testGenerator(reported1, "reported function with array literal"); 1.48 +testGenerator(reported2, "reported function with let-expression"); 1.49 +testGenerator(simplified1, "reported function with array literal, simplified"); 1.50 +testGenerator(simplified2, "reported function with let-expression, simplified"); 1.51 +testGenerator(f1, "top-level array comprehension with paren expr in for-block"); 1.52 +testGenerator(f2, "top-level array comprehension with paren expr in if-block"); 1.53 +testGenerator(f3, "parenthesized array comprehension with paren expr in for-block"); 1.54 +testGenerator(f4, "parenthesized array comprehension with paren expr in if-block"); 1.55 +testGenerator(f7, "object literal"); 1.56 +testGenerator(f8, "array literal in paren exp"); 1.57 +testGenerator(f9, "let-expression in paren exp");