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

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

Issue 1422853004: [es6] Fix Object built-in subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@weak-subclass
Patch Set: Test updated 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
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) {
11 var proto = object.__proto__; 11 var proto = object.__proto__;
12 for (var i = 0; i < constructors.length; i++) { 12 for (var i = 0; i < constructors.length; i++) {
13 assertEquals(constructors[i].prototype, proto); 13 assertEquals(constructors[i].prototype, proto);
14 assertEquals(constructors[i], proto.constructor); 14 assertEquals(constructors[i], proto.constructor);
15 proto = proto.__proto__; 15 proto = proto.__proto__;
16 } 16 }
17 } 17 }
18 18
19 19
20 (function() { 20 (function() {
21 class A extends Object {
22 constructor(...args) {
23 assertTrue(%IsConstructCall());
24 super(...args);
25 this.a = 42;
26 }
27 }
28
29 var s = new A("foo");
30 assertTrue(s instanceof Object);
31 assertTrue(s instanceof A);
32 assertEquals("object", typeof s);
33 checkPrototypeChain(s, [A, Object]);
34 assertEquals(42, s.a);
35
36 var s1 = new A("bar");
37 assertTrue(%HaveSameMap(s, s1));
38
39
40 var n = new A(153);
41 assertTrue(n instanceof Object);
42 assertTrue(n instanceof A);
43 assertEquals("object", typeof s);
44 checkPrototypeChain(s, [A, Object]);
45 assertEquals(42, n.a);
46
47 var n1 = new A(312);
48 assertTrue(%HaveSameMap(n, n1));
49 assertTrue(%HaveSameMap(n, s));
50
51
52 var b = new A(true);
53 assertTrue(b instanceof Object);
54 assertTrue(b instanceof A);
55 assertEquals("object", typeof s);
56 checkPrototypeChain(s, [A, Object]);
57 assertEquals(42, b.a);
58
59 var b1 = new A(true);
60 assertTrue(%HaveSameMap(b, b1));
61 assertTrue(%HaveSameMap(b, s));
62 })();
63
64
65 (function() {
21 class A extends Function { 66 class A extends Function {
22 constructor(...args) { 67 constructor(...args) {
23 assertTrue(%IsConstructCall()); 68 assertTrue(%IsConstructCall());
24 super(...args); 69 super(...args);
25 this.a = 42; 70 this.a = 42;
26 } 71 }
27 } 72 }
28 73
29 var o = new A("this.foo = 153;"); 74 var o = new A("this.foo = 153;");
30 assertTrue(o instanceof Object); 75 assertTrue(o instanceof Object);
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 (function() { 556 (function() {
512 class A extends null {} 557 class A extends null {}
513 assertThrows("new A"); 558 assertThrows("new A");
514 })(); 559 })();
515 560
516 561
517 (function() { 562 (function() {
518 class A extends Symbol {} 563 class A extends Symbol {}
519 assertThrows("new A"); 564 assertThrows("new A");
520 })(); 565 })();
OLDNEW
« src/js/v8natives.js ('K') | « src/js/v8natives.js ('k') | test/mjsunit/harmony/super.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698