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 main() { | 5 main() { |
6 var a; | 6 var a; |
7 a = new List(); | 7 a = new List(); |
8 a.add(499); | 8 a.add(499); |
9 Expect.equals(1, a.length); | 9 Expect.equals(1, a.length); |
10 Expect.equals(499, a[0]); | 10 Expect.equals(499, a[0]); |
11 a.clear(); | 11 a.clear(); |
12 Expect.equals(0, a.length); | 12 Expect.equals(0, a.length); |
13 Expect.throws(() => a[0], (e) => e is RangeError); | 13 Expect.throws(() => a[0], (e) => e is RangeError); |
14 | 14 |
15 a = new List(42).toList(growable: true); | 15 a = new List(42).toList(); |
16 Expect.equals(42, a.length); | 16 Expect.equals(42, a.length); |
17 a.add(499); | 17 a.add(499); |
18 Expect.equals(43, a.length); | 18 Expect.equals(43, a.length); |
19 Expect.equals(499, a[42]); | 19 Expect.equals(499, a[42]); |
20 Expect.equals(null, a[23]); | 20 Expect.equals(null, a[23]); |
21 a.clear(); | 21 a.clear(); |
22 Expect.equals(0, a.length); | 22 Expect.equals(0, a.length); |
23 Expect.throws(() => a[0], (e) => e is RangeError); | 23 Expect.throws(() => a[0], (e) => e is RangeError); |
24 | 24 |
25 a = new List<int>(42).toList(growable: true); | 25 a = new List<int>(42).toList(); |
26 Expect.equals(42, a.length); | 26 Expect.equals(42, a.length); |
27 a.add(499); | 27 a.add(499); |
28 Expect.equals(43, a.length); | 28 Expect.equals(43, a.length); |
29 Expect.equals(499, a[42]); | 29 Expect.equals(499, a[42]); |
30 for (int i = 0; i < 42; i++) { | 30 for (int i = 0; i < 42; i++) { |
31 Expect.equals(null, a[i]); | 31 Expect.equals(null, a[i]); |
32 } | 32 } |
33 a.clear(); | 33 a.clear(); |
34 Expect.equals(0, a.length); | 34 Expect.equals(0, a.length); |
35 Expect.throws(() => a[0], (e) => e is RangeError); | 35 Expect.throws(() => a[0], (e) => e is RangeError); |
36 } | 36 } |
OLD | NEW |