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

Side by Side Diff: test/mjsunit/es6/classes-subclass-builtins.js

Issue 1424283002: [es6] Fix WeakMap/Set built-ins subclasssing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@func-subclass
Patch Set: Test updated once again 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') | 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: --allow-natives-syntax 5 // Flags: --allow-natives-syntax
6 6
7 "use strict"; 7 "use strict";
8 8
9 9
10 function checkPrototypeChain(object, constructors) { 10 function checkPrototypeChain(object, constructors) {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 TestArraySubclassing(Uint8ClampedArray); 259 TestArraySubclassing(Uint8ClampedArray);
260 TestArraySubclassing(Int16Array); 260 TestArraySubclassing(Int16Array);
261 TestArraySubclassing(Uint16Array); 261 TestArraySubclassing(Uint16Array);
262 TestArraySubclassing(Int32Array); 262 TestArraySubclassing(Int32Array);
263 TestArraySubclassing(Uint32Array); 263 TestArraySubclassing(Uint32Array);
264 TestArraySubclassing(Float32Array); 264 TestArraySubclassing(Float32Array);
265 TestArraySubclassing(Float64Array); 265 TestArraySubclassing(Float64Array);
266 })(); 266 })();
267 267
268 268
269 function TestMapSetSubclassing(container, is_map) {
270 var keys = [{name: "banana"}, {name: "cow"}, {name: "orange"}, {name: "chicken "}, {name: "apple"}];
271
272 class A extends container {
273 constructor(...args) {
274 assertTrue(%IsConstructCall());
275 super(...args);
276 this.a = 42;
277 this.d = 4.2;
278 }
279 }
280
281 var o = new A();
282 assertTrue(o instanceof Object);
283 assertTrue(o instanceof container);
284 assertTrue(o instanceof A);
285 assertEquals("object", typeof o);
286 checkPrototypeChain(o, [A, container, Object]);
287
288 for (var i = 0; i < keys.length; i++) {
289 if (is_map) {
290 o.set(keys[i], (i + 1) * 11);
291 } else {
292 o.add(keys[i]);
293 }
294 }
295 o.delete(keys[1]);
296 o.delete(keys[3]);
297
298 assertTrue(o.has(keys[0]));
299 assertFalse(o.has(keys[1]));
300 assertTrue(o.has(keys[2]));
301 assertFalse(o.has(keys[1]));
302 assertTrue(o.has(keys[4]));
303 if (is_map) {
304 assertEquals(11, o.get(keys[0]));
305 assertEquals(undefined, o.get(keys[1]));
306 assertEquals(33, o.get(keys[2]));
307 assertEquals(undefined, o.get(keys[3]));
308 assertEquals(55, o.get(keys[4]));
309 }
310 assertEquals(42, o.a);
311 assertEquals(4.2, o.d);
312
313 var o1 = new A();
314 assertTrue(%HaveSameMap(o, o1));
315 }
316
317
318 (function() {
319 TestMapSetSubclassing(Map, true);
320 TestMapSetSubclassing(WeakMap, true);
321 TestMapSetSubclassing(Set, false);
322 TestMapSetSubclassing(WeakSet, false);
323 })();
324
325
269 (function() { 326 (function() {
270 class A extends ArrayBuffer { 327 class A extends ArrayBuffer {
271 constructor(...args) { 328 constructor(...args) {
272 assertTrue(%IsConstructCall()); 329 assertTrue(%IsConstructCall());
273 super(...args); 330 super(...args);
274 this.a = 42; 331 this.a = 42;
275 this.d = 4.2; 332 this.d = 4.2;
276 } 333 }
277 } 334 }
278 335
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 (function() { 548 (function() {
492 class A extends null {} 549 class A extends null {}
493 assertThrows("new A"); 550 assertThrows("new A");
494 })(); 551 })();
495 552
496 553
497 (function() { 554 (function() {
498 class A extends Symbol {} 555 class A extends Symbol {}
499 assertThrows("new A"); 556 assertThrows("new A");
500 })(); 557 })();
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698