OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | |
6 | |
7 class B { | 5 class B { |
8 int value; | 6 int value; |
9 List trace; | 7 List trace; |
10 B(this.trace) : value = 100; | 8 B(this.trace) : value = 100; |
11 operator [](index) { | 9 operator [](index) { |
12 trace.add(-3); | 10 trace.add(-3); |
13 trace.add(index); | 11 trace.add(index); |
14 trace.add(this.value); | 12 trace.add(this.value); |
15 this.value = this.value + 1; | 13 this.value = this.value + 1; |
16 return this; | 14 return this; |
(...skipping 24 matching lines...) Expand all Loading... |
41 trace.add(-2); | 39 trace.add(-2); |
42 return 42; | 40 return 42; |
43 } | 41 } |
44 | 42 |
45 main() { | 43 main() { |
46 List trace = new List(); | 44 List trace = new List(); |
47 getB(trace)[getIndex(trace)] += 37; | 45 getB(trace)[getIndex(trace)] += 37; |
48 | 46 |
49 Expect.listEquals([-1, -2, -3, 42, 100, -4, 101, 37, -5, 42, 102], trace); | 47 Expect.listEquals([-1, -2, -3, 42, 100, -4, 101, 37, -5, 42, 102], trace); |
50 } | 48 } |
OLD | NEW |