| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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: --harmony | 5 // Flags: --harmony |
| 6 | 6 |
| 7 (function TestBasics() { | 7 (function TestBasics() { |
| 8 var C = class C {} | 8 var C = class C {} |
| 9 assertEquals(typeof C, 'function'); | 9 assertEquals(typeof C, 'function'); |
| 10 assertEquals(C.__proto__, Function.prototype); | 10 assertEquals(C.__proto__, Function.prototype); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 assertEquals(1, x); | 238 assertEquals(1, x); |
| 239 assertEquals(2, C.staticX = 2); | 239 assertEquals(2, C.staticX = 2); |
| 240 assertEquals(2, staticX); | 240 assertEquals(2, staticX); |
| 241 assertEquals(3, new C().y = 3); | 241 assertEquals(3, new C().y = 3); |
| 242 assertEquals(3, y); | 242 assertEquals(3, y); |
| 243 assertEquals(4, C.staticY = 4); | 243 assertEquals(4, C.staticY = 4); |
| 244 assertEquals(4, staticY); | 244 assertEquals(4, staticY); |
| 245 })(); | 245 })(); |
| 246 | 246 |
| 247 | 247 |
| 248 (function TestSideEffectsInPropertyDefine() { |
| 249 function B() {} |
| 250 B.prototype = { |
| 251 constructor: B, |
| 252 set m(v) { |
| 253 throw Error(); |
| 254 } |
| 255 }; |
| 256 |
| 257 class C extends B { |
| 258 m() { return 1; } |
| 259 } |
| 260 |
| 261 assertEquals(1, new C().m()); |
| 262 })(); |
| 263 |
| 264 |
| 248 (function TestAccessors() { | 265 (function TestAccessors() { |
| 249 class C { | 266 class C { |
| 250 // constructor(x) { | 267 // constructor(x) { |
| 251 // this._x = x; | 268 // this._x = x; |
| 252 // } | 269 // } |
| 253 | 270 |
| 254 get x() { return this._x; } | 271 get x() { return this._x; } |
| 255 set x(v) { this._x = v; } | 272 set x(v) { this._x = v; } |
| 256 | 273 |
| 257 // static get staticX() { return this._x; } | 274 // static get staticX() { return this._x; } |
| 258 // static set staticX(v) { this._x = v; } | 275 // static set staticX(v) { this._x = v; } |
| 259 } | 276 } |
| 260 | 277 |
| 261 // assertTrue(C.prototype.hasOwnProperty('x')); | 278 // assertTrue(C.prototype.hasOwnProperty('x')); |
| 262 // assertTrue(C.hasOwnProperty('staticX')); | 279 // assertTrue(C.hasOwnProperty('staticX')); |
| 263 | 280 |
| 264 // var c = new C(1); | 281 // var c = new C(1); |
| 265 // c._x = 1; | 282 // c._x = 1; |
| 266 // assertEquals(1, c.x); | 283 // assertEquals(1, c.x); |
| 267 | 284 |
| 268 })(); | 285 })(); |
| OLD | NEW |