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 // Test GrowableArray.dart. | 4 // Test GrowableArray.dart. |
5 | 5 |
6 #library("GrowableObjectArray2Test.dart"); | 6 #library("GrowableObjectArray2Test.dart"); |
7 #import("dart:coreimpl"); | 7 #import("dart:coreimpl"); |
8 | 8 |
9 class GrowableObjectArray2Test { | 9 class GrowableObjectArray2Test { |
10 static testMain() { | 10 static testMain() { |
(...skipping 21 matching lines...) Expand all Loading... |
32 list.setRange(0, f.length, f, 0); | 32 list.setRange(0, f.length, f, 0); |
33 for (int i = 0; i < f.length; i++) { | 33 for (int i = 0; i < f.length; i++) { |
34 Expect.equals(2, list[i]); | 34 Expect.equals(2, list[i]); |
35 } | 35 } |
36 f.setRange(0, 2, g, 10); | 36 f.setRange(0, 2, g, 10); |
37 Expect.equals(20, f.length); | 37 Expect.equals(20, f.length); |
38 | 38 |
39 bool exceptionCaught = false; | 39 bool exceptionCaught = false; |
40 try { | 40 try { |
41 var elem = g[g.length]; | 41 var elem = g[g.length]; |
42 } catch (IndexOutOfRangeException e) { | 42 } on IndexOutOfRangeException catch (e) { |
43 exceptionCaught = true; | 43 exceptionCaught = true; |
44 } | 44 } |
45 Expect.equals(true, exceptionCaught); | 45 Expect.equals(true, exceptionCaught); |
46 | 46 |
47 List<int> plainArray = [4, 3, 9, 12, -4, 9]; | 47 List<int> plainArray = [4, 3, 9, 12, -4, 9]; |
48 GrowableObjectArray h = new GrowableObjectArray.withCapacity(4); | 48 GrowableObjectArray h = new GrowableObjectArray.withCapacity(4); |
49 plainArray.forEach((elem) { h.add(elem); }); | 49 plainArray.forEach((elem) { h.add(elem); }); |
50 int compare(a, b) { | 50 int compare(a, b) { |
51 if (a < b) return -1; | 51 if (a < b) return -1; |
52 if (a > b) return 1; | 52 if (a > b) return 1; |
(...skipping 12 matching lines...) Expand all Loading... |
65 h.clear(); | 65 h.clear(); |
66 List array = const [0, 1, 2, 3, 4]; | 66 List array = const [0, 1, 2, 3, 4]; |
67 h.addAll(array); | 67 h.addAll(array); |
68 Expect.equals(5, h.length); | 68 Expect.equals(5, h.length); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 main() { | 72 main() { |
73 GrowableObjectArray2Test.testMain(); | 73 GrowableObjectArray2Test.testMain(); |
74 } | 74 } |
OLD | NEW |