OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Test that a list literal is expandable and modifiable. | 7 // Test that a list literal is expandable and modifiable. |
8 | 8 |
9 class ListLiteralTest { | 9 class ListLiteralTest { |
10 static void testMain() { | 10 static void testMain() { |
11 var list = [1, 2, 3]; | 11 var list = [1, 2, 3]; |
12 Expect.equals(3, list.length); | 12 Expect.equals(3, list.length); |
13 list.add(4); | 13 list.add(4); |
14 Expect.equals(4, list.length); | 14 Expect.equals(4, list.length); |
15 list.addAll([5, 6]); | 15 list.addAll([5, 6]); |
16 Expect.equals(6, list.length); | 16 Expect.equals(6, list.length); |
17 list[0] = 0; | 17 list[0] = 0; |
18 Expect.equals(0, list[0]); | 18 Expect.equals(0, list[0]); |
19 } | 19 } |
20 } | 20 } |
21 | 21 |
22 main() { | 22 main() { |
23 ListLiteralTest.testMain(); | 23 ListLiteralTest.testMain(); |
24 } | 24 } |
OLD | NEW |