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

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

Issue 683893002: Classes: Add super support in methods and accessors (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Change test slightly Created 6 years, 2 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
« no previous file with comments | « src/x64/full-codegen-x64.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.js
diff --git a/test/mjsunit/harmony/classes.js b/test/mjsunit/harmony/classes.js
index 9302b29eebc045e056e635a9ad6eff13003ec920..c5c2b72313a69d0ffac6d12b294aa99675a66b9b 100644
--- a/test/mjsunit/harmony/classes.js
+++ b/test/mjsunit/harmony/classes.js
@@ -439,6 +439,156 @@ function assertAccessorDescriptor(object, name) {
})();
+(function TestSuperInMethods() {
+ class B {
+ method() {
+ return 1;
+ }
+ get x() {
+ return 2;
+ }
+ }
+ class C extends B {
+ method() {
+ assertEquals(2, super.x);
+ return super.method();
+ }
+ }
+ assertEquals(1, new C().method());
+})();
+
+
+(function TestSuperInGetter() {
+ class B {
+ method() {
+ return 1;
+ }
+ get x() {
+ return 2;
+ }
+ }
+ class C extends B {
+ get y() {
+ assertEquals(2, super.x);
+ return super.method();
+ }
+ }
+ assertEquals(1, new C().y);
+})();
+
+
+(function TestSuperInSetter() {
+ class B {
+ method() {
+ return 1;
+ }
+ get x() {
+ return 2;
+ }
+ }
+ class C extends B {
+ set y(v) {
+ assertEquals(3, v);
+ assertEquals(2, super.x);
+ assertEquals(1, super.method());
+ }
+ }
+ assertEquals(3, new C().y = 3);
+})();
+
+
+(function TestSuperInStaticMethods() {
+ class B {
+ static method() {
+ return 1;
+ }
+ static get x() {
+ return 2;
+ }
+ }
+ class C extends B {
+ static method() {
+ assertEquals(2, super.x);
+ return super.method();
+ }
+ }
+ assertEquals(1, C.method());
+})();
+
+
+(function TestSuperInStaticGetter() {
+ class B {
+ static method() {
+ return 1;
+ }
+ static get x() {
+ return 2;
+ }
+ }
+ class C extends B {
+ static get x() {
+ assertEquals(2, super.x);
+ return super.method();
+ }
+ }
+ assertEquals(1, C.x);
+})();
+
+
+(function TestSuperInStaticSetter() {
+ class B {
+ static method() {
+ return 1;
+ }
+ static get x() {
+ return 2;
+ }
+ }
+ class C extends B {
+ static set x(v) {
+ assertEquals(3, v);
+ assertEquals(2, super.x);
+ assertEquals(1, super.method());
+ }
+ }
+ assertEquals(3, C.x = 3);
+})();
+
+
+(function TestNumericPropertyNames() {
+ class B {
+ 1() { return 1; }
+ get 2() { return 2; }
+ set 3(_) {}
+
+ static 4() { return 4; }
+ static get 5() { return 5; }
+ static set 6(_) {}
+ }
+
+ assertMethodDescriptor(B.prototype, '1');
+ assertGetterDescriptor(B.prototype, '2');
+ assertSetterDescriptor(B.prototype, '3');
+
+ assertMethodDescriptor(B, '4');
+ assertGetterDescriptor(B, '5');
+ assertSetterDescriptor(B, '6');
+
+ class C extends B {
+ 1() { return super[1](); }
+ get 2() { return super[2]; }
+
+ static 4() { return super[4](); }
+ static get 5() { return super[5]; }
+ }
+
+ assertEquals(1, new C()[1]());
+ assertEquals(2, new C()[2]);
+ assertEquals(4, C[4]());
+ assertEquals(5, C[5]);
+})();
+
+
/* TODO(arv): Implement
(function TestNameBindingInConstructor() {
class C {
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698