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 class ListTest { | 6 class ListTest { |
7 static void TestIterator() { | 7 static void TestIterator() { |
8 List<int> a = new List<int>(10); | 8 List<int> a = new List<int>(10); |
9 int count = 0; | 9 int count = 0; |
10 | 10 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 Expect.equals(true, t.contains(9)); | 86 Expect.equals(true, t.contains(9)); |
87 Expect.equals(true, t.contains(-4)); | 87 Expect.equals(true, t.contains(-4)); |
88 Expect.equals(false, t.contains(-3)); | 88 Expect.equals(false, t.contains(-3)); |
89 Expect.equals(6, unsorted.length); | 89 Expect.equals(6, unsorted.length); |
90 Expect.equals(5, t.length); | 90 Expect.equals(5, t.length); |
91 TestIterator(); | 91 TestIterator(); |
92 int element = unsorted[2]; | 92 int element = unsorted[2]; |
93 Expect.equals(9, element); | 93 Expect.equals(9, element); |
94 | 94 |
95 Expect.throws(() => unsorted[2.1], | 95 Expect.throws(() => unsorted[2.1], |
96 (e) => e is IllegalArgumentException || e is TypeError); | 96 (e) => e is ArgumentError || e is TypeError); |
97 | 97 |
98 Expect.throws(() => new List(-1), (e) => true); | 98 Expect.throws(() => new List(-1), (e) => true); |
99 Expect.throws(() => new List(99999999999999999999999), (e) => true); | 99 Expect.throws(() => new List(99999999999999999999999), (e) => true); |
100 | 100 |
101 List list = new List(); | 101 List list = new List(); |
102 // We cannot write just 'list.removeLast' due to issue 3769. | 102 // We cannot write just 'list.removeLast' due to issue 3769. |
103 Expect.throws(() => list.removeLast(), | 103 Expect.throws(() => list.removeLast(), |
104 (e) => e is IndexOutOfRangeException); | 104 (e) => e is IndexOutOfRangeException); |
105 Expect.equals(0, list.length); | 105 Expect.equals(0, list.length); |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 main() { | 109 main() { |
110 ListTest.testMain(); | 110 ListTest.testMain(); |
111 } | 111 } |
OLD | NEW |