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

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

Issue 1421033002: [es6] Partially implement Reflect.defineProperty. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address a comment and rebase. Created 5 years, 1 month 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/objects.cc ('k') | test/mjsunit/harmony/reflect-define-property.js » ('j') | 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-reflect 5 // Flags: --harmony-reflect
6 6
7 // TODO(neis): Test with proxies. 7 // TODO(neis): Test with proxies.
8 8
9 9
10 10
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 let proto = tgt.__proto__; 170 let proto = tgt.__proto__;
171 tgt.__proto__ = { get foo() {return this.bla} }; 171 tgt.__proto__ = { get foo() {return this.bla} };
172 assertEquals(true, Reflect.has(tgt, "foo")); 172 assertEquals(true, Reflect.has(tgt, "foo"));
173 tgt.__proto__ = proto; 173 tgt.__proto__ = proto;
174 } 174 }
175 })(); 175 })();
176 176
177 177
178 178
179 //////////////////////////////////////////////////////////////////////////////// 179 ////////////////////////////////////////////////////////////////////////////////
180 // Reflect.defineProperty
181
182
183 (function testReflectDefinePropertyArity() {
184 assertEquals(3, Reflect.defineProperty.length);
185 })();
186
187
188 (function testReflectDefinePropertyOnNonObject() {
189 assertThrows(function() { Reflect.defineProperty(); }, TypeError);
190 assertThrows(function() { Reflect.defineProperty(42, "bla"); }, TypeError);
191 assertThrows(function() { Reflect.defineProperty(null, "bla"); }, TypeError);
192 assertThrows(function() { Reflect.defineProperty({}, "bla"); }, TypeError);
193 assertThrows(function() { Reflect.defineProperty({}, "bla", 42); },
194 TypeError);
195 assertThrows(function() { Reflect.defineProperty({}, "bla", null); },
196 TypeError);
197 })();
198
199
200 (function testReflectDefinePropertyKeyConversion() {
201 var tgt = {};
202 var a = { [Symbol.toPrimitive]: function() { return "bla" } };
203 var b = { [Symbol.toPrimitive]: function() { throw "gaga" } };
204 assertTrue(Reflect.defineProperty(tgt, a, {value: 42}));
205 assertEquals(tgt.bla, 42);
206 assertThrows(function() { Reflect.defineProperty(tgt, b); }, "gaga");
207 })();
208
209
210 // See reflect-define-property.js for further tests.
211
212
213
214 ////////////////////////////////////////////////////////////////////////////////
180 // Reflect.deleteProperty 215 // Reflect.deleteProperty
181 216
182 217
183 (function testReflectDeletePropertyArity() { 218 (function testReflectDeletePropertyArity() {
184 assertEquals(2, Reflect.deleteProperty.length); 219 assertEquals(2, Reflect.deleteProperty.length);
185 })(); 220 })();
186 221
187 222
188 (function testReflectDeletePropertyOnNonObject() { 223 (function testReflectDeletePropertyOnNonObject() {
189 assertThrows(function() { Reflect.deleteProperty(); }, TypeError); 224 assertThrows(function() { Reflect.deleteProperty(); }, TypeError);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // Reflect.setPrototypeOf 289 // Reflect.setPrototypeOf
255 290
256 291
257 (function testReflectSetPrototypeOfArity() { 292 (function testReflectSetPrototypeOfArity() {
258 assertEquals(2, Reflect.setPrototypeOf.length); 293 assertEquals(2, Reflect.setPrototypeOf.length);
259 })(); 294 })();
260 295
261 296
262 (function testReflectSetPrototypeOfOnNonObject() { 297 (function testReflectSetPrototypeOfOnNonObject() {
263 assertThrows(function() { Reflect.setPrototypeOf(undefined, {}); }, 298 assertThrows(function() { Reflect.setPrototypeOf(undefined, {}); },
264 TypeError); 299 TypeError);
265 assertThrows(function() { Reflect.setPrototypeOf(42, {}); }, TypeError); 300 assertThrows(function() { Reflect.setPrototypeOf(42, {}); }, TypeError);
266 assertThrows(function() { Reflect.setPrototypeOf(null, {}); }, TypeError); 301 assertThrows(function() { Reflect.setPrototypeOf(null, {}); }, TypeError);
267 302
268 assertThrows(function() { Reflect.setPrototypeOf({}, undefined); }, 303 assertThrows(function() { Reflect.setPrototypeOf({}, undefined); },
269 TypeError); 304 TypeError);
270 assertThrows(function() { Reflect.setPrototypeOf({}, 42); }, TypeError); 305 assertThrows(function() { Reflect.setPrototypeOf({}, 42); }, TypeError);
271 assertTrue(Reflect.setPrototypeOf({}, null)); 306 assertTrue(Reflect.setPrototypeOf({}, null));
272 })(); 307 })();
273 308
274 309
275 // See reflect-set-prototype-of.js for further tests. 310 // See reflect-set-prototype-of.js for further tests.
276 311
277 312
278 313
279 //////////////////////////////////////////////////////////////////////////////// 314 ////////////////////////////////////////////////////////////////////////////////
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 assertThrows(function() { Reflect.preventExtensions(); }, TypeError); 373 assertThrows(function() { Reflect.preventExtensions(); }, TypeError);
339 assertThrows(function() { Reflect.preventExtensions(42); }, TypeError); 374 assertThrows(function() { Reflect.preventExtensions(42); }, TypeError);
340 assertThrows(function() { Reflect.preventExtensions(null); }, TypeError); 375 assertThrows(function() { Reflect.preventExtensions(null); }, TypeError);
341 })(); 376 })();
342 377
343 378
344 // See reflect-prevent-extensions.js for further tests. 379 // See reflect-prevent-extensions.js for further tests.
345 380
346 // TODO(neis): Need proxies to test the situation where 381 // TODO(neis): Need proxies to test the situation where
347 // [[preventExtensions]] returns false. 382 // [[preventExtensions]] returns false.
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/harmony/reflect-define-property.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698