| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-380237-03.js'; |
| 7 |
|
| 8 |
|
| 9 |
var BUGNUMBER = 380237; |
| 10 |
var summary = 'Decompilation of generator expressions'; |
| 11 |
var actual = ''; |
| 12 |
var expect = ''; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
test(); |
| 17 |
|
| 18 |
|
| 19 |
expect = 'No Error'; |
| 20 |
actual = ''; |
| 21 |
try |
| 22 |
{ |
| 23 |
var g = ((yield i) for (i in [1,2,3])); |
| 24 |
actual = 'No Error'; |
| 25 |
} |
| 26 |
catch(ex) |
| 27 |
{ |
| 28 |
actual = ex + ''; |
| 29 |
} |
| 30 |
reportCompare(expect, actual, summary + ': top level'); |
| 31 |
|
| 32 |
|
| 33 |
function test() |
| 34 |
{ |
| 35 |
enterFunc ('test'); |
| 36 |
printBugNumber(BUGNUMBER); |
| 37 |
printStatus (summary); |
| 38 |
|
| 39 |
var f = (function() { g = (d for (d in [0]) for (e in [1])); }); |
| 40 |
expect = 'function() { g = (d for (d in [0]) for (e in [1])); }'; |
| 41 |
actual = f + ''; |
| 42 |
compareSource(expect, actual, summary + ': see bug 380506'); |
| 43 |
|
| 44 |
f = function() { return (1 for (i in [])) }; |
| 45 |
expect = 'function() { return (1 for (i in [])); }'; |
| 46 |
actual = f + ''; |
| 47 |
compareSource(expect, actual, summary); |
| 48 |
|
| 49 |
f = function() { with((x for (x in []))) { } }; |
| 50 |
expect = 'function() { with(x for (x in [])) { } }'; |
| 51 |
actual = f + ''; |
| 52 |
compareSource(expect, actual, summary); |
| 53 |
|
| 54 |
f = (function() { (1 for (w in []) if (0)) }); |
| 55 |
expect = 'function() { (1 for (w in []) if (0)); }'; |
| 56 |
actual = f + ''; |
| 57 |
compareSource(expect, actual, summary); |
| 58 |
|
| 59 |
f = (function() { (1 for (w in []) if (x)) }); |
| 60 |
expect = 'function() { (1 for (w in []) if (x)); }'; |
| 61 |
actual = f + ''; |
| 62 |
compareSource(expect, actual, summary); |
| 63 |
|
| 64 |
f = (function() { (1 for (w in []) if (1)) }); |
| 65 |
expect = 'function() { (1 for (w in []) ); }'; |
| 66 |
actual = f + ''; |
| 67 |
compareSource(expect, actual, summary); |
| 68 |
|
| 69 |
f = (function() { (x for ([{}, {}] in [])); }); |
| 70 |
expect = 'function() { (x for ([[], []] in [])); }'; |
| 71 |
actual = f + ''; |
| 72 |
compareSource(expect, actual, summary); |
| 73 |
|
| 74 |
expect = 'SyntaxError: invalid assignment left-hand side'; |
| 75 |
actual = ''; |
| 76 |
try |
| 77 |
{ |
| 78 |
eval('(function() { (x for each (x in [])) = 3; })'); |
| 79 |
} |
| 80 |
catch(ex) |
| 81 |
{ |
| 82 |
actual = ex + ''; |
| 83 |
} |
| 84 |
reportCompare(expect, actual, summary + ': Do not Assert: *pc == JSOP_CALL'); |
| 85 |
|
| 86 |
f = (function() { (x*x for (x in a)); }); |
| 87 |
expect = 'function() { (x*x for (x in a)); }'; |
| 88 |
actual = f + ''; |
| 89 |
compareSource(expect, actual, summary); |
| 90 |
|
| 91 |
f = (function () { (1 for (y in (yield 3))); }); |
| 92 |
expect = 'function () { (1 for (y in yield 3)); }'; |
| 93 |
actual = f + ''; |
| 94 |
compareSource(expect, actual, summary); |
| 95 |
|
| 96 |
expect = 'SyntaxError: invalid delete operand'; |
| 97 |
try |
| 98 |
{ |
| 99 |
eval('(function () { delete (x for (x in [])); })'); |
| 100 |
} |
| 101 |
catch(ex) |
| 102 |
{ |
| 103 |
actual = ex + ''; |
| 104 |
} |
| 105 |
reportCompare(expect, actual, summary + ': Do not Assert: *pc == JSOP_CALL'); |
| 106 |
|
| 107 |
f = (function() { ([yield] for (x in [])); }); |
| 108 |
expect = 'function() { ([yield] for (x in [])); }'; |
| 109 |
actual = f + ''; |
| 110 |
compareSource(expect, actual, summary); |
| 111 |
|
| 112 |
f = function() { if(1, (x for (x in []))) { } }; |
| 113 |
expect = 'function() { if(1, (x for (x in []))) { } }'; |
| 114 |
actual = f + ''; |
| 115 |
compareSource(expect, actual, summary); |
| 116 |
|
| 117 |
f = function () {return(i*j for each (i in [1,2,3,4]) |
| 118 |
for each (j in [5,6,7,8]))}; |
| 119 |
expect = 'function () {return(i*j for each (i in [1,2,3,4]) ' + |
| 120 |
'for each (j in [5,6,7,8]));}'; |
| 121 |
actual = f + ''; |
| 122 |
compareSource(expect, actual, summary); |
| 123 |
|
| 124 |
expect = 'No Error'; |
| 125 |
actual = ''; |
| 126 |
try |
| 127 |
{ |
| 128 |
var g = ((yield i) for (i in [1,2,3])); |
| 129 |
actual = 'No Error'; |
| 130 |
} |
| 131 |
catch(ex) |
| 132 |
{ |
| 133 |
actual = ex + ''; |
| 134 |
} |
| 135 |
reportCompare(expect, actual, summary + ': nested'); |
| 136 |
|
| 137 |
f = function() { try { } catch(x if (1 for (x in []))) { } finally { } }; |
| 138 |
expect = 'function() { try {} catch(x if (1 for (x in []))) {} finally {} }'; |
| 139 |
actual = f + ''; |
| 140 |
compareSource(expect, actual, summary); |
| 141 |
|
| 142 |
f = eval(uneval(f)); |
| 143 |
expect = 'function() { try {} catch(x if (1 for (x in []))) {} finally {} }'; |
| 144 |
actual = f + ''; |
| 145 |
compareSource(expect, actual, summary + ': eval(uneval())'); |
| 146 |
|
| 147 |
f = function() { if (1, (x for (x in []))) { } }; |
| 148 |
expect = 'function() { if (1, (x for (x in []))) { } }'; |
| 149 |
actual = f + ''; |
| 150 |
compareSource(expect, actual, summary); |
| 151 |
|
| 152 |
f = function() { ((a, b) for (x in [])) }; |
| 153 |
expect = 'function() { ((a, b) for (x in [])); }'; |
| 154 |
actual = f + ''; |
| 155 |
compareSource(expect, actual, summary); |
| 156 |
|
| 157 |
f = (function() { ({x setter: (function () {}).x }) }); |
| 158 |
expect = 'function() { ({x setter: function () {}.x }); }'; |
| 159 |
actual = f + ''; |
| 160 |
compareSource(expect, actual, summary); |
| 161 |
|
| 162 |
exitFunc ('test'); |
| 163 |
} |