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 |
5 class A { | 7 class A { |
6 List<int> list; | 8 List<int> list; |
7 A(int a, int b) : list = <int>[a, b]; | 9 A(int a, int b) : list = <int>[a, b]; |
8 operator [](index) => list[index]; | 10 operator [](index) => list[index]; |
9 operator []=(index, value) => list[index] = value; | 11 operator []=(index, value) => list[index] = value; |
10 } | 12 } |
11 | 13 |
12 class B { | 14 class B { |
13 int value; | 15 int value; |
14 List trace; | 16 List trace; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 Expect.equals(1, a[0]); | 66 Expect.equals(1, a[0]); |
65 | 67 |
66 a[0] += 2; | 68 a[0] += 2; |
67 Expect.equals(3, a[0]); | 69 Expect.equals(3, a[0]); |
68 | 70 |
69 List trace = new List(); | 71 List trace = new List(); |
70 getB(trace)[getIndex(trace)] += 37; | 72 getB(trace)[getIndex(trace)] += 37; |
71 | 73 |
72 Expect.listEquals([-1, -2, -3, 42, 100, -4, 101, 37, -5, 42, 102], trace); | 74 Expect.listEquals([-1, -2, -3, 42, 100, -4, 101, 37, -5, 42, 102], trace); |
73 } | 75 } |
OLD | NEW |