Chromium Code Reviews| 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); | |
|
Søren Gjesse
2014/07/02 13:06:14
Please add tests passing the length optional argum
| |
| 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 | |
| 332 view = bytes.asByteData(24); | |
| 333 Expect.equals(1000, view.lengthInBytes); | |
| 334 view = bytes.asUint8List(24); | |
| 335 Expect.equals(1000, view.lengthInBytes); | |
| 336 view = bytes.asInt8List(24); | |
| 337 Expect.equals(1000, view.lengthInBytes); | |
| 338 view = bytes.asUint8ClampedList(24); | |
| 339 Expect.equals(1000, view.lengthInBytes); | |
| 340 view = bytes.asUint16List(24); | |
| 341 Expect.equals(1000, view.lengthInBytes); | |
| 342 view = bytes.asInt16List(24); | |
| 343 Expect.equals(1000, view.lengthInBytes); | |
| 344 view = bytes.asUint32List(24); | |
| 345 Expect.equals(1000, view.lengthInBytes); | |
| 346 view = bytes.asInt32List(24); | |
| 347 Expect.equals(1000, view.lengthInBytes); | |
| 348 view = bytes.asUint64List(24); | |
| 349 Expect.equals(1000, view.lengthInBytes); | |
| 350 view = bytes.asInt64List(24); | |
| 351 Expect.equals(1000, view.lengthInBytes); | |
| 352 view = bytes.asFloat32List(24); | |
| 353 Expect.equals(1000, view.lengthInBytes); | |
| 354 view = bytes.asFloat64List(24); | |
| 355 Expect.equals(1000, view.lengthInBytes); | |
| 330 } | 356 } |
| 331 | 357 |
| 332 testWhere() { | 358 testWhere() { |
| 333 var bytes = new Uint8List(13); | 359 var bytes = new Uint8List(13); |
| 334 bytes.setRange(0, 5, [1, 1, 1, 1, 1]); | 360 bytes.setRange(0, 5, [1, 1, 1, 1, 1]); |
| 335 Expect.equals(5, bytes.where((v) => v > 0).length); | 361 Expect.equals(5, bytes.where((v) => v > 0).length); |
| 336 } | 362 } |
| 337 | 363 |
| 338 testCreationFromList() { | 364 testCreationFromList() { |
| 339 var intList = | 365 var intList = |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 testSetAtIndex(float64list, 1.4260258159703532e-105, true); | 437 testSetAtIndex(float64list, 1.4260258159703532e-105, true); |
| 412 testGetAtIndex(float64list, 1.4260258159703532e-105); | 438 testGetAtIndex(float64list, 1.4260258159703532e-105); |
| 413 } | 439 } |
| 414 testTypedDataRange(true); | 440 testTypedDataRange(true); |
| 415 testUnsignedTypedDataRange(true); | 441 testUnsignedTypedDataRange(true); |
| 416 testViewCreation(); | 442 testViewCreation(); |
| 417 testWhere(); | 443 testWhere(); |
| 418 testCreationFromList(); | 444 testCreationFromList(); |
| 419 } | 445 } |
| 420 | 446 |
| OLD | NEW |