Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: test/mjsunit/harmony/destructuring.js

Issue 1906633002: Version 5.0.71.34 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@5.0
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/pattern-rewriter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Flags: --harmony-destructuring-bind 5 // Flags: --harmony-destructuring-bind
6 // Flags: --harmony-default-parameters 6 // Flags: --harmony-default-parameters
7 7
8 (function TestObjectLiteralPattern() { 8 (function TestObjectLiteralPattern() {
9 var { x : x, y : y, get, set } = { x : 1, y : 2, get: 3, set: 4 }; 9 var { x : x, y : y, get, set } = { x : 1, y : 2, get: 3, set: 4 };
10 assertEquals(1, x); 10 assertEquals(1, x);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 assertSame(27, x); 256 assertSame(27, x);
257 assertEquals(0, callCount); 257 assertEquals(0, callCount);
258 258
259 callCount = 0; 259 callCount = 0;
260 var { x = f(42) } = {}; 260 var { x = f(42) } = {};
261 assertSame(42, x); 261 assertSame(42, x);
262 assertEquals(1, callCount); 262 assertEquals(1, callCount);
263 }()); 263 }());
264 264
265 265
266 (function TestAssignmentExprInInitializers() {
267 {
268 let x, y;
269 {
270 let { x = y = 1 } = {};
271 assertSame(x, 1);
272 assertSame(y, 1);
273 }
274 assertSame(undefined, x);
275 assertSame(1, y);
276 }
277
278 {
279 let x, y;
280 {
281 let { x: x = y = 1 } = {};
282 assertSame(1, x);
283 assertSame(1, y);
284 }
285 assertSame(undefined, x);
286 assertSame(1, y);
287 }
288
289 {
290 let x, y;
291 {
292 let [ x = y = 1 ] = [];
293 assertSame(1, x);
294 assertSame(1, y);
295 }
296 assertSame(undefined, x);
297 assertSame(1, y);
298 }
299
300 {
301 let x, y;
302 (function({ x = y = 1 }) {}({}));
303 assertSame(undefined, x);
304 assertSame(1, y);
305 }
306
307 {
308 let x, y;
309 (function({ x: x = y = 1 }) {}({}));
310 assertSame(undefined, x);
311 assertSame(1, y);
312 }
313
314 {
315 let x, y;
316 (function([ x = y = 1 ]) {}([]));
317 assertSame(undefined, x);
318 assertSame(1, y);
319 }
320 }());
321
322
266 (function TestMultipleAccesses() { 323 (function TestMultipleAccesses() {
267 assertThrows( 324 assertThrows(
268 "'use strict';"+ 325 "'use strict';"+
269 "const {x,x} = {x:1};", 326 "const {x,x} = {x:1};",
270 SyntaxError); 327 SyntaxError);
271 328
272 assertThrows( 329 assertThrows(
273 "'use strict';"+ 330 "'use strict';"+
274 "let {x,x} = {x:1};", 331 "let {x,x} = {x:1};",
275 SyntaxError); 332 SyntaxError);
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 throw [1, 2, 3]; 1182 throw [1, 2, 3];
1126 } catch ([foo, ...bar]) { 1183 } catch ([foo, ...bar]) {
1127 assertEquals(1, foo); 1184 assertEquals(1, foo);
1128 assertEquals([2, 3], bar); 1185 assertEquals([2, 3], bar);
1129 } 1186 }
1130 1187
1131 assertEquals("hello", foo); 1188 assertEquals("hello", foo);
1132 assertEquals("world", bar); 1189 assertEquals("world", bar);
1133 assertEquals(42, baz); 1190 assertEquals(42, baz);
1134 })(); 1191 })();
OLDNEW
« no previous file with comments | « src/parsing/pattern-rewriter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698