Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: tests/corelib/list_test.dart

Issue 14178017: Mark list_test as failing on browsers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Moved argument checking checking away from typed arrays for now Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« tests/corelib/corelib.status ('K') | « tests/corelib/corelib.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "dart:collection"; 5 import "dart:collection";
6 import "dart:typed_data"; 6 import "dart:typed_data";
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 void main() { 9 void main() {
10 // Typed lists - fixed length and can only contain integers. 10 // Typed lists - fixed length and can only contain integers.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 Expect.isFalse(list.every(matchSome)); 145 Expect.isFalse(list.every(matchSome));
146 Expect.isFalse(list.every(matchNone)); 146 Expect.isFalse(list.every(matchNone));
147 147
148 // any 148 // any
149 Expect.isTrue(list.any(matchAll)); 149 Expect.isTrue(list.any(matchAll));
150 Expect.isTrue(list.any(matchSome)); 150 Expect.isTrue(list.any(matchSome));
151 Expect.isTrue(list.any(matchSomeFirst)); 151 Expect.isTrue(list.any(matchSomeFirst));
152 Expect.isTrue(list.any(matchSomeLast)); 152 Expect.isTrue(list.any(matchSomeLast));
153 Expect.isFalse(list.any(matchNone)); 153 Expect.isFalse(list.any(matchNone));
154 154
155 // Argument checking isn't implemented for typed arrays in browsers,
156 // so it's moved to the method below for now.
157 }
158
159 void testLengthInvariantOperations(List list) {
160 testTypedLengthInvariantOperations(list);
161 // Tests that need untyped lists.
162 list.setAll(0, [0, 1, 2, 3]);
163 Expect.equals(-1, list.indexOf(100));
164 Expect.equals(-1, list.lastIndexOf(100));
165 list[2] = new Yes();
166 Expect.equals(2, list.indexOf(100));
167 Expect.equals(2, list.lastIndexOf(100));
168 list[3] = new Yes();
169 Expect.equals(2, list.indexOf(100));
170 Expect.equals(3, list.lastIndexOf(100));
171 list[2] = 2;
172 Expect.equals(3, list.indexOf(100));
173 Expect.equals(3, list.lastIndexOf(100));
174 list[3] = 3;
175 Expect.equals(-1, list.indexOf(100));
176 Expect.equals(-1, list.lastIndexOf(100));
177
155 // Argument errors on bad indices. List is still [0, 1, 2, 3]. 178 // Argument errors on bad indices. List is still [0, 1, 2, 3].
156 testArgumentError(action()) { 179 testArgumentError(action()) {
157 Expect.throws(action, (e) => e is ArgumentError); 180 Expect.throws(action, (e) => e is ArgumentError);
158 } 181 }
159 182
160 // Direct indices (0 <= index < length). 183 // Direct indices (0 <= index < length).
161 testArgumentError(() => list[-1]); 184 testArgumentError(() => list[-1]);
162 testArgumentError(() => list[4]); 185 testArgumentError(() => list[4]);
163 testArgumentError(() => list[-1] = 99); 186 testArgumentError(() => list[-1] = 99);
164 testArgumentError(() => list[4] = 99); 187 testArgumentError(() => list[4] = 99);
(...skipping 15 matching lines...) Expand all
180 // for setAll, end is implictly start + values.length. 203 // for setAll, end is implictly start + values.length.
181 testArgumentError(() => list.setAll(-1, [])); 204 testArgumentError(() => list.setAll(-1, []));
182 testArgumentError(() => list.setAll(5, [])); 205 testArgumentError(() => list.setAll(5, []));
183 testArgumentError(() => list.setAll(2, [1, 2, 3])); 206 testArgumentError(() => list.setAll(2, [1, 2, 3]));
184 testArgumentError(() => list.fillRange(-1, 2)); 207 testArgumentError(() => list.fillRange(-1, 2));
185 testArgumentError(() => list.fillRange(-1, 5)); 208 testArgumentError(() => list.fillRange(-1, 5));
186 testArgumentError(() => list.fillRange(2, 5)); 209 testArgumentError(() => list.fillRange(2, 5));
187 testArgumentError(() => list.fillRange(4, 2)); 210 testArgumentError(() => list.fillRange(4, 2));
188 } 211 }
189 212
190 void testLengthInvariantOperations(List list) {
191 testTypedLengthInvariantOperations(list);
192 // Tests that need untyped lists.
193 list.setAll(0, [0, 1, 2, 3]);
194 Expect.equals(-1, list.indexOf(100));
195 Expect.equals(-1, list.lastIndexOf(100));
196 list[2] = new Yes();
197 Expect.equals(2, list.indexOf(100));
198 Expect.equals(2, list.lastIndexOf(100));
199 list[3] = new Yes();
200 Expect.equals(2, list.indexOf(100));
201 Expect.equals(3, list.lastIndexOf(100));
202 list[2] = 2;
203 Expect.equals(3, list.indexOf(100));
204 Expect.equals(3, list.lastIndexOf(100));
205 list[3] = 3;
206 Expect.equals(-1, list.indexOf(100));
207 Expect.equals(-1, list.lastIndexOf(100));
208
209 }
210
211 void testTypedList(List list) { 213 void testTypedList(List list) {
212 testTypedLengthInvariantOperations(list); 214 testTypedLengthInvariantOperations(list);
213 testCannotChangeLength(list); 215 testCannotChangeLength(list);
214 } 216 }
215 217
216 void testFixedLengthList(List list) { 218 void testFixedLengthList(List list) {
217 testLengthInvariantOperations(list); 219 testLengthInvariantOperations(list);
218 testCannotChangeLength(list); 220 testCannotChangeLength(list);
219 } 221 }
220 222
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } 469 }
468 470
469 class MyFixedList<E> extends ListBase<E> { 471 class MyFixedList<E> extends ListBase<E> {
470 List<E> _source; 472 List<E> _source;
471 MyFixedList(this._source); 473 MyFixedList(this._source);
472 int get length => _source.length; 474 int get length => _source.length;
473 void set length(int length) { throw new UnsupportedError("Fixed length!"); } 475 void set length(int length) { throw new UnsupportedError("Fixed length!"); }
474 E operator[](int index) => _source[index]; 476 E operator[](int index) => _source[index];
475 void operator[]=(int index, E value) { _source[index] = value; } 477 void operator[]=(int index, E value) { _source[index] = value; }
476 } 478 }
OLDNEW
« tests/corelib/corelib.status ('K') | « tests/corelib/corelib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698