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) 2006 |
| 20 * the Initial Developer. All Rights Reserved. |
| 21 * |
| 22 * Contributor(s): Jesse Ruderman |
| 23 * Brendan Eich |
| 24 * |
| 25 * Alternatively, the contents of this file may be used under the terms of |
| 26 * either the GNU General Public License Version 2 or later (the "GPL"), or |
| 27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
| 28 * in which case the provisions of the GPL or the LGPL are applicable instead |
| 29 * of those above. If you wish to allow use of your version of this file only |
| 30 * under the terms of either the GPL or the LGPL, and not to allow others to |
| 31 * use your version of this file under the terms of the MPL, indicate your |
| 32 * decision by deleting the provisions above and replace them with the notice |
| 33 * and other provisions required by the GPL or the LGPL. If you do not delete |
| 34 * the provisions above, a recipient may use your version of this file under |
| 35 * the terms of any one of the MPL, the GPL or the LGPL. |
| 36 * |
| 37 * ***** END LICENSE BLOCK ***** */ |
| 38 |
| 39 var gTestfile = 'regress-346642-01.js'; |
| 40 //----------------------------------------------------------------------------- |
| 41 var BUGNUMBER = 346642; |
| 42 var summary = 'decompilation of destructuring assignment'; |
| 43 var actual = ''; |
| 44 var expect = ''; |
| 45 |
| 46 |
| 47 //----------------------------------------------------------------------------- |
| 48 test(); |
| 49 //----------------------------------------------------------------------------- |
| 50 |
| 51 function test() |
| 52 { |
| 53 enterFunc ('test'); |
| 54 printBugNumber(BUGNUMBER); |
| 55 printStatus (summary); |
| 56 |
| 57 var f; |
| 58 |
| 59 f = function () {({a:{c:x}, b:x}) = ({b:3})} |
| 60 expect = 'function () {({a:{c:x}, b:x} = {b:3});}'; |
| 61 actual = f + ''; |
| 62 compareSource(expect, actual, summary + ': 1'); |
| 63 |
| 64 f = function() { for(; let (x=3,y=4) null;) { } } |
| 65 expect = 'function() { for(; let (x=3,y=4) null;) { } }'; |
| 66 actual = f + ''; |
| 67 compareSource(expect, actual, summary + ': 2'); |
| 68 |
| 69 f = function() { let (x=3,y=4) { } x = 5; } |
| 70 expect = 'function() { let (x=3,y=4) { } x = 5; }'; |
| 71 actual = f + ''; |
| 72 compareSource(expect, actual, summary + ': 3'); |
| 73 |
| 74 f = function () { for ([11].x;;) break; } |
| 75 expect = 'function () { for ([11].x;;) { break;} }'; |
| 76 actual = f + ''; |
| 77 compareSource(expect, actual, summary + ': 4'); |
| 78 |
| 79 f = function() { new ({ a: b } = c) } |
| 80 expect = 'function() { new ({ a: b } = c); }'; |
| 81 actual = f + ''; |
| 82 compareSource(expect, actual, summary + ': 5'); |
| 83 |
| 84 f = function () { (let (x) 3)(); } |
| 85 expect = 'function () { (let (x) 3)(); }'; |
| 86 actual = f + ''; |
| 87 compareSource(expect, actual, summary + ': 6'); |
| 88 |
| 89 f = function () { (let (x) 3).foo(); } |
| 90 expect = 'function () { (let (x) 3).foo(); }'; |
| 91 actual = f + ''; |
| 92 compareSource(expect, actual, summary + ': 7'); |
| 93 |
| 94 f = function () { ({x: a(b)}) = window; } |
| 95 expect = 'function () { ({x: a(b)} = window); }'; |
| 96 actual = f + ''; |
| 97 compareSource(expect, actual, summary + ': 8'); |
| 98 |
| 99 f = function() { let ([a]=x) { } } |
| 100 expect = 'function() { let ([a]=x) { } }'; |
| 101 actual = f + ''; |
| 102 compareSource(expect, actual, summary + ': 9'); |
| 103 |
| 104 f = function( ){ new ([x] = k) } |
| 105 expect = 'function( ){ new ([x] = k); }'; |
| 106 actual = f + ''; |
| 107 compareSource(expect, actual, summary + ': 10'); |
| 108 |
| 109 f = function() { [a] = [b] = c } |
| 110 expect = 'function() { [a] = [b] = c; }'; |
| 111 actual = f + ''; |
| 112 compareSource(expect, actual, summary + ': 11'); |
| 113 |
| 114 f = function() { [] = 3 } |
| 115 expect = 'function() { [] = 3; }'; |
| 116 actual = f + ''; |
| 117 compareSource(expect, actual, summary + ': 12'); |
| 118 |
| 119 f = function() { ({}) = 3 } |
| 120 expect = 'function() { [] = 3; }'; |
| 121 actual = f + ''; |
| 122 compareSource(expect, actual, summary + ': 13'); |
| 123 |
| 124 f = function () { while( {} = e ) ; } |
| 125 expect = 'function () { while( ( [] = e ) ) {} }'; |
| 126 actual = f + ''; |
| 127 compareSource(expect, actual, summary + ': 14'); |
| 128 |
| 129 f = function () { while( {} = (a)(b) ) ; } |
| 130 expect = 'function () { while( ( [] = a(b) ) ) {} }'; |
| 131 actual = f + ''; |
| 132 compareSource(expect, actual, summary + ': 15'); |
| 133 |
| 134 f = function (){[] = [a,b,c]} |
| 135 expect = 'function (){[] = [a,b,c];}'; |
| 136 actual = f + ''; |
| 137 compareSource(expect, actual, summary + ': 16'); |
| 138 |
| 139 f = function (){for([] = [a,b,c];;);} |
| 140 expect = 'function (){for([] = [a,b,c];;){}}'; |
| 141 actual = f + ''; |
| 142 compareSource(expect, actual, summary + ': 17'); |
| 143 |
| 144 f = function (){for(;;[] = [a,b,c]);} |
| 145 expect = 'function (){for(;;[] = [a,b,c]){}}'; |
| 146 actual = f + ''; |
| 147 compareSource(expect, actual, summary + ': 18'); |
| 148 |
| 149 f = function (){for(let [] = [a,b,c];;);} |
| 150 expect = 'function (){for(let [] = [a,b,c];;){}}'; |
| 151 actual = f + ''; |
| 152 compareSource(expect, actual, summary + ': 19'); |
| 153 |
| 154 f = function() { for (;; [x] = [1]) { } } |
| 155 expect = 'function() { for (;; [x] = [1]) { } } '; |
| 156 actual = f + ''; |
| 157 compareSource(expect, actual, summary + ': 20'); |
| 158 |
| 159 f = function() { [g['//']] = h } |
| 160 expect = 'function() { [g["//"]] = h; }'; |
| 161 actual = f + ''; |
| 162 compareSource(expect, actual, summary + ': 21'); |
| 163 |
| 164 f = (function() { for ( let [a,b]=[c,d] in [3]) { } }) |
| 165 expect = 'function() { [c, d]; for ( let [a,b] in [3]) { } }'; |
| 166 actual = f + ''; |
| 167 compareSource(expect, actual, summary + ': 22'); |
| 168 |
| 169 f = function () { while(1) [a] = [b]; } |
| 170 expect = 'function () { while(true) {[a] = [b];} } '; |
| 171 actual = f + ''; |
| 172 compareSource(expect, actual, summary + ': 23'); |
| 173 |
| 174 f = function () { for(var [x, y] = r in p) { } } |
| 175 expect = 'function () { var [x, y] = r; for( [x, y] in p) { } }'; |
| 176 actual = f + ''; |
| 177 compareSource(expect, actual, summary + ': 24'); |
| 178 |
| 179 f = function() { for([x] = [];;) { } } |
| 180 expect = 'function() { for([x] = [];;) { } }'; |
| 181 actual = f + ''; |
| 182 compareSource(expect, actual, summary + ': 25'); |
| 183 |
| 184 f = function () { let ([y] = delete [1]) { } } |
| 185 expect = 'function () { let ([y] = ([1], true)) { } }'; |
| 186 actual = f + ''; |
| 187 compareSource(expect, actual, summary + ': 26'); |
| 188 |
| 189 f = function () { delete 4..x } |
| 190 expect = 'function () { delete (4).x; }'; |
| 191 actual = f + ''; |
| 192 compareSource(expect, actual, summary + ': 27'); |
| 193 |
| 194 f = function() { return [({ x: y }) = p for (z in 5)] } |
| 195 expect = 'function() { return [{ x: y } = p for (z in 5)]; }'; |
| 196 actual = f + ''; |
| 197 compareSource(expect, actual, summary + ': 28'); |
| 198 |
| 199 exitFunc ('test'); |
| 200 } |
OLD | NEW |