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

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
« no previous file with comments | « src/js/v8natives.js ('k') | test/mjsunit/es6/super.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: --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 this.d = 4.2;
27 }
28 }
29
30 var s = new A("foo");
31 assertTrue(s instanceof Object);
32 assertTrue(s instanceof A);
33 assertEquals("object", typeof s);
34 checkPrototypeChain(s, [A, Object]);
35 assertEquals(42, s.a);
36 assertEquals(4.2, s.d);
37
38 var s1 = new A("bar");
39 assertTrue(%HaveSameMap(s, s1));
40
41
42 var n = new A(153);
43 assertTrue(n instanceof Object);
44 assertTrue(n instanceof A);
45 assertEquals("object", typeof s);
46 checkPrototypeChain(s, [A, Object]);
47 assertEquals(42, n.a);
48 assertEquals(4.2, n.d);
49
50 var n1 = new A(312);
51 assertTrue(%HaveSameMap(n, n1));
52 assertTrue(%HaveSameMap(n, s));
53
54
55 var b = new A(true);
56 assertTrue(b instanceof Object);
57 assertTrue(b instanceof A);
58 assertEquals("object", typeof s);
59 checkPrototypeChain(s, [A, Object]);
60 assertEquals(42, b.a);
61 assertEquals(4.2, b.d);
62
63 var b1 = new A(true);
64 assertTrue(%HaveSameMap(b, b1));
65 assertTrue(%HaveSameMap(b, s));
66 })();
67
68
69 (function() {
21 class A extends Function { 70 class A extends Function {
22 constructor(...args) { 71 constructor(...args) {
23 assertTrue(%IsConstructCall()); 72 assertTrue(%IsConstructCall());
24 super(...args); 73 super(...args);
25 this.a = 42; 74 this.a = 42;
26 this.d = 4.2; 75 this.d = 4.2;
27 } 76 }
28 } 77 }
29 78
30 var o = new A("this.foo = 153;"); 79 var o = new A("this.foo = 153;");
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 (function() { 595 (function() {
547 class A extends null {} 596 class A extends null {}
548 assertThrows("new A"); 597 assertThrows("new A");
549 })(); 598 })();
550 599
551 600
552 (function() { 601 (function() {
553 class A extends Symbol {} 602 class A extends Symbol {}
554 assertThrows("new A"); 603 assertThrows("new A");
555 })(); 604 })();
OLDNEW
« no previous file with comments | « src/js/v8natives.js ('k') | test/mjsunit/es6/super.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698