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