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 // Dart test program for testing arrays. | 4 // Dart test program for testing arrays. |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 class ListTest { | 8 class ListTest { |
9 static void TestIterator() { | 9 static void TestIterator() { |
10 List<int> a = new List<int>(10); | 10 List<int> a = new List<int>(10); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 List a = new List(len); | 47 List a = new List(len); |
48 Expect.equals(true, a is List); | 48 Expect.equals(true, a is List); |
49 Expect.equals(len, a.length); | 49 Expect.equals(len, a.length); |
50 a.forEach((element) { Expect.equals(null, element); }); | 50 a.forEach((element) { Expect.equals(null, element); }); |
51 a[1] = 1; | 51 a[1] = 1; |
52 Expect.equals(1, a[1]); | 52 Expect.equals(1, a[1]); |
53 Expect.throws(() => a[len], (e) => e is RangeError); | 53 Expect.throws(() => a[len], (e) => e is RangeError); |
54 | 54 |
55 Expect.throws(() { | 55 Expect.throws(() { |
56 List a = new List(4); | 56 List a = new List(4); |
57 a.setRange(1, 1, a, null); | 57 a.setRange(1, 2, a, null); |
58 }); | 58 }); |
59 | 59 |
60 Expect.throws(() { | 60 Expect.throws(() { |
61 List a = new List(4); | 61 List a = new List(4); |
62 a.setRange(1, 1, const [1, 2, 3, 4], null); | 62 a.setRange(1, 2, const [1, 2, 3, 4], null); |
63 }); | 63 }); |
64 | 64 |
65 Expect.throws(() { | 65 Expect.throws(() { |
66 List a = new List(4); | 66 List a = new List(4); |
67 a.setRange(10, 1, a, 1); | 67 a.setRange(10, 11, a, 1); |
68 }, (e) => e is RangeError); | 68 }, (e) => e is RangeError); |
69 | 69 |
70 a = new List(4); | 70 a = new List(4); |
71 List b = new List(4); | 71 List b = new List(4); |
72 b.setRange(0, 4, a, 0); | 72 b.setRange(0, 4, a, 0); |
73 | 73 |
74 List<int> unsorted = [4, 3, 9, 12, -4, 9]; | 74 List<int> unsorted = [4, 3, 9, 12, -4, 9]; |
75 int compare(a, b) { | 75 int compare(a, b) { |
76 if (a < b) return -1; | 76 if (a < b) return -1; |
77 if (a > b) return 1; | 77 if (a > b) return 1; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // We cannot write just 'list.removeLast' due to issue 3769. | 109 // We cannot write just 'list.removeLast' due to issue 3769. |
110 Expect.throws(() => list.removeLast(), | 110 Expect.throws(() => list.removeLast(), |
111 (e) => e is RangeError); | 111 (e) => e is RangeError); |
112 Expect.equals(0, list.length); | 112 Expect.equals(0, list.length); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 main() { | 116 main() { |
117 ListTest.testMain(); | 117 ListTest.testMain(); |
118 } | 118 } |
OLD | NEW |