| Index: test/mjsunit/harmony/classes.js
|
| diff --git a/test/mjsunit/harmony/classes.js b/test/mjsunit/harmony/classes.js
|
| index a83d483bd9a20945d383f1bda233875fb87b748c..ec53b4cc38d5eff544e92cbc2a6ad6b713be844b 100644
|
| --- a/test/mjsunit/harmony/classes.js
|
| +++ b/test/mjsunit/harmony/classes.js
|
| @@ -177,3 +177,92 @@
|
| class E { x() { 42; } }
|
| assertEquals('class E { x() { 42; } }', E.toString());
|
| })();
|
| +
|
| +
|
| +(function TestMethods() {
|
| + class C {
|
| + method() { return 1; }
|
| + static staticMethod() { return 2; }
|
| + method2() { return 3; }
|
| + static staticMethod2() { return 4; }
|
| + }
|
| +
|
| + assertEquals('function', typeof C.prototype.method);
|
| + assertEquals('function', typeof C.prototype.method2);
|
| + assertEquals('function', typeof C.staticMethod);
|
| + assertEquals('function', typeof C.staticMethod2);
|
| +
|
| + assertEquals(1, new C().method());
|
| + assertEquals(2, C.staticMethod());
|
| + assertEquals(3, new C().method2());
|
| + assertEquals(4, C.staticMethod2());
|
| +})();
|
| +
|
| +
|
| +(function TestGetters() {
|
| + class C {
|
| + get x() { return 1; }
|
| + static get staticX() { return 2; }
|
| + get y() { return 3; }
|
| + static get staticY() { return 4; }
|
| + }
|
| +
|
| + assertTrue(C.prototype.hasOwnProperty('x'));
|
| + assertTrue(C.hasOwnProperty('staticX'));
|
| + assertTrue(C.prototype.hasOwnProperty('y'));
|
| + assertTrue(C.hasOwnProperty('staticY'));
|
| +
|
| + assertEquals(1, new C().x);
|
| + assertEquals(2, C.staticX);
|
| + assertEquals(3, new C().y);
|
| + assertEquals(4, C.staticY);
|
| +})();
|
| +
|
| +
|
| +
|
| +(function TestSetters() {
|
| + var x, staticX, y, staticY;
|
| + class C {
|
| + set x(v) { x = v; }
|
| + static set staticX(v) { staticX = v; }
|
| + set y(v) { y = v; }
|
| + static set staticY(v) { staticY = v; }
|
| + }
|
| +
|
| + assertTrue(C.prototype.hasOwnProperty('x'));
|
| + assertTrue(C.hasOwnProperty('staticX'));
|
| + assertTrue(C.prototype.hasOwnProperty('y'));
|
| + assertTrue(C.hasOwnProperty('staticY'));
|
| +
|
| + assertEquals(1, new C().x = 1);
|
| + assertEquals(1, x);
|
| + assertEquals(2, C.staticX = 2);
|
| + assertEquals(2, staticX);
|
| + assertEquals(3, new C().y = 3);
|
| + assertEquals(3, y);
|
| + assertEquals(4, C.staticY = 4);
|
| + assertEquals(4, staticY);
|
| +})();
|
| +
|
| +
|
| +(function TestAccessors() {
|
| + class C {
|
| + // constructor(x) {
|
| + // this._x = x;
|
| + // }
|
| +
|
| + get x() { return this._x; }
|
| + set x(v) { this._x = v; }
|
| +
|
| + // static get staticX() { return this._x; }
|
| + // static set staticX(v) { this._x = v; }
|
| + }
|
| +
|
| + // assertTrue(C.prototype.hasOwnProperty('x'));
|
| + // assertTrue(C.hasOwnProperty('staticX'));
|
| +
|
| + // var c = new C(1);
|
| + // c._x = 1;
|
| + // assertEquals(1, c.x);
|
| +
|
| +})();
|
|
|