|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 //----------------------------------------------------------------------------- |
|
8 var BUGNUMBER = 667131; |
|
9 var summary = 'yield ignored if maybeNoteLegacyGenerator called too late'; |
|
10 var actual = ''; |
|
11 var expect = ''; |
|
12 |
|
13 function testGenerator(f, desc) { |
|
14 reportCompare(f.isGenerator(), true, desc + ": is generator"); |
|
15 reportCompare(typeof f(), "object", desc + ": calling doesn't crash"); |
|
16 } |
|
17 |
|
18 function reported1() { |
|
19 (function(){})([yield[]], ("")) |
|
20 } |
|
21 |
|
22 function reported2() { |
|
23 (function(){})(let(w = "") yield, (e)) |
|
24 } |
|
25 |
|
26 function simplified1() { |
|
27 print([yield], (0)) |
|
28 } |
|
29 |
|
30 function simplified2() { |
|
31 print(let(w) yield, (0)) |
|
32 } |
|
33 |
|
34 function f1(a) { [x for (x in yield) for (y in (a))] } |
|
35 function f2(a) { [x for (x in yield) if (y in (a))] } |
|
36 function f3(a) { ([x for (x in yield) for (y in (a))]) } |
|
37 function f4(a) { ([x for (x in yield) if (y in (a))]) } |
|
38 |
|
39 function f7() { print({a:yield},(0)) } |
|
40 |
|
41 function f8() { ([yield], (0)) } |
|
42 function f9() { (let(w)yield, (0)) } |
|
43 |
|
44 testGenerator(reported1, "reported function with array literal"); |
|
45 testGenerator(reported2, "reported function with let-expression"); |
|
46 testGenerator(simplified1, "reported function with array literal, simplified"); |
|
47 testGenerator(simplified2, "reported function with let-expression, simplified"); |
|
48 testGenerator(f1, "top-level array comprehension with paren expr in for-block"); |
|
49 testGenerator(f2, "top-level array comprehension with paren expr in if-block"); |
|
50 testGenerator(f3, "parenthesized array comprehension with paren expr in for-block"); |
|
51 testGenerator(f4, "parenthesized array comprehension with paren expr in if-block"); |
|
52 testGenerator(f7, "object literal"); |
|
53 testGenerator(f8, "array literal in paren exp"); |
|
54 testGenerator(f9, "let-expression in paren exp"); |