Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1 | Tests for ES6 class syntax expressions |
| 2 | |
| 3 | On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". |
| 4 | |
| 5 | |
| 6 | PASS constructorCallCount is 0 |
| 7 | PASS A.someStaticMethod() is staticMethodValue |
| 8 | PASS A.someStaticGetter is getterValue |
| 9 | PASS setterValue = undefined; A.someStaticSetter = 123; setterValue is 123 |
| 10 | PASS (new A).someInstanceMethod() is instanceMethodValue |
| 11 | PASS constructorCallCount is 1 |
| 12 | PASS (new A).someGetter is getterValue |
| 13 | PASS constructorCallCount is 2 |
| 14 | PASS (new A).someGetter is getterValue |
| 15 | PASS setterValue = undefined; (new A).someSetter = 789; setterValue is 789 |
| 16 | PASS (new A).__proto__ is A.prototype |
| 17 | PASS A.prototype.constructor is A |
| 18 | PASS x = class threw exception SyntaxError: Unexpected end of input. |
| 19 | PASS x = class { threw exception SyntaxError: Unexpected end of input. |
| 20 | PASS x = class { ( } threw exception SyntaxError: Unexpected token (. |
| 21 | PASS x = class {} did not throw exception. |
| 22 | PASS x = class { constructor() {} constructor() {} } threw exception SyntaxError: A class may only have one constructor. |
| 23 | PASS x = class { get constructor() {} } threw exception SyntaxError: Class constructor may not be an accessor. |
| 24 | PASS x = class { set constructor() {} } threw exception SyntaxError: Class constructor may not be an accessor. |
| 25 | PASS x = class { constructor() {} static constructor() { return staticMethodValue; } } did not throw exception. |
| 26 | PASS x = class { constructor() {} static constructor() { return staticMethodValue; } }; x.constructor() is staticMethodValue |
| 27 | PASS x = class { constructor() {} static prototype() {} } threw exception SyntaxError: Classes may not have static property named prototype. |
| 28 | PASS x = class { constructor() {} static get prototype() {} } threw exception SyntaxError: Classes may not have static property named prototype. |
| 29 | PASS x = class { constructor() {} static set prototype() {} } threw exception SyntaxError: Classes may not have static property named prototype. |
| 30 | PASS x = class { constructor() {} prototype() { return instanceMethodValue; } } did not throw exception. |
| 31 | PASS x = class { constructor() {} prototype() { return instanceMethodValue; } }; (new x).prototype() is instanceMethodValue |
| 32 | PASS x = class { constructor() {} set foo(a) {} } did not throw exception. |
| 33 | PASS x = class { constructor() {} set foo({x, y}) {} } did not throw exception. |
| 34 | PASS x = class { constructor() {} set foo() {} } threw exception SyntaxError: Setter must have exactly one formal parameter.. |
| 35 | PASS x = class { constructor() {} set foo(a, b) {} } threw exception SyntaxError: Setter must have exactly one formal parameter.. |
| 36 | PASS x = class { constructor() {} get foo() {} } did not throw exception. |
| 37 | PASS x = class { constructor() {} get foo(x) {} } threw exception SyntaxError: Getter must not have any formal parameters.. |
| 38 | PASS x = class { constructor() {} get foo({x, y}) {} } threw exception SyntaxError: Getter must not have any formal parameters.. |
| 39 | PASS successfullyParsed is true |
| 40 | |
| 41 | TEST COMPLETE |