| 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"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 class A { | 7 class A { |
| 8 List<int> list; | 8 List<int> list; |
| 9 A(int a, int b) : list = <int>[a, b]; | 9 A(int a, int b) : list = <int>[a, b]; |
| 10 operator [](index) => list[index]; | 10 operator [](index) => list[index]; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 trace.add(value); | 36 trace.add(value); |
| 37 this.value = this.value + 1; | 37 this.value = this.value + 1; |
| 38 return this; | 38 return this; |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 B getB(trace) { | 42 B getB(trace) { |
| 43 trace.add(-1); | 43 trace.add(-1); |
| 44 return new B(trace); | 44 return new B(trace); |
| 45 } | 45 } |
| 46 |
| 46 int getIndex(trace) { | 47 int getIndex(trace) { |
| 47 trace.add(-2); | 48 trace.add(-2); |
| 48 return 42; | 49 return 42; |
| 49 } | 50 } |
| 50 | 51 |
| 51 main() { | 52 main() { |
| 52 A a = new A(1, 2); | 53 A a = new A(1, 2); |
| 53 Expect.equals(1, a[0]); | 54 Expect.equals(1, a[0]); |
| 54 Expect.equals(2, a[1]); | 55 Expect.equals(2, a[1]); |
| 55 | 56 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 66 Expect.equals(1, a[0]); | 67 Expect.equals(1, a[0]); |
| 67 | 68 |
| 68 a[0] += 2; | 69 a[0] += 2; |
| 69 Expect.equals(3, a[0]); | 70 Expect.equals(3, a[0]); |
| 70 | 71 |
| 71 List trace = new List(); | 72 List trace = new List(); |
| 72 getB(trace)[getIndex(trace)] += 37; | 73 getB(trace)[getIndex(trace)] += 37; |
| 73 | 74 |
| 74 Expect.listEquals([-1, -2, -3, 42, 100, -4, 101, 37, -5, 42, 102], trace); | 75 Expect.listEquals([-1, -2, -3, 42, 100, -4, 101, 37, -5, 42, 102], trace); |
| 75 } | 76 } |
| OLD | NEW |