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

Side by Side Diff: test/mjsunit/harmony/object-rest-basic.js

Issue 2639333004: [pattern rewriter] Only desugar to call %ToName on computed properties (Closed)
Patch Set: add dcheck Created 3 years, 11 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/runtime/runtime-object.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 2016 the V8 project authors. All rights reserved. 1 // // Copyright 2016 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-object-rest-spread 5 // Flags: --harmony-object-rest-spread
6 var { ...x } = { a: 1 }; 6 var { ...x } = { a: 1 };
7 assertEquals({ a: 1 }, x); 7 assertEquals({ a: 1 }, x);
8 8
9 var { ...x } = { a: 1, b: 1 }; 9 var { ...x } = { a: 1, b: 1 };
10 assertEquals({ a: 1, b: 1 }, x); 10 assertEquals({ a: 1, b: 1 }, x);
(...skipping 24 matching lines...) Expand all
35 var { [key]: y, ...x } = { b: 1, a: 1 }; 35 var { [key]: y, ...x } = { b: 1, a: 1 };
36 assertEquals({ a: 1 }, x); 36 assertEquals({ a: 1 }, x);
37 assertEquals(1, y); 37 assertEquals(1, y);
38 38
39 var key = 1; 39 var key = 1;
40 var { [key++]: y, ...x } = { 1: 1, a: 1 }; 40 var { [key++]: y, ...x } = { 1: 1, a: 1 };
41 assertEquals({ a: 1 }, x); 41 assertEquals({ a: 1 }, x);
42 assertEquals(key, 2); 42 assertEquals(key, 2);
43 assertEquals(1, y); 43 assertEquals(1, y);
44 44
45 var key = '1';
46 var {[key]: y, ...x} = {1: 1, a: 1};
47 assertEquals({a: 1}, x);
48 assertEquals(1, y);
49
45 function example({a, ...rest}, { b = rest }) { 50 function example({a, ...rest}, { b = rest }) {
46 assertEquals(1, a); 51 assertEquals(1, a);
47 assertEquals({ b: 2, c: 3}, rest); 52 assertEquals({ b: 2, c: 3}, rest);
48 assertEquals({ b: 2, c: 3}, b); 53 assertEquals({ b: 2, c: 3}, b);
49 }; 54 };
50 example({ a: 1, b: 2, c: 3}, { b: undefined }); 55 example({ a: 1, b: 2, c: 3}, { b: undefined });
51 56
52 var x = { a: 3 }; 57 var x = { a: 3 };
53 var y = { 58 var y = {
54 set a(val) { assertUnreachable(); }, 59 set a(val) { assertUnreachable(); },
55 ...x, 60 ...x,
56 }; 61 };
57 assertEquals(y.a, 3); 62 assertEquals(y.a, 3);
58 63
64 var {...y} = {
65 get a() {
66 return 1
67 }
68 };
69 assertEquals({a: 1}, y);
70
59 var x = { 71 var x = {
60 get a() { throw new Error(); }, 72 get a() { throw new Error(); },
61 }; 73 };
62 assertThrows(() => { var { ...y } = x }); 74 assertThrows(() => { var { ...y } = x });
63 75
64 var p = new Proxy({}, { 76 var p = new Proxy({}, {
65 ownKeys() { throw new Error(); } 77 ownKeys() { throw new Error(); }
66 }); 78 });
67 assertThrows(() => { var { ...y } = p }); 79 assertThrows(() => { var { ...y } = p });
68 80
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 assertEquals(2, y); 125 assertEquals(2, y);
114 assertEquals({ 3: 3 }, z); 126 assertEquals({ 3: 3 }, z);
115 127
116 (({x, ...z}) => { assertEquals({y: 1}, z); })({ x: 1, y: 1}); 128 (({x, ...z}) => { assertEquals({y: 1}, z); })({ x: 1, y: 1});
117 129
118 var [...{...z}] = [{ x: 1}]; 130 var [...{...z}] = [{ x: 1}];
119 assertEquals({ 0: { x: 1} }, z); 131 assertEquals({ 0: { x: 1} }, z);
120 132
121 var {...{x}} = { x: 1}; 133 var {...{x}} = { x: 1};
122 assertEquals(1, x); 134 assertEquals(1, x);
135
136 var {4294967297: y, ...x} = {4294967297: 1, x: 1};
137 assertEquals(1, y);
138 assertEquals({x: 1}, x);
139
140 var obj = {
141 [Symbol.toPrimitive]() {
142 return 1;
143 }
144 };
145 var {[obj]: y, ...x} = {1: 1, x: 1};
146 assertEquals(1, y);
147 assertEquals({x: 1}, x);
148
149 var {[null]: y, ...x} = {null: 1, x: 1};
150 assertEquals(1, y);
151 assertEquals({x: 1}, x);
152
153 var {[true]: y, ...x} = {true: 1, x: 1};
154 assertEquals(1, y);
155 assertEquals({x: 1}, x);
156
157 var {[false]: y, ...x} = {false: 1, x: 1};
158 assertEquals(1, y);
159 assertEquals({x: 1}, x);
OLDNEW
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698