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
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/
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
15 * The Original Code is JavaScript Engine testing utilities.
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2006
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s): Jesse Ruderman
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.
37 * ***** END LICENSE BLOCK ***** */
39 var gTestfile
= 'regress-346642-01.js';
40 //-----------------------------------------------------------------------------
41 var BUGNUMBER
= 346642;
42 var summary
= 'decompilation of destructuring assignment';
47 //-----------------------------------------------------------------------------
49 //-----------------------------------------------------------------------------
54 printBugNumber(BUGNUMBER
);
55 printStatus (summary
);
59 f = function () {({a
:{c
:x
}, b
:x
}) = ({b
:3})}
60 expect
= 'function () {({a:{c:x}, b:x} = {b:3});}';
62 compareSource(expect
, actual
, summary
+ ': 1');
64 f = function() { for(; let (x
=3,y
=4) null;) { } }
65 expect
= 'function() { for(; let (x=3,y=4) null;) { } }';
67 compareSource(expect
, actual
, summary
+ ': 2');
69 f = function() { let (x
=3,y
=4) { } x
= 5; }
70 expect
= 'function() { let (x=3,y=4) { } x = 5; }';
72 compareSource(expect
, actual
, summary
+ ': 3');
74 f = function () { for ([11].x
;;) break; }
75 expect
= 'function () { for ([11].x;;) { break;} }';
77 compareSource(expect
, actual
, summary
+ ': 4');
79 f = function() { new ({ a
: b
} = c
) }
80 expect
= 'function() { new ({ a: b } = c); }';
82 compareSource(expect
, actual
, summary
+ ': 5');
84 f = function () { (let (x
) 3)(); }
85 expect
= 'function () { (let (x) 3)(); }';
87 compareSource(expect
, actual
, summary
+ ': 6');
89 f = function () { (let (x
) 3).foo(); }
90 expect
= 'function () { (let (x) 3).foo(); }';
92 compareSource(expect
, actual
, summary
+ ': 7');
94 f = function () { ({x
: a(b
)}) = window
; }
95 expect
= 'function () { ({x: a(b)} = window); }';
97 compareSource(expect
, actual
, summary
+ ': 8');
99 f = function() { let ([a
]=x
) { } }
100 expect
= 'function() { let ([a]=x) { } }';
102 compareSource(expect
, actual
, summary
+ ': 9');
104 f = function( ){ new ([x
] = k
) }
105 expect
= 'function( ){ new ([x] = k); }';
107 compareSource(expect
, actual
, summary
+ ': 10');
109 f = function() { [a
] = [b
] = c
}
110 expect
= 'function() { [a] = [b] = c; }';
112 compareSource(expect
, actual
, summary
+ ': 11');
114 f = function() { [] = 3 }
115 expect
= 'function() { [] = 3; }';
117 compareSource(expect
, actual
, summary
+ ': 12');
119 f = function() { ({}) = 3 }
120 expect
= 'function() { [] = 3; }';
122 compareSource(expect
, actual
, summary
+ ': 13');
124 f = function () { while( {} = e
) ; }
125 expect
= 'function () { while( ( [] = e ) ) {} }';
127 compareSource(expect
, actual
, summary
+ ': 14');
129 f = function () { while( {} = (a
)(b
) ) ; }
130 expect
= 'function () { while( ( [] = a(b) ) ) {} }';
132 compareSource(expect
, actual
, summary
+ ': 15');
134 f = function (){[] = [a
,b
,c
]}
135 expect
= 'function (){[] = [a,b,c];}';
137 compareSource(expect
, actual
, summary
+ ': 16');
139 f = function (){for([] = [a
,b
,c
];;);}
140 expect
= 'function (){for([] = [a,b,c];;){}}';
142 compareSource(expect
, actual
, summary
+ ': 17');
144 f = function (){for(;;[] = [a
,b
,c
]);}
145 expect
= 'function (){for(;;[] = [a,b,c]){}}';
147 compareSource(expect
, actual
, summary
+ ': 18');
149 f = function (){for(let [] = [a
,b
,c
];;);}
150 expect
= 'function (){for(let [] = [a,b,c];;){}}';
152 compareSource(expect
, actual
, summary
+ ': 19');
154 f = function() { for (;; [x
] = [1]) { } }
155 expect
= 'function() { for (;; [x] = [1]) { } } ';
157 compareSource(expect
, actual
, summary
+ ': 20');
159 f = function() { [g
['//']] = h
}
160 expect
= 'function() { [g["//"]] = h; }';
162 compareSource(expect
, actual
, summary
+ ': 21');
164 f
= (function() { for ( let [a
,b
]=[c
,d
] in [3]) { } })
165 expect
= 'function() { [c, d]; for ( let [a,b] in [3]) { } }';
167 compareSource(expect
, actual
, summary
+ ': 22');
169 f = function () { while(1) [a
] = [b
]; }
170 expect
= 'function () { while(true) {[a] = [b];} } ';
172 compareSource(expect
, actual
, summary
+ ': 23');
174 f = function () { for(var [x
, y
] = r
in p
) { } }
175 expect
= 'function () { var [x, y] = r; for( [x, y] in p) { } }';
177 compareSource(expect
, actual
, summary
+ ': 24');
179 f = function() { for([x
] = [];;) { } }
180 expect
= 'function() { for([x] = [];;) { } }';
182 compareSource(expect
, actual
, summary
+ ': 25');
184 f = function () { let ([y
] = delete [1]) { } }
185 expect
= 'function () { let ([y] = ([1], true)) { } }';
187 compareSource(expect
, actual
, summary
+ ': 26');
189 f = function () { delete 4..x
}
190 expect
= 'function () { delete (4).x; }';
192 compareSource(expect
, actual
, summary
+ ': 27');
194 f = function() { return [({ x
: y
}) = p
for (z
in 5)] }
195 expect
= 'function() { return [{ x: y } = p for (z in 5)]; }';
197 compareSource(expect
, actual
, summary
+ ': 28');