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 effects = []; |
| 9 class C { |
| 10 a = (effects.push(0), 0); |
| 11 a = (effects.push(1), 1); |
| 12 } |
| 13 |
| 14 let c = new C; |
| 15 assertArrayEquals([0, 1], effects); |
| 16 assertEquals(1, c.a); |
| 17 } |
| 18 |
| 19 { |
| 20 let effects = []; |
| 21 class C { |
| 22 a = (effects.push(0), 0); |
| 23 ['a'] = (effects.push(1), 1); |
| 24 } |
| 25 |
| 26 let c = new C; |
| 27 assertArrayEquals([0, 1], effects); |
| 28 assertEquals(1, c.a); |
| 29 } |
| 30 |
| 31 { |
| 32 let effects = []; |
| 33 class C { |
| 34 static a = (effects.push(0), 0); |
| 35 static a = (effects.push(1), 1); |
| 36 } |
| 37 |
| 38 assertArrayEquals([0, 1], effects); |
| 39 assertEquals(1, C.a); |
| 40 } |
| 41 |
| 42 { |
| 43 class C { |
| 44 a = 0; |
| 45 b = assertEquals(0, this.a); |
| 46 } |
| 47 |
| 48 new C; |
| 49 } |
| 50 |
| 51 { |
| 52 let effects = []; |
| 53 |
| 54 class C { |
| 55 static [effects.push(0)] = effects.push(1); |
| 56 [effects.push(2)] = effects.push(13); |
| 57 static [effects.push(3)]; |
| 58 [effects.push(4)]; |
| 59 static [effects.push(5)](){} |
| 60 [effects.push(6)](){} |
| 61 static [effects.push(7)](){} |
| 62 [effects.push(8)]; |
| 63 static [effects.push(9)]; |
| 64 [effects.push(10)] = effects.push(14); |
| 65 static [effects.push(11)] = effects.push(12); |
| 66 |
| 67 constructor() { |
| 68 effects.push(15); |
| 69 } |
| 70 } |
| 71 assertArrayEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], effects); |
| 72 |
| 73 new C; |
| 74 assertArrayEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], effe
cts); |
| 75 } |
| 76 |
| 77 { |
| 78 let effects = []; |
| 79 |
| 80 class Base { |
| 81 a = (effects.push(1), 0); |
| 82 |
| 83 constructor() { |
| 84 effects.push(2); |
| 85 assertEquals(undefined, this.c); |
| 86 assertEquals(0, this.a); |
| 87 this.b = 1; |
| 88 } |
| 89 } |
| 90 |
| 91 class Derived extends Base { |
| 92 c = (assertEquals(0, this.a), assertEquals(1, this.b), effects.push(3), 2); |
| 93 |
| 94 constructor() { |
| 95 effects.push(0); |
| 96 super(); |
| 97 effects.push(4); |
| 98 assertEquals(2, this.c); |
| 99 } |
| 100 } |
| 101 |
| 102 new Derived; |
| 103 assertArrayEquals([0, 1, 2, 3, 4], effects); |
| 104 } |
OLD | NEW |