OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 /* ***** BEGIN LICENSE BLOCK ***** |
| 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 4 * |
| 5 * The contents of this file are subject to the Mozilla Public License Version |
| 6 * 1.1 (the "License"); you may not use this file except in compliance with |
| 7 * the License. You may obtain a copy of the License at |
| 8 * http://www.mozilla.org/MPL/ |
| 9 * |
| 10 * Software distributed under the License is distributed on an "AS IS" basis, |
| 11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 12 * for the specific language governing rights and limitations under the |
| 13 * License. |
| 14 * |
| 15 * The Original Code is JavaScript Engine testing utilities. |
| 16 * |
| 17 * The Initial Developer of the Original Code is |
| 18 * Mozilla Foundation. |
| 19 * Portions created by the Initial Developer are Copyright (C) 2007 |
| 20 * the Initial Developer. All Rights Reserved. |
| 21 * |
| 22 * Contributor(s): Jesse Ruderman |
| 23 * |
| 24 * Alternatively, the contents of this file may be used under the terms of |
| 25 * either the GNU General Public License Version 2 or later (the "GPL"), or |
| 26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
| 27 * in which case the provisions of the GPL or the LGPL are applicable instead |
| 28 * of those above. If you wish to allow use of your version of this file only |
| 29 * under the terms of either the GPL or the LGPL, and not to allow others to |
| 30 * use your version of this file under the terms of the MPL, indicate your |
| 31 * decision by deleting the provisions above and replace them with the notice |
| 32 * and other provisions required by the GPL or the LGPL. If you do not delete |
| 33 * the provisions above, a recipient may use your version of this file under |
| 34 * the terms of any one of the MPL, the GPL or the LGPL. |
| 35 * |
| 36 * ***** END LICENSE BLOCK ***** */ |
| 37 |
| 38 var gTestfile = 'regress-380237-03.js'; |
| 39 |
| 40 //----------------------------------------------------------------------------- |
| 41 var BUGNUMBER = 380237; |
| 42 var summary = 'Decompilation of generator expressions'; |
| 43 var actual = ''; |
| 44 var expect = ''; |
| 45 |
| 46 |
| 47 //----------------------------------------------------------------------------- |
| 48 test(); |
| 49 //----------------------------------------------------------------------------- |
| 50 |
| 51 expect = 'No Error'; |
| 52 actual = ''; |
| 53 try |
| 54 { |
| 55 var g = ((yield i) for (i in [1,2,3])); |
| 56 actual = 'No Error'; |
| 57 } |
| 58 catch(ex) |
| 59 { |
| 60 actual = ex + ''; |
| 61 } |
| 62 reportCompare(expect, actual, summary + ': top level'); |
| 63 |
| 64 |
| 65 function test() |
| 66 { |
| 67 enterFunc ('test'); |
| 68 printBugNumber(BUGNUMBER); |
| 69 printStatus (summary); |
| 70 |
| 71 var f = (function() { g = (d for (d in [0]) for (e in [1])); }); |
| 72 expect = 'function() { g = (d for (d in [0]) for (e in [1])); }'; |
| 73 actual = f + ''; |
| 74 compareSource(expect, actual, summary + ': see bug 380506'); |
| 75 |
| 76 f = function() { return (1 for (i in [])) }; |
| 77 expect = 'function() { return (1 for (i in [])); }'; |
| 78 actual = f + ''; |
| 79 compareSource(expect, actual, summary); |
| 80 |
| 81 f = function() { with((x for (x in []))) { } }; |
| 82 expect = 'function() { with(x for (x in [])) { } }'; |
| 83 actual = f + ''; |
| 84 compareSource(expect, actual, summary); |
| 85 |
| 86 f = (function() { (1 for (w in []) if (0)) }); |
| 87 expect = 'function() { (1 for (w in []) if (false)); }'; |
| 88 actual = f + ''; |
| 89 compareSource(expect, actual, summary); |
| 90 |
| 91 f = (function() { (1 for (w in []) if (x)) }); |
| 92 expect = 'function() { (1 for (w in []) if (x)); }'; |
| 93 actual = f + ''; |
| 94 compareSource(expect, actual, summary); |
| 95 |
| 96 f = (function() { (1 for (w in []) if (1)) }); |
| 97 expect = 'function() { (1 for (w in []) ); }'; |
| 98 actual = f + ''; |
| 99 compareSource(expect, actual, summary); |
| 100 |
| 101 f = (function() { (x for ([{}, {}] in [])); }); |
| 102 expect = 'function() { (x for ([[], []] in [])); }'; |
| 103 actual = f + ''; |
| 104 compareSource(expect, actual, summary); |
| 105 |
| 106 expect = 'SyntaxError: invalid assignment left-hand side'; |
| 107 actual = ''; |
| 108 try |
| 109 { |
| 110 eval('(function() { (x for each (x in [])) = 3; })'); |
| 111 } |
| 112 catch(ex) |
| 113 { |
| 114 actual = ex + ''; |
| 115 } |
| 116 reportCompare(expect, actual, summary + ': Do not Assert: *pc == JSOP_CALL'); |
| 117 |
| 118 f = (function() { (x*x for (x in a)); }); |
| 119 expect = 'function() { (x*x for (x in a)); }'; |
| 120 actual = f + ''; |
| 121 compareSource(expect, actual, summary); |
| 122 |
| 123 f = (function () { (1 for (y in (yield 3))); }); |
| 124 expect = 'function () { (1 for (y in yield 3)); }'; |
| 125 actual = f + ''; |
| 126 compareSource(expect, actual, summary); |
| 127 |
| 128 expect = 'SyntaxError: invalid delete operand'; |
| 129 try |
| 130 { |
| 131 eval('(function () { delete (x for (x in [])); })'); |
| 132 } |
| 133 catch(ex) |
| 134 { |
| 135 actual = ex + ''; |
| 136 } |
| 137 reportCompare(expect, actual, summary + ': Do not Assert: *pc == JSOP_CALL'); |
| 138 |
| 139 f = (function() { ([yield] for (x in [])); }); |
| 140 expect = 'function() { ([(yield)] for (x in [])); }'; |
| 141 actual = f + ''; |
| 142 compareSource(expect, actual, summary); |
| 143 |
| 144 f = function() { if(1, (x for (x in []))) { } }; |
| 145 expect = 'function() { if(1, (x for (x in []))) { } }'; |
| 146 actual = f + ''; |
| 147 compareSource(expect, actual, summary); |
| 148 |
| 149 f = function () {return(i*j for each (i in [1,2,3,4]) |
| 150 for each (j in [5,6,7,8]))}; |
| 151 expect = 'function () {return(i*j for each (i in [1,2,3,4]) ' + |
| 152 'for each (j in [5,6,7,8]));}'; |
| 153 actual = f + ''; |
| 154 compareSource(expect, actual, summary); |
| 155 |
| 156 expect = 'No Error'; |
| 157 actual = ''; |
| 158 try |
| 159 { |
| 160 var g = ((yield i) for (i in [1,2,3])); |
| 161 actual = 'No Error'; |
| 162 } |
| 163 catch(ex) |
| 164 { |
| 165 actual = ex + ''; |
| 166 } |
| 167 reportCompare(expect, actual, summary + ': nested'); |
| 168 |
| 169 f = function() { try { } catch(x if (1 for (x in []))) { } finally { } }; |
| 170 expect = 'function() { try {} catch(x if (1 for (x in []))) {} finally {} }'; |
| 171 actual = f + ''; |
| 172 compareSource(expect, actual, summary); |
| 173 |
| 174 f = eval(uneval(f)); |
| 175 expect = 'function() { try {} catch(x if (1 for (x in []))) {} finally {} }'; |
| 176 actual = f + ''; |
| 177 compareSource(expect, actual, summary + ': eval(uneval())'); |
| 178 |
| 179 f = function() { if (1, (x for (x in []))) { } }; |
| 180 expect = 'function() { if (1, (x for (x in []))) { } }'; |
| 181 actual = f + ''; |
| 182 compareSource(expect, actual, summary); |
| 183 |
| 184 f = function() { ((a, b) for (x in [])) }; |
| 185 expect = 'function() { ((a, b) for (x in [])); }'; |
| 186 actual = f + ''; |
| 187 compareSource(expect, actual, summary); |
| 188 |
| 189 f = (function() { ({x setter: (function () {}).x }) }); |
| 190 expect = 'function() { ({x setter: function () {}.x }); }'; |
| 191 actual = f + ''; |
| 192 compareSource(expect, actual, summary); |
| 193 |
| 194 exitFunc ('test'); |
| 195 } |
OLD | NEW |