OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'dart:collection'; | 6 import 'dart:collection'; |
7 | 7 |
8 class MyList extends ListBase { | 8 class MyList extends ListBase { |
9 final list; | 9 final list; |
10 MyList(this.list); | 10 MyList(this.list); |
11 | 11 |
12 get length => list.length; | 12 get length => list.length; |
13 set length(val) { list.length = val; } | 13 set length(val) { |
| 14 list.length = val; |
| 15 } |
14 | 16 |
15 operator [](index) => list[index]; | 17 operator [](index) => list[index]; |
16 operator []=(index, val) => list[index] = val; | 18 operator []=(index, val) => list[index] = val; |
17 } | 19 } |
18 | 20 |
19 main() { | 21 main() { |
20 Expect.equals("[]", [].toString()); | 22 Expect.equals("[]", [].toString()); |
21 Expect.equals("[1]", [1].toString()); | 23 Expect.equals("[1]", [1].toString()); |
22 Expect.equals("[1, 2]", [1, 2].toString()); | 24 Expect.equals("[1, 2]", [1, 2].toString()); |
23 Expect.equals("[]", const [].toString()); | 25 Expect.equals("[]", const [].toString()); |
24 Expect.equals("[1]", const [1].toString()); | 26 Expect.equals("[1]", const [1].toString()); |
25 Expect.equals("[1, 2]", const [1, 2].toString()); | 27 Expect.equals("[1, 2]", const [1, 2].toString()); |
26 Expect.equals("[]", new MyList([]).toString()); | 28 Expect.equals("[]", new MyList([]).toString()); |
27 Expect.equals("[1]", new MyList([1]).toString()); | 29 Expect.equals("[1]", new MyList([1]).toString()); |
28 Expect.equals("[1, 2]", new MyList([1, 2]).toString()); | 30 Expect.equals("[1, 2]", new MyList([1, 2]).toString()); |
29 } | 31 } |
OLD | NEW |