OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --harmony-class-fields |
| 6 |
| 7 { |
| 8 let hits = 0; |
| 9 let coercible = { toString(){ ++hits; return 'a'; } }; |
| 10 |
| 11 class C { |
| 12 [coercible] = 0; |
| 13 } |
| 14 |
| 15 assertEquals(1, hits); |
| 16 |
| 17 new C; |
| 18 new C; |
| 19 |
| 20 assertEquals(1, hits); |
| 21 |
| 22 assertEquals(0, (new C).a); |
| 23 } |
| 24 |
| 25 { |
| 26 let hits = 0; |
| 27 let coercible = { toString(){ ++hits; return 'a'; } }; |
| 28 |
| 29 class C { |
| 30 static [coercible] = 0; |
| 31 } |
| 32 |
| 33 assertEquals(1, hits); |
| 34 |
| 35 new C; |
| 36 new C; |
| 37 |
| 38 assertEquals(1, hits); |
| 39 |
| 40 assertEquals(0, C.a); |
| 41 } |
OLD | NEW |