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

Side by Side Diff: tests/standalone/typed_data_test.dart

Issue 13834008: Add fromList constructor to typeddata typed lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test for mixing int and double lists. 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
« no previous file with comments | « sdk/lib/typeddata/typeddata.dart ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Dart test program for testing typed data. 5 // Dart test program for testing typed data.
6 6
7 // Library tag to be able to run in html test framework. 7 // Library tag to be able to run in html test framework.
8 library TypedDataTest; 8 library TypedDataTest;
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 view = new Float64List.view(bytes, 24); 307 view = new Float64List.view(bytes, 24);
308 Expect.equals(1000, view.lengthInBytes); 308 Expect.equals(1000, view.lengthInBytes);
309 } 309 }
310 310
311 testWhere() { 311 testWhere() {
312 var bytes = new Uint8List(13); 312 var bytes = new Uint8List(13);
313 bytes.setRange(0, 5, [1, 1, 1, 1, 1]); 313 bytes.setRange(0, 5, [1, 1, 1, 1, 1]);
314 Expect.equals(5, bytes.where((v) => v > 0).length); 314 Expect.equals(5, bytes.where((v) => v > 0).length);
315 } 315 }
316 316
317 testCreationFromList() {
318 var intList =
319 [-10000000000000000000, -255, -127, 0, 128, 256, 1000000000000000000000];
320 var intLists = [];
321 intLists.add(new Int8List.fromList(intList));
322 intLists.add(new Int16List.fromList(intList));
323 intLists.add(new Int32List.fromList(intList));
324 intLists.add(new Int64List.fromList(intList));
325 intLists.add(new Uint8List.fromList(intList));
326 intLists.add(new Uint16List.fromList(intList));
327 intLists.add(new Uint32List.fromList(intList));
328 intLists.add(new Uint64List.fromList(intList));
329 var doubleList =
330 [-123123123123.123123123123, -123.0, 0.0, 123.0, 123123123123.123123123];
331 var doubleLists = [];
332 doubleLists.add(new Float32List.fromList(doubleList));
333 doubleLists.add(new Float64List.fromList(doubleList));
334 for (var ints in intLists) {
335 for (var doubles in doubleLists) {
336 Expect.throws(() => ints[0] = doubles[0]);
337 Expect.throws(() => doubles[0] = ints[0]);
338 }
339 }
340 }
341
317 main() { 342 main() {
318 for (int i = 0; i < 2000; i++) { 343 for (int i = 0; i < 2000; i++) {
319 testCreateUint8TypedData(); 344 testCreateUint8TypedData();
320 testCreateClampedUint8TypedData(); 345 testCreateClampedUint8TypedData();
321 testCreateExternalClampedUint8TypedData(); 346 testCreateExternalClampedUint8TypedData();
322 testTypedDataRange(false); 347 testTypedDataRange(false);
323 testUnsignedTypedDataRange(false); 348 testUnsignedTypedDataRange(false);
324 testClampedUnsignedTypedDataRange(false); 349 testClampedUnsignedTypedDataRange(false);
325 testExternalClampedUnsignedTypedDataRange(false); 350 testExternalClampedUnsignedTypedDataRange(false);
326 testSetRange(); 351 testSetRange();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 390
366 var float64list = new Float64List(16); 391 var float64list = new Float64List(16);
367 testSetAtIndex(float64list, 1.4260258159703532e-105, true); 392 testSetAtIndex(float64list, 1.4260258159703532e-105, true);
368 testGetAtIndex(float64list, 1.4260258159703532e-105); 393 testGetAtIndex(float64list, 1.4260258159703532e-105);
369 } 394 }
370 testTypedDataRange(true); 395 testTypedDataRange(true);
371 testUnsignedTypedDataRange(true); 396 testUnsignedTypedDataRange(true);
372 testExternalClampedUnsignedTypedDataRange(true); 397 testExternalClampedUnsignedTypedDataRange(true);
373 testViewCreation(); 398 testViewCreation();
374 testWhere(); 399 testWhere();
400 testCreationFromList();
375 } 401 }
376 402
OLDNEW
« no previous file with comments | « sdk/lib/typeddata/typeddata.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698