| OLD | NEW |
| 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 Loading... |
| 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 list = new Int8List.fromList(intList); |
| 321 list = new Int16List.fromList(intList); |
| 322 list = new Int32List.fromList(intList); |
| 323 list = new Int64List.fromList(intList); |
| 324 list = new Uint8List.fromList(intList); |
| 325 list = new Uint16List.fromList(intList); |
| 326 list = new Uint32List.fromList(intList); |
| 327 list = new Uint64List.fromList(intList); |
| 328 var doubleList = |
| 329 [-123123123123.123123123123, -123.0, 0.0, 123.0, 123123123123.123123123]; |
| 330 list = new Float32List.fromList(doubleList); |
| 331 list = new Float64List.fromList(doubleList); |
| 332 } |
| 333 |
| 317 main() { | 334 main() { |
| 318 for (int i = 0; i < 2000; i++) { | 335 for (int i = 0; i < 2000; i++) { |
| 319 testCreateUint8TypedData(); | 336 testCreateUint8TypedData(); |
| 320 testCreateClampedUint8TypedData(); | 337 testCreateClampedUint8TypedData(); |
| 321 testCreateExternalClampedUint8TypedData(); | 338 testCreateExternalClampedUint8TypedData(); |
| 322 testTypedDataRange(false); | 339 testTypedDataRange(false); |
| 323 testUnsignedTypedDataRange(false); | 340 testUnsignedTypedDataRange(false); |
| 324 testClampedUnsignedTypedDataRange(false); | 341 testClampedUnsignedTypedDataRange(false); |
| 325 testExternalClampedUnsignedTypedDataRange(false); | 342 testExternalClampedUnsignedTypedDataRange(false); |
| 326 testSetRange(); | 343 testSetRange(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 382 |
| 366 var float64list = new Float64List(16); | 383 var float64list = new Float64List(16); |
| 367 testSetAtIndex(float64list, 1.4260258159703532e-105, true); | 384 testSetAtIndex(float64list, 1.4260258159703532e-105, true); |
| 368 testGetAtIndex(float64list, 1.4260258159703532e-105); | 385 testGetAtIndex(float64list, 1.4260258159703532e-105); |
| 369 } | 386 } |
| 370 testTypedDataRange(true); | 387 testTypedDataRange(true); |
| 371 testUnsignedTypedDataRange(true); | 388 testUnsignedTypedDataRange(true); |
| 372 testExternalClampedUnsignedTypedDataRange(true); | 389 testExternalClampedUnsignedTypedDataRange(true); |
| 373 testViewCreation(); | 390 testViewCreation(); |
| 374 testWhere(); | 391 testWhere(); |
| 392 testCreationFromList(); |
| 375 } | 393 } |
| 376 | 394 |
| OLD | NEW |