| 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 // VMOptions=--optimization_counter_threshold=10 | 7 // VMOptions=--optimization_counter_threshold=10 |
| 8 | 8 |
| 9 // Library tag to be able to run in html test framework. | 9 // Library tag to be able to run in html test framework. |
| 10 library TypedDataTest; | 10 library TypedDataTest; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 296 } |
| 297 validate(); | 297 validate(); |
| 298 for (int i = 0; i < bdata.lengthInBytes-7; i+=8) { | 298 for (int i = 0; i < bdata.lengthInBytes-7; i+=8) { |
| 299 bdata.setFloat64(i, 1.4260258159703532e-105, Endianness.LITTLE_ENDIAN); | 299 bdata.setFloat64(i, 1.4260258159703532e-105, Endianness.LITTLE_ENDIAN); |
| 300 } | 300 } |
| 301 validate(false); | 301 validate(false); |
| 302 } | 302 } |
| 303 | 303 |
| 304 testViewCreation() { | 304 testViewCreation() { |
| 305 var bytes = new Uint8List(1024).buffer; | 305 var bytes = new Uint8List(1024).buffer; |
| 306 var view = new ByteData.view(bytes, 24); | 306 var view; |
| 307 view = new ByteData.view(bytes, 24); |
| 307 Expect.equals(1000, view.lengthInBytes); | 308 Expect.equals(1000, view.lengthInBytes); |
| 308 view = new Uint8List.view(bytes, 24); | 309 view = new Uint8List.view(bytes, 24); |
| 309 Expect.equals(1000, view.lengthInBytes); | 310 Expect.equals(1000, view.lengthInBytes); |
| 310 view = new Int8List.view(bytes, 24); | 311 view = new Int8List.view(bytes, 24); |
| 311 Expect.equals(1000, view.lengthInBytes); | 312 Expect.equals(1000, view.lengthInBytes); |
| 312 view = new Uint8ClampedList.view(bytes, 24); | 313 view = new Uint8ClampedList.view(bytes, 24); |
| 313 Expect.equals(1000, view.lengthInBytes); | 314 Expect.equals(1000, view.lengthInBytes); |
| 314 view = new Uint16List.view(bytes, 24); | 315 view = new Uint16List.view(bytes, 24); |
| 315 Expect.equals(1000, view.lengthInBytes); | 316 Expect.equals(1000, view.lengthInBytes); |
| 316 view = new Int16List.view(bytes, 24); | 317 view = new Int16List.view(bytes, 24); |
| 317 Expect.equals(1000, view.lengthInBytes); | 318 Expect.equals(1000, view.lengthInBytes); |
| 318 view = new Uint32List.view(bytes, 24); | 319 view = new Uint32List.view(bytes, 24); |
| 319 Expect.equals(1000, view.lengthInBytes); | 320 Expect.equals(1000, view.lengthInBytes); |
| 320 view = new Int32List.view(bytes, 24); | 321 view = new Int32List.view(bytes, 24); |
| 321 Expect.equals(1000, view.lengthInBytes); | 322 Expect.equals(1000, view.lengthInBytes); |
| 322 view = new Uint64List.view(bytes, 24); | 323 view = new Uint64List.view(bytes, 24); |
| 323 Expect.equals(1000, view.lengthInBytes); | 324 Expect.equals(1000, view.lengthInBytes); |
| 324 view = new Int64List.view(bytes, 24); | 325 view = new Int64List.view(bytes, 24); |
| 325 Expect.equals(1000, view.lengthInBytes); | 326 Expect.equals(1000, view.lengthInBytes); |
| 326 view = new Float32List.view(bytes, 24); | 327 view = new Float32List.view(bytes, 24); |
| 327 Expect.equals(1000, view.lengthInBytes); | 328 Expect.equals(1000, view.lengthInBytes); |
| 328 view = new Float64List.view(bytes, 24); | 329 view = new Float64List.view(bytes, 24); |
| 329 Expect.equals(1000, view.lengthInBytes); | 330 Expect.equals(1000, view.lengthInBytes); |
| 331 view = new Int32x4List.view(bytes, 16); |
| 332 Expect.equals(1008, view.lengthInBytes); // Must be 16-byte aligned. |
| 333 view = new Float32x4List.view(bytes, 16); |
| 334 Expect.equals(1008, view.lengthInBytes); |
| 335 view = new Float64x2List.view(bytes, 16); |
| 336 Expect.equals(1008, view.lengthInBytes); |
| 337 |
| 338 view = bytes.asByteData(24); |
| 339 Expect.equals(1000, view.lengthInBytes); |
| 340 view = bytes.asUint8List(24); |
| 341 Expect.equals(1000, view.lengthInBytes); |
| 342 view = bytes.asInt8List(24); |
| 343 Expect.equals(1000, view.lengthInBytes); |
| 344 view = bytes.asUint8ClampedList(24); |
| 345 Expect.equals(1000, view.lengthInBytes); |
| 346 view = bytes.asUint16List(24); |
| 347 Expect.equals(1000, view.lengthInBytes); |
| 348 view = bytes.asInt16List(24); |
| 349 Expect.equals(1000, view.lengthInBytes); |
| 350 view = bytes.asUint32List(24); |
| 351 Expect.equals(1000, view.lengthInBytes); |
| 352 view = bytes.asInt32List(24); |
| 353 Expect.equals(1000, view.lengthInBytes); |
| 354 view = bytes.asUint64List(24); |
| 355 Expect.equals(1000, view.lengthInBytes); |
| 356 view = bytes.asInt64List(24); |
| 357 Expect.equals(1000, view.lengthInBytes); |
| 358 view = bytes.asFloat32List(24); |
| 359 Expect.equals(1000, view.lengthInBytes); |
| 360 view = bytes.asFloat64List(24); |
| 361 Expect.equals(1000, view.lengthInBytes); |
| 362 view = bytes.asInt32x4List(16); |
| 363 Expect.equals(1008, view.lengthInBytes); |
| 364 view = bytes.asFloat32x4List(16); |
| 365 Expect.equals(1008, view.lengthInBytes); |
| 366 view = bytes.asFloat64x2List(16); |
| 367 Expect.equals(1008, view.lengthInBytes); |
| 368 |
| 369 view = bytes.asByteData(24, 800); |
| 370 Expect.equals(800, view.lengthInBytes); |
| 371 view = bytes.asUint8List(24, 800); |
| 372 Expect.equals(800, view.lengthInBytes); |
| 373 view = bytes.asInt8List(24, 800); |
| 374 Expect.equals(800, view.lengthInBytes); |
| 375 view = bytes.asUint8ClampedList(24, 800); |
| 376 Expect.equals(800, view.lengthInBytes); |
| 377 view = bytes.asUint16List(24, 400); |
| 378 Expect.equals(800, view.lengthInBytes); |
| 379 view = bytes.asInt16List(24, 400); |
| 380 Expect.equals(800, view.lengthInBytes); |
| 381 view = bytes.asUint32List(24, 200 ); |
| 382 Expect.equals(800, view.lengthInBytes); |
| 383 view = bytes.asInt32List(24, 200); |
| 384 Expect.equals(800, view.lengthInBytes); |
| 385 view = bytes.asUint64List(24, 100); |
| 386 Expect.equals(800, view.lengthInBytes); |
| 387 view = bytes.asInt64List(24, 100); |
| 388 Expect.equals(800, view.lengthInBytes); |
| 389 view = bytes.asFloat32List(24, 200); |
| 390 Expect.equals(800, view.lengthInBytes); |
| 391 view = bytes.asFloat64List(24, 100); |
| 392 Expect.equals(800, view.lengthInBytes); |
| 393 view = bytes.asInt32x4List(32, 50); |
| 394 Expect.equals(800, view.lengthInBytes); |
| 395 view = bytes.asFloat32x4List(32, 50); |
| 396 Expect.equals(800, view.lengthInBytes); |
| 397 view = bytes.asFloat64x2List(32, 50); |
| 398 Expect.equals(800, view.lengthInBytes); |
| 330 } | 399 } |
| 331 | 400 |
| 332 testWhere() { | 401 testWhere() { |
| 333 var bytes = new Uint8List(13); | 402 var bytes = new Uint8List(13); |
| 334 bytes.setRange(0, 5, [1, 1, 1, 1, 1]); | 403 bytes.setRange(0, 5, [1, 1, 1, 1, 1]); |
| 335 Expect.equals(5, bytes.where((v) => v > 0).length); | 404 Expect.equals(5, bytes.where((v) => v > 0).length); |
| 336 } | 405 } |
| 337 | 406 |
| 338 testCreationFromList() { | 407 testCreationFromList() { |
| 339 var intList = | 408 var intList = |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 testSetAtIndex(float64list, 1.4260258159703532e-105, true); | 480 testSetAtIndex(float64list, 1.4260258159703532e-105, true); |
| 412 testGetAtIndex(float64list, 1.4260258159703532e-105); | 481 testGetAtIndex(float64list, 1.4260258159703532e-105); |
| 413 } | 482 } |
| 414 testTypedDataRange(true); | 483 testTypedDataRange(true); |
| 415 testUnsignedTypedDataRange(true); | 484 testUnsignedTypedDataRange(true); |
| 416 testViewCreation(); | 485 testViewCreation(); |
| 417 testWhere(); | 486 testWhere(); |
| 418 testCreationFromList(); | 487 testCreationFromList(); |
| 419 } | 488 } |
| 420 | 489 |
| OLD | NEW |