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

Unified Diff: test/mjsunit/harmony/classes-experimental.js

Issue 917753002: new classes: implement default constructors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« src/parser.cc ('K') | « src/runtime/runtime-classes.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/classes-experimental.js
diff --git a/test/mjsunit/harmony/classes-experimental.js b/test/mjsunit/harmony/classes-experimental.js
index 36c4dd82465130b767c460bf67fcae9f2077eabc..97b47f8d4d2693149f760209da1619d3b396aeb0 100644
--- a/test/mjsunit/harmony/classes-experimental.js
+++ b/test/mjsunit/harmony/classes-experimental.js
@@ -225,3 +225,62 @@
assertSame(8, s2.y);
assertSame(Subclass.prototype, s.__proto__);
}());
+
+
+(function TestDefaultConstructor() {
+ class Base1 { }
+
+ assertThrows(function() { Base1(); }, TypeError);
+
+ class Subclass1 extends Base1 { }
+
+ assertThrows(function() { Subclass1(); }, TypeError);
+
+ let s1 = new Subclass1();
+ assertSame(s1.__proto__, Subclass1.prototype);
+
+ class Base2 {
+ constructor(x, y) {
+ this.x = x;
+ this.y = y;
+ }
+ }
+
+ class Subclass2 extends Base2 {};
+
+ let s2 = new Subclass2(1, 2);
+
+ assertSame(s2.__proto__, Subclass2.prototype);
+ assertSame(1, s2.x);
+ assertSame(2, s2.y);
+
+ var f = Subclass2.bind({}, 3, 4);
arv (Not doing code reviews) 2015/02/11 14:53:49 var -> let
Dmitry Lomov (no reviews) 2015/02/11 16:29:36 Done.
+ let s2prime = new f();
+ assertSame(s2prime.__proto__, Subclass2.prototype);
+ assertSame(3, s2prime.x);
+ assertSame(4, s2prime.y);
+
+ let obj = {};
+ class Base3 {
+ constructor() {
+ return obj;
+ }
+ }
+
+ class Subclass3 extends Base3 {};
+
+ let s3 = new Subclass3();
+ assertSame(obj, s3);
+
+ class ExtendedUint8Array extends Uint8Array { }
+
+ var eua = new ExtendedUint8Array(10);
+ assertEquals(10, eua.length);
+ assertEquals(10, eua.byteLength);
+ eua[0] = 0xFF;
+ eua[1] = 0xFFA;
+ assertEquals(0xFF, eua[0]);
+ assertEquals(0xFA, eua[1]);
+ assertTrue(eua.__proto__ === ExtendedUint8Array.prototype);
arv (Not doing code reviews) 2015/02/11 14:53:49 assertSame or assertEquals
Dmitry Lomov (no reviews) 2015/02/11 16:29:36 Done.
+ assertEquals("[object Uint8Array]", Object.prototype.toString.call(eua));
+}());
« src/parser.cc ('K') | « src/runtime/runtime-classes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698