| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Library tag to be able to run in html test framework. | 5 // Library tag to be able to run in html test framework. |
| 6 library byte_array_test; | 6 library byte_array_test; |
| 7 | 7 |
| 8 import 'dart:scalarlist'; | 8 import 'dart:scalarlist'; |
| 9 | 9 |
| 10 class ByteArrayTest { | 10 class ByteArrayTest { |
| 11 static testInt8List() { | 11 static testInt8ListImpl(Int8List array) { |
| 12 Expect.throws(() { new Int8List(-1); }, | |
| 13 (e) { return e is ArgumentError; }); | |
| 14 var array = new Int8List(10); | |
| 15 Expect.isTrue(array is List<int>); | 12 Expect.isTrue(array is List<int>); |
| 16 Expect.equals(10, array.length); | 13 Expect.equals(10, array.length); |
| 17 Expect.equals(1, array.bytesPerElement()); | 14 Expect.equals(1, array.bytesPerElement()); |
| 18 Expect.equals(10, array.lengthInBytes()); | 15 Expect.equals(10, array.lengthInBytes()); |
| 19 Expect.listEquals([0, 0, 0, 0, 0, | 16 Expect.listEquals([0, 0, 0, 0, 0, |
| 20 0, 0, 0, 0, 0], | 17 0, 0, 0, 0, 0], |
| 21 array); | 18 array); |
| 22 Expect.throws(() { array[-1] = 0; }, | 19 Expect.throws(() { array[-1] = 0; }, |
| 23 (e) { return e is RangeError; }); | 20 (e) { return e is RangeError; }); |
| 24 Expect.throws(() { return array[-1]; }, | 21 Expect.throws(() { return array[-1]; }, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 var empty = array.getRange(array.length, 0); | 81 var empty = array.getRange(array.length, 0); |
| 85 Expect.equals(0, empty.length); | 82 Expect.equals(0, empty.length); |
| 86 var region = array.getRange(3, array.length - 6); | 83 var region = array.getRange(3, array.length - 6); |
| 87 Expect.isTrue(copy is Int8List); | 84 Expect.isTrue(copy is Int8List); |
| 88 Expect.equals(4, region.length); | 85 Expect.equals(4, region.length); |
| 89 Expect.listEquals([3, 4, 5, 6], region); | 86 Expect.listEquals([3, 4, 5, 6], region); |
| 90 array.setRange(3, 4, [-128, 0, 1, 127]); | 87 array.setRange(3, 4, [-128, 0, 1, 127]); |
| 91 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], | 88 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], |
| 92 array); | 89 array); |
| 93 } | 90 } |
| 91 static testInt8List() { |
| 92 Expect.throws(() { new Int8List(-1); }, |
| 93 (e) { return e is ArgumentError; }); |
| 94 Expect.throws(() { new Int8List.transferrable(-1); }, |
| 95 (e) { return e is ArgumentError; }); |
| 96 var array = new Int8List(10); |
| 97 testInt8ListImpl(array); |
| 98 array = new Int8List.transferrable(10); |
| 99 testInt8ListImpl(array); |
| 100 } |
| 94 | 101 |
| 95 static testUint8List() { | 102 static testUint8ListImpl(Uint8List array) { |
| 96 Expect.throws(() { new Uint8List(-1); }, | |
| 97 (e) { return e is ArgumentError; }); | |
| 98 var array = new Uint8List(10); | |
| 99 Expect.isTrue(array is List<int>); | 103 Expect.isTrue(array is List<int>); |
| 100 Expect.equals(10, array.length); | 104 Expect.equals(10, array.length); |
| 101 Expect.equals(1, array.bytesPerElement()); | 105 Expect.equals(1, array.bytesPerElement()); |
| 102 Expect.equals(10, array.lengthInBytes()); | 106 Expect.equals(10, array.lengthInBytes()); |
| 103 Expect.listEquals([0, 0, 0, 0, 0, | 107 Expect.listEquals([0, 0, 0, 0, 0, |
| 104 0, 0, 0, 0, 0], | 108 0, 0, 0, 0, 0], |
| 105 array); | 109 array); |
| 106 Expect.throws(() { array[-1] = 0; }, | 110 Expect.throws(() { array[-1] = 0; }, |
| 107 (e) { return e is RangeError; }); | 111 (e) { return e is RangeError; }); |
| 108 Expect.throws(() { return array[-1]; }, | 112 Expect.throws(() { return array[-1]; }, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 Expect.equals(0, empty.length); | 161 Expect.equals(0, empty.length); |
| 158 var region = array.getRange(3, array.length - 6); | 162 var region = array.getRange(3, array.length - 6); |
| 159 Expect.isTrue(copy is Uint8List); | 163 Expect.isTrue(copy is Uint8List); |
| 160 Expect.equals(4, region.length); | 164 Expect.equals(4, region.length); |
| 161 Expect.listEquals([3, 4, 5, 6], region); | 165 Expect.listEquals([3, 4, 5, 6], region); |
| 162 array.setRange(3, 4, [257, 0, 1, 255]); | 166 array.setRange(3, 4, [257, 0, 1, 255]); |
| 163 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], | 167 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], |
| 164 array); | 168 array); |
| 165 } | 169 } |
| 166 | 170 |
| 167 static testInt16List() { | 171 static testUint8List() { |
| 168 Expect.throws(() { new Int16List(-1); }, | 172 Expect.throws(() { new Uint8List(-1); }, |
| 169 (e) { return e is ArgumentError; }); | 173 (e) { return e is ArgumentError; }); |
| 170 var array = new Int16List(10); | 174 Expect.throws(() { new Uint8List.transferrable(-1); }, |
| 175 (e) { return e is ArgumentError; }); |
| 176 var array = new Uint8List(10); |
| 177 testUint8ListImpl(array); |
| 178 array = new Uint8List.transferrable(10); |
| 179 testUint8ListImpl(array); |
| 180 } |
| 181 |
| 182 static testInt16ListImpl(Int16List array) { |
| 171 Expect.isTrue(array is List<int>); | 183 Expect.isTrue(array is List<int>); |
| 172 Expect.equals(10, array.length); | 184 Expect.equals(10, array.length); |
| 173 Expect.equals(2, array.bytesPerElement()); | 185 Expect.equals(2, array.bytesPerElement()); |
| 174 Expect.equals(20, array.lengthInBytes()); | 186 Expect.equals(20, array.lengthInBytes()); |
| 175 Expect.listEquals([0, 0, 0, 0, 0, | 187 Expect.listEquals([0, 0, 0, 0, 0, |
| 176 0, 0, 0, 0, 0], | 188 0, 0, 0, 0, 0], |
| 177 array); | 189 array); |
| 178 Expect.throws(() { array[-1] = 0; }, | 190 Expect.throws(() { array[-1] = 0; }, |
| 179 (e) { return e is RangeError; }); | 191 (e) { return e is RangeError; }); |
| 180 Expect.throws(() { return array[-1]; }, | 192 Expect.throws(() { return array[-1]; }, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 Expect.equals(0, empty.length); | 253 Expect.equals(0, empty.length); |
| 242 var region = array.getRange(3, array.length - 6); | 254 var region = array.getRange(3, array.length - 6); |
| 243 Expect.isTrue(copy is Int16List); | 255 Expect.isTrue(copy is Int16List); |
| 244 Expect.equals(4, region.length); | 256 Expect.equals(4, region.length); |
| 245 Expect.listEquals([3, 4, 5, 6], region); | 257 Expect.listEquals([3, 4, 5, 6], region); |
| 246 array.setRange(3, 4, [-32768, 0, 1, 32767]); | 258 array.setRange(3, 4, [-32768, 0, 1, 32767]); |
| 247 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], | 259 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], |
| 248 array); | 260 array); |
| 249 } | 261 } |
| 250 | 262 |
| 251 static testUint16List() { | 263 static testInt16List() { |
| 252 Expect.throws(() { new Uint16List(-1); }, | 264 Expect.throws(() { new Int16List(-1); }, |
| 253 (e) { return e is ArgumentError; }); | 265 (e) { return e is ArgumentError; }); |
| 254 var array = new Uint16List(10); | 266 Expect.throws(() { new Int16List.transferrable(-1); }, |
| 267 (e) { return e is ArgumentError; }); |
| 268 var array = new Int16List(10); |
| 269 testInt16ListImpl(array); |
| 270 array = new Int16List.transferrable(10); |
| 271 testInt16ListImpl(array); |
| 272 } |
| 273 |
| 274 static testUint16ListImpl(Uint16List array) { |
| 255 Expect.isTrue(array is List<int>); | 275 Expect.isTrue(array is List<int>); |
| 256 Expect.equals(10, array.length); | 276 Expect.equals(10, array.length); |
| 257 Expect.equals(2, array.bytesPerElement()); | 277 Expect.equals(2, array.bytesPerElement()); |
| 258 Expect.equals(20, array.lengthInBytes()); | 278 Expect.equals(20, array.lengthInBytes()); |
| 259 Expect.listEquals([0, 0, 0, 0, 0, | 279 Expect.listEquals([0, 0, 0, 0, 0, |
| 260 0, 0, 0, 0, 0], | 280 0, 0, 0, 0, 0], |
| 261 array); | 281 array); |
| 262 Expect.throws(() { array[-1] = 0; }, | 282 Expect.throws(() { array[-1] = 0; }, |
| 263 (e) { return e is RangeError; }); | 283 (e) { return e is RangeError; }); |
| 264 Expect.throws(() { return array[-1]; }, | 284 Expect.throws(() { return array[-1]; }, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 Expect.equals(0, empty.length); | 333 Expect.equals(0, empty.length); |
| 314 var region = array.getRange(3, array.length - 6); | 334 var region = array.getRange(3, array.length - 6); |
| 315 Expect.isTrue(copy is Uint16List); | 335 Expect.isTrue(copy is Uint16List); |
| 316 Expect.equals(4, region.length); | 336 Expect.equals(4, region.length); |
| 317 Expect.listEquals([3, 4, 5, 6], region); | 337 Expect.listEquals([3, 4, 5, 6], region); |
| 318 array.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); | 338 array.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); |
| 319 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], | 339 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], |
| 320 array); | 340 array); |
| 321 } | 341 } |
| 322 | 342 |
| 323 static testInt32List() { | 343 static testUint16List() { |
| 324 Expect.throws(() { new Int32List(-1); }, | 344 Expect.throws(() { new Uint16List(-1); }, |
| 325 (e) { return e is ArgumentError; }); | 345 (e) { return e is ArgumentError; }); |
| 326 var array = new Int32List(10); | 346 Expect.throws(() { new Uint16List.transferrable(-1); }, |
| 347 (e) { return e is ArgumentError; }); |
| 348 var array = new Uint16List(10); |
| 349 testUint16ListImpl(array); |
| 350 array = new Uint16List.transferrable(10); |
| 351 testUint16ListImpl(array); |
| 352 } |
| 353 |
| 354 static testInt32ListImpl(Int32List array) { |
| 327 Expect.isTrue(array is List<int>); | 355 Expect.isTrue(array is List<int>); |
| 328 Expect.equals(10, array.length); | 356 Expect.equals(10, array.length); |
| 329 Expect.equals(4, array.bytesPerElement()); | 357 Expect.equals(4, array.bytesPerElement()); |
| 330 Expect.equals(40, array.lengthInBytes()); | 358 Expect.equals(40, array.lengthInBytes()); |
| 331 Expect.listEquals([0, 0, 0, 0, 0, | 359 Expect.listEquals([0, 0, 0, 0, 0, |
| 332 0, 0, 0, 0, 0], | 360 0, 0, 0, 0, 0], |
| 333 array); | 361 array); |
| 334 Expect.throws(() { array[-1] = 0; }, | 362 Expect.throws(() { array[-1] = 0; }, |
| 335 (e) { return e is RangeError; }); | 363 (e) { return e is RangeError; }); |
| 336 Expect.throws(() { return array[-1]; }, | 364 Expect.throws(() { return array[-1]; }, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 Expect.equals(0, empty.length); | 431 Expect.equals(0, empty.length); |
| 404 var region = array.getRange(3, array.length - 6); | 432 var region = array.getRange(3, array.length - 6); |
| 405 Expect.isTrue(copy is Int32List); | 433 Expect.isTrue(copy is Int32List); |
| 406 Expect.equals(4, region.length); | 434 Expect.equals(4, region.length); |
| 407 Expect.listEquals([3, 4, 5, 6], region); | 435 Expect.listEquals([3, 4, 5, 6], region); |
| 408 array.setRange(3, 4, [-0x80000000, 0, 1, 0x7FFFFFFF]); | 436 array.setRange(3, 4, [-0x80000000, 0, 1, 0x7FFFFFFF]); |
| 409 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], | 437 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], |
| 410 array); | 438 array); |
| 411 } | 439 } |
| 412 | 440 |
| 413 static testUint32List() { | 441 static testInt32List() { |
| 414 Expect.throws(() { new Uint32List(-1); }, | 442 Expect.throws(() { new Int32List(-1); }, |
| 415 (e) { return e is ArgumentError; }); | 443 (e) { return e is ArgumentError; }); |
| 416 var array = new Uint32List(10); | 444 Expect.throws(() { new Int32List.transferrable(-1); }, |
| 445 (e) { return e is ArgumentError; }); |
| 446 var array = new Int32List(10); |
| 447 testInt32ListImpl(array); |
| 448 array = new Int32List.transferrable(10); |
| 449 testInt32ListImpl(array); |
| 450 } |
| 451 |
| 452 static testUint32ListImpl(Uint32List array) { |
| 417 Expect.isTrue(array is List<int>); | 453 Expect.isTrue(array is List<int>); |
| 418 Expect.equals(10, array.length); | 454 Expect.equals(10, array.length); |
| 419 Expect.equals(4, array.bytesPerElement()); | 455 Expect.equals(4, array.bytesPerElement()); |
| 420 Expect.equals(40, array.lengthInBytes()); | 456 Expect.equals(40, array.lengthInBytes()); |
| 421 Expect.listEquals([0, 0, 0, 0, 0, | 457 Expect.listEquals([0, 0, 0, 0, 0, |
| 422 0, 0, 0, 0, 0], | 458 0, 0, 0, 0, 0], |
| 423 array); | 459 array); |
| 424 Expect.throws(() { array[-1] = 0; }, | 460 Expect.throws(() { array[-1] = 0; }, |
| 425 (e) { return e is RangeError; }); | 461 (e) { return e is RangeError; }); |
| 426 Expect.throws(() { return array[-1]; }, | 462 Expect.throws(() { return array[-1]; }, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 Expect.equals(0, empty.length); | 514 Expect.equals(0, empty.length); |
| 479 var region = array.getRange(3, array.length - 6); | 515 var region = array.getRange(3, array.length - 6); |
| 480 Expect.isTrue(copy is Uint32List); | 516 Expect.isTrue(copy is Uint32List); |
| 481 Expect.equals(4, region.length); | 517 Expect.equals(4, region.length); |
| 482 Expect.listEquals([3, 4, 5, 6], region); | 518 Expect.listEquals([3, 4, 5, 6], region); |
| 483 array.setRange(3, 4, [0x100000001, 0, 1, 0xFFFFFFFF]); | 519 array.setRange(3, 4, [0x100000001, 0, 1, 0xFFFFFFFF]); |
| 484 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], | 520 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], |
| 485 array); | 521 array); |
| 486 } | 522 } |
| 487 | 523 |
| 488 static testInt64List() { | 524 static testUint32List() { |
| 489 Expect.throws(() { new Int64List(-1); }, | 525 Expect.throws(() { new Uint32List(-1); }, |
| 490 (e) { return e is ArgumentError; }); | 526 (e) { return e is ArgumentError; }); |
| 491 var array = new Int64List(10); | 527 Expect.throws(() { new Uint32List(-1); }, |
| 528 (e) { return e is ArgumentError; }); |
| 529 var array = new Uint32List(10); |
| 530 testUint32ListImpl(array); |
| 531 array = new Uint32List.transferrable(10); |
| 532 testUint32ListImpl(array); |
| 533 |
| 534 } |
| 535 |
| 536 static testInt64ListImpl(Int64List array) { |
| 492 Expect.isTrue(array is List<int>); | 537 Expect.isTrue(array is List<int>); |
| 493 Expect.equals(10, array.length); | 538 Expect.equals(10, array.length); |
| 494 Expect.equals(8, array.bytesPerElement()); | 539 Expect.equals(8, array.bytesPerElement()); |
| 495 Expect.equals(80, array.lengthInBytes()); | 540 Expect.equals(80, array.lengthInBytes()); |
| 496 Expect.listEquals([0, 0, 0, 0, 0, | 541 Expect.listEquals([0, 0, 0, 0, 0, |
| 497 0, 0, 0, 0, 0], | 542 0, 0, 0, 0, 0], |
| 498 array); | 543 array); |
| 499 Expect.throws(() { array[-1] = 0; }, | 544 Expect.throws(() { array[-1] = 0; }, |
| 500 (e) { return e is RangeError; }); | 545 (e) { return e is RangeError; }); |
| 501 Expect.throws(() { return array[-1]; }, | 546 Expect.throws(() { return array[-1]; }, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 var region = array.getRange(3, array.length - 6); | 614 var region = array.getRange(3, array.length - 6); |
| 570 Expect.isTrue(copy is Int64List); | 615 Expect.isTrue(copy is Int64List); |
| 571 Expect.equals(4, region.length); | 616 Expect.equals(4, region.length); |
| 572 Expect.listEquals([3, 4, 5, 6], region); | 617 Expect.listEquals([3, 4, 5, 6], region); |
| 573 array.setRange(3, 4, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); | 618 array.setRange(3, 4, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); |
| 574 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, | 619 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, |
| 575 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], | 620 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], |
| 576 array); | 621 array); |
| 577 } | 622 } |
| 578 | 623 |
| 579 static testUint64List() { | 624 static testInt64List() { |
| 580 Expect.throws(() { new Uint64List(-1); }, | 625 Expect.throws(() { new Int64List(-1); }, |
| 581 (e) { return e is ArgumentError; }); | 626 (e) { return e is ArgumentError; }); |
| 582 var array = new Uint64List(10); | 627 Expect.throws(() { new Int64List.transferrable(-1); }, |
| 628 (e) { return e is ArgumentError; }); |
| 629 var array = new Int64List(10); |
| 630 testInt64ListImpl(array); |
| 631 array = new Int64List.transferrable(10); |
| 632 testInt64ListImpl(array); |
| 633 } |
| 634 |
| 635 static testUint64ListImpl(Uint64List array) { |
| 583 Expect.isTrue(array is List<int>); | 636 Expect.isTrue(array is List<int>); |
| 584 Expect.equals(10, array.length); | 637 Expect.equals(10, array.length); |
| 585 Expect.equals(8, array.bytesPerElement()); | 638 Expect.equals(8, array.bytesPerElement()); |
| 586 Expect.equals(80, array.lengthInBytes()); | 639 Expect.equals(80, array.lengthInBytes()); |
| 587 Expect.listEquals([0, 0, 0, 0, 0, | 640 Expect.listEquals([0, 0, 0, 0, 0, |
| 588 0, 0, 0, 0, 0], | 641 0, 0, 0, 0, 0], |
| 589 array); | 642 array); |
| 590 Expect.throws(() { array[-1] = 0; }, | 643 Expect.throws(() { array[-1] = 0; }, |
| 591 (e) { return e is RangeError; }); | 644 (e) { return e is RangeError; }); |
| 592 Expect.throws(() { return array[-1]; }, | 645 Expect.throws(() { return array[-1]; }, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 Expect.equals(0, empty.length); | 697 Expect.equals(0, empty.length); |
| 645 var region = array.getRange(3, array.length - 6); | 698 var region = array.getRange(3, array.length - 6); |
| 646 Expect.isTrue(copy is Uint64List); | 699 Expect.isTrue(copy is Uint64List); |
| 647 Expect.equals(4, region.length); | 700 Expect.equals(4, region.length); |
| 648 Expect.listEquals([3, 4, 5, 6], region); | 701 Expect.listEquals([3, 4, 5, 6], region); |
| 649 array.setRange(3, 4, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); | 702 array.setRange(3, 4, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); |
| 650 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], | 703 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], |
| 651 array); | 704 array); |
| 652 } | 705 } |
| 653 | 706 |
| 654 static testFloat32List() { | 707 static testUint64List() { |
| 655 Expect.throws(() { new Float32List(-1); }, | 708 Expect.throws(() { new Uint64List(-1); }, |
| 656 (e) { return e is ArgumentError; }); | 709 (e) { return e is ArgumentError; }); |
| 657 var array = new Float32List(10); | 710 Expect.throws(() { new Uint64List.transferrable(-1); }, |
| 711 (e) { return e is ArgumentError; }); |
| 712 var array = new Uint64List(10); |
| 713 testUint64ListImpl(array); |
| 714 array = new Uint64List.transferrable(10); |
| 715 testUint64ListImpl(array); |
| 716 } |
| 717 |
| 718 static testFloat32ListImpl(Float32List array) { |
| 658 Expect.isTrue(array is List<double>); | 719 Expect.isTrue(array is List<double>); |
| 659 Expect.equals(10, array.length); | 720 Expect.equals(10, array.length); |
| 660 Expect.equals(4, array.bytesPerElement()); | 721 Expect.equals(4, array.bytesPerElement()); |
| 661 Expect.equals(40, array.lengthInBytes()); | 722 Expect.equals(40, array.lengthInBytes()); |
| 662 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, | 723 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, |
| 663 0.0, 0.0, 0.0, 0.0, 0.0], | 724 0.0, 0.0, 0.0, 0.0, 0.0], |
| 664 array); | 725 array); |
| 665 Expect.throws(() { array[-1] = 0.0; }, | 726 Expect.throws(() { array[-1] = 0.0; }, |
| 666 (e) { return e is RangeError; }); | 727 (e) { return e is RangeError; }); |
| 667 Expect.throws(() { return array[-1]; }, | 728 Expect.throws(() { return array[-1]; }, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 var region = array.getRange(3, array.length - 6); | 767 var region = array.getRange(3, array.length - 6); |
| 707 Expect.isTrue(copy is Float32List); | 768 Expect.isTrue(copy is Float32List); |
| 708 Expect.equals(4, region.length); | 769 Expect.equals(4, region.length); |
| 709 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 770 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
| 710 array.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 771 array.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
| 711 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 772 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
| 712 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 773 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
| 713 array); | 774 array); |
| 714 } | 775 } |
| 715 | 776 |
| 716 static testFloat64List() { | 777 static testFloat32List() { |
| 717 Expect.throws(() { new Float64List(-1); }, | 778 Expect.throws(() { new Float32List(-1); }, |
| 718 (e) { return e is ArgumentError; }); | 779 (e) { return e is ArgumentError; }); |
| 719 var array = new Float64List(10); | 780 Expect.throws(() { new Float32List.transferrable(-1); }, |
| 781 (e) { return e is ArgumentError; }); |
| 782 var array = new Float32List(10); |
| 783 testFloat32ListImpl(array); |
| 784 array = new Float32List.transferrable(10); |
| 785 testFloat32ListImpl(array); |
| 786 } |
| 787 |
| 788 static testFloat64ListImpl(Float64List array) { |
| 720 Expect.isTrue(array is List<double>); | 789 Expect.isTrue(array is List<double>); |
| 721 Expect.equals(10, array.length); | 790 Expect.equals(10, array.length); |
| 722 Expect.equals(8, array.bytesPerElement()); | 791 Expect.equals(8, array.bytesPerElement()); |
| 723 Expect.equals(80, array.lengthInBytes()); | 792 Expect.equals(80, array.lengthInBytes()); |
| 724 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, | 793 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, |
| 725 0.0, 0.0, 0.0, 0.0, 0.0], | 794 0.0, 0.0, 0.0, 0.0, 0.0], |
| 726 array); | 795 array); |
| 727 Expect.throws(() { array[-1] = 0.0; }, | 796 Expect.throws(() { array[-1] = 0.0; }, |
| 728 (e) { return e is RangeError; }); | 797 (e) { return e is RangeError; }); |
| 729 Expect.throws(() { return array[-1]; }, | 798 Expect.throws(() { return array[-1]; }, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 var region = array.getRange(3, array.length - 6); | 837 var region = array.getRange(3, array.length - 6); |
| 769 Expect.isTrue(copy is Float64List); | 838 Expect.isTrue(copy is Float64List); |
| 770 Expect.equals(4, region.length); | 839 Expect.equals(4, region.length); |
| 771 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 840 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
| 772 array.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 841 array.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
| 773 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 842 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
| 774 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 843 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
| 775 array); | 844 array); |
| 776 } | 845 } |
| 777 | 846 |
| 847 static testFloat64List() { |
| 848 Expect.throws(() { new Float64List(-1); }, |
| 849 (e) { return e is ArgumentError; }); |
| 850 var array = new Float64List(10); |
| 851 testFloat64ListImpl(array); |
| 852 array = new Float64List.transferrable(10); |
| 853 testFloat64ListImpl(array); |
| 854 } |
| 855 |
| 778 static testByteList() { | 856 static testByteList() { |
| 779 var array = new Uint8List(8); | 857 var array = new Uint8List(8); |
| 780 Expect.equals(8, array.length); | 858 Expect.equals(8, array.length); |
| 781 Expect.equals(8, array.lengthInBytes()); | 859 Expect.equals(8, array.lengthInBytes()); |
| 782 var byte_array = array.asByteArray(0, array.lengthInBytes()); | 860 var byte_array = array.asByteArray(0, array.lengthInBytes()); |
| 783 Expect.equals(8, byte_array.lengthInBytes()); | 861 Expect.equals(8, byte_array.lengthInBytes()); |
| 784 Expect.throws(() { byte_array.getInt8(-1); }, | 862 Expect.throws(() { byte_array.getInt8(-1); }, |
| 785 (e) { return e is RangeError; }); | 863 (e) { return e is RangeError; }); |
| 786 Expect.throws(() { byte_array.getUint8(-1); }, | 864 Expect.throws(() { byte_array.getUint8(-1); }, |
| 787 (e) { return e is RangeError; }); | 865 (e) { return e is RangeError; }); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 Expect.equals(0xFAFB, byte_array.getUint16(4)); | 991 Expect.equals(0xFAFB, byte_array.getUint16(4)); |
| 914 Expect.equals(0xF8F9, byte_array.getUint16(6)); | 992 Expect.equals(0xF8F9, byte_array.getUint16(6)); |
| 915 Expect.equals(-1082130432, byte_array.getInt32(0)); | 993 Expect.equals(-1082130432, byte_array.getInt32(0)); |
| 916 Expect.equals(0xBF800000, byte_array.getUint32(0)); | 994 Expect.equals(0xBF800000, byte_array.getUint32(0)); |
| 917 Expect.equals(-506097523945897984, byte_array.getInt64(0)); | 995 Expect.equals(-506097523945897984, byte_array.getInt64(0)); |
| 918 Expect.equals(0xF8F9FAFBBF800000, byte_array.getUint64(0)); | 996 Expect.equals(0xF8F9FAFBBF800000, byte_array.getUint64(0)); |
| 919 Expect.equals(-1.0, byte_array.getFloat32(0)); | 997 Expect.equals(-1.0, byte_array.getFloat32(0)); |
| 920 // TODO: byte_array.getFloat64(0) | 998 // TODO: byte_array.getFloat64(0) |
| 921 } | 999 } |
| 922 | 1000 |
| 923 static testInt8ListView() { | 1001 static testInt8ListViewImpl(var array) { |
| 924 var array = new Uint8List(12); | |
| 925 Expect.equals(12, array.length); | 1002 Expect.equals(12, array.length); |
| 926 Expect.equals(1, array.bytesPerElement()); | 1003 Expect.equals(1, array.bytesPerElement()); |
| 927 Expect.equals(12, array.lengthInBytes()); | 1004 Expect.equals(12, array.lengthInBytes()); |
| 928 for (int i = 0; i < array.length; ++i) { | 1005 for (int i = 0; i < array.length; ++i) { |
| 929 array[i] = 0xFF; | 1006 array[i] = 0xFF; |
| 930 } | 1007 } |
| 931 Expect.throws(() { new Int8List.view(array.asByteArray(), -1); }, | 1008 Expect.throws(() { new Int8List.view(array.asByteArray(), -1); }, |
| 932 (e) { return e is RangeError; }); | 1009 (e) { return e is RangeError; }); |
| 933 Expect.throws(() { new Int8List.view(array.asByteArray(), 0, -1); }, | 1010 Expect.throws(() { new Int8List.view(array.asByteArray(), 0, -1); }, |
| 934 (e) { return e is RangeError; }); | 1011 (e) { return e is RangeError; }); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 var region = view.getRange(3, view.length - 6); | 1116 var region = view.getRange(3, view.length - 6); |
| 1040 Expect.isTrue(copy is Int8List); | 1117 Expect.isTrue(copy is Int8List); |
| 1041 Expect.equals(4, region.length); | 1118 Expect.equals(4, region.length); |
| 1042 Expect.listEquals([3, 4, 5, 6], region); | 1119 Expect.listEquals([3, 4, 5, 6], region); |
| 1043 view.setRange(3, 4, [-128, 0, 1, 127]); | 1120 view.setRange(3, 4, [-128, 0, 1, 127]); |
| 1044 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], | 1121 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], |
| 1045 view); | 1122 view); |
| 1046 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF], | 1123 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF], |
| 1047 array); | 1124 array); |
| 1048 } | 1125 } |
| 1126 static testInt8ListView() { |
| 1127 var array = new Uint8List(12); |
| 1128 testInt8ListViewImpl(array); |
| 1129 array = new Uint8List.transferrable(12); |
| 1130 testInt8ListViewImpl(array); |
| 1131 } |
| 1049 | 1132 |
| 1050 static testUint8ListView() { | 1133 static testUint8ListViewImpl(var array) { |
| 1051 var array = new Int8List(12); | |
| 1052 Expect.isTrue(array is List<int>); | 1134 Expect.isTrue(array is List<int>); |
| 1053 Expect.equals(12, array.length); | 1135 Expect.equals(12, array.length); |
| 1054 Expect.equals(1, array.bytesPerElement()); | 1136 Expect.equals(1, array.bytesPerElement()); |
| 1055 Expect.equals(12, array.lengthInBytes()); | 1137 Expect.equals(12, array.lengthInBytes()); |
| 1056 for (int i = 0; i < array.length; ++i) { | 1138 for (int i = 0; i < array.length; ++i) { |
| 1057 array[i] = -1; | 1139 array[i] = -1; |
| 1058 } | 1140 } |
| 1059 Expect.throws(() { new Uint8List.view(array.asByteArray(), -1); }, | 1141 Expect.throws(() { new Uint8List.view(array.asByteArray(), -1); }, |
| 1060 (e) { return e is RangeError; }); | 1142 (e) { return e is RangeError; }); |
| 1061 Expect.throws(() { new Uint8List.view(array.asByteArray(), 0, -1); }, | 1143 Expect.throws(() { new Uint8List.view(array.asByteArray(), 0, -1); }, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 Expect.listEquals(view, copy); | 1230 Expect.listEquals(view, copy); |
| 1149 var region = view.getRange(3, view.length - 6); | 1231 var region = view.getRange(3, view.length - 6); |
| 1150 Expect.isTrue(copy is Uint8List); | 1232 Expect.isTrue(copy is Uint8List); |
| 1151 Expect.equals(4, region.length); | 1233 Expect.equals(4, region.length); |
| 1152 Expect.listEquals([3, 4, 5, 6], region); | 1234 Expect.listEquals([3, 4, 5, 6], region); |
| 1153 view.setRange(3, 4, [257, 0, 1, 255]); | 1235 view.setRange(3, 4, [257, 0, 1, 255]); |
| 1154 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], | 1236 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], |
| 1155 view); | 1237 view); |
| 1156 } | 1238 } |
| 1157 | 1239 |
| 1158 static testInt16ListView() { | 1240 static testUint8ListView() { |
| 1159 var array = new Uint8List(24); | 1241 var array = new Int8List(12); |
| 1242 testUint8ListViewImpl(array); |
| 1243 array = new Int8List.transferrable(12); |
| 1244 testUint8ListViewImpl(array); |
| 1245 } |
| 1246 |
| 1247 static testInt16ListViewImpl(var array) { |
| 1160 Expect.equals(24, array.length); | 1248 Expect.equals(24, array.length); |
| 1161 Expect.equals(1, array.bytesPerElement()); | 1249 Expect.equals(1, array.bytesPerElement()); |
| 1162 Expect.equals(24, array.lengthInBytes()); | 1250 Expect.equals(24, array.lengthInBytes()); |
| 1163 for (int i = 0; i < array.length; ++i) { | 1251 for (int i = 0; i < array.length; ++i) { |
| 1164 array[i] = 0xFF; | 1252 array[i] = 0xFF; |
| 1165 } | 1253 } |
| 1166 Expect.throws(() { new Int16List.view(array.asByteArray(), -1); }, | 1254 Expect.throws(() { new Int16List.view(array.asByteArray(), -1); }, |
| 1167 (e) { return e is RangeError; }); | 1255 (e) { return e is RangeError; }); |
| 1168 Expect.throws(() { new Int16List.view(array.asByteArray(), 0, -1); }, | 1256 Expect.throws(() { new Int16List.view(array.asByteArray(), 0, -1); }, |
| 1169 (e) { return e is RangeError; }); | 1257 (e) { return e is RangeError; }); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1282 Expect.listEquals([3, 4, 5, 6], region); | 1370 Expect.listEquals([3, 4, 5, 6], region); |
| 1283 view.setRange(3, 4, [-32768, 0, 1, 32767]); | 1371 view.setRange(3, 4, [-32768, 0, 1, 32767]); |
| 1284 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], | 1372 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], |
| 1285 view); | 1373 view); |
| 1286 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, | 1374 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, |
| 1287 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F, | 1375 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F, |
| 1288 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], | 1376 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], |
| 1289 array); | 1377 array); |
| 1290 } | 1378 } |
| 1291 | 1379 |
| 1292 static testUint16ListView() { | 1380 static testInt16ListView() { |
| 1293 var array = new Int8List(24); | 1381 var array = new Uint8List(24); |
| 1382 testInt16ListViewImpl(array); |
| 1383 array = new Uint8List.transferrable(24); |
| 1384 testInt16ListViewImpl(array); |
| 1385 } |
| 1386 |
| 1387 static testUint16ListViewImpl(var array) { |
| 1294 Expect.isTrue(array is List<int>); | 1388 Expect.isTrue(array is List<int>); |
| 1295 Expect.equals(24, array.length); | 1389 Expect.equals(24, array.length); |
| 1296 Expect.equals(1, array.bytesPerElement()); | 1390 Expect.equals(1, array.bytesPerElement()); |
| 1297 Expect.equals(24, array.lengthInBytes()); | 1391 Expect.equals(24, array.lengthInBytes()); |
| 1298 for (int i = 0; i < array.length; ++i) { | 1392 for (int i = 0; i < array.length; ++i) { |
| 1299 array[i] = -1; | 1393 array[i] = -1; |
| 1300 } | 1394 } |
| 1301 Expect.throws(() { new Uint16List.view(array.asByteArray(), -1); }, | 1395 Expect.throws(() { new Uint16List.view(array.asByteArray(), -1); }, |
| 1302 (e) { return e is RangeError; }); | 1396 (e) { return e is RangeError; }); |
| 1303 Expect.throws(() { new Uint16List.view(array.asByteArray(), 0, -1); }, | 1397 Expect.throws(() { new Uint16List.view(array.asByteArray(), 0, -1); }, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 Expect.listEquals([3, 4, 5, 6], region); | 1489 Expect.listEquals([3, 4, 5, 6], region); |
| 1396 view.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); | 1490 view.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); |
| 1397 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], | 1491 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], |
| 1398 view); | 1492 view); |
| 1399 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, | 1493 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, |
| 1400 1, 0, 0, 0, 1, 0, -1, -1, | 1494 1, 0, 0, 0, 1, 0, -1, -1, |
| 1401 7, 0, 8, 0, 9, 0, -1, -1], | 1495 7, 0, 8, 0, 9, 0, -1, -1], |
| 1402 array); | 1496 array); |
| 1403 } | 1497 } |
| 1404 | 1498 |
| 1499 static testUint16ListView() { |
| 1500 var array = new Int8List(24); |
| 1501 testUint16ListViewImpl(array); |
| 1502 array = new Int8List.transferrable(24); |
| 1503 testUint16ListViewImpl(array); |
| 1504 } |
| 1505 |
| 1405 static testInt32ListView() { | 1506 static testInt32ListView() { |
| 1406 var array = new Uint8List(48); | 1507 var array = new Uint8List(48); |
| 1407 Expect.equals(48, array.length); | 1508 Expect.equals(48, array.length); |
| 1408 Expect.equals(1, array.bytesPerElement()); | 1509 Expect.equals(1, array.bytesPerElement()); |
| 1409 Expect.equals(48, array.lengthInBytes()); | 1510 Expect.equals(48, array.lengthInBytes()); |
| 1410 for (int i = 0; i < array.length; ++i) { | 1511 for (int i = 0; i < array.length; ++i) { |
| 1411 array[i] = 0xFF; | 1512 array[i] = 0xFF; |
| 1412 } | 1513 } |
| 1413 Expect.throws(() { new Int32List.view(array.asByteArray(), -1); }, | 1514 Expect.throws(() { new Int32List.view(array.asByteArray(), -1); }, |
| 1414 (e) { return e is RangeError; }); | 1515 (e) { return e is RangeError; }); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 view); | 1654 view); |
| 1554 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, | 1655 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, |
| 1555 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, | 1656 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 1556 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, | 1657 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, |
| 1557 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, | 1658 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, |
| 1558 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, | 1659 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, |
| 1559 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], | 1660 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], |
| 1560 array); | 1661 array); |
| 1561 } | 1662 } |
| 1562 | 1663 |
| 1563 static testUint32ListView() { | 1664 static testUint32ListViewImpl(var array) { |
| 1564 var array = new Int8List(48); | |
| 1565 Expect.isTrue(array is List<int>); | 1665 Expect.isTrue(array is List<int>); |
| 1566 Expect.equals(48, array.length); | 1666 Expect.equals(48, array.length); |
| 1567 Expect.equals(1, array.bytesPerElement()); | 1667 Expect.equals(1, array.bytesPerElement()); |
| 1568 Expect.equals(48, array.lengthInBytes()); | 1668 Expect.equals(48, array.lengthInBytes()); |
| 1569 for (int i = 0; i < array.length; ++i) { | 1669 for (int i = 0; i < array.length; ++i) { |
| 1570 array[i] = -1; | 1670 array[i] = -1; |
| 1571 } | 1671 } |
| 1572 Expect.throws(() { new Uint32List.view(array.asByteArray(), -1); }, | 1672 Expect.throws(() { new Uint32List.view(array.asByteArray(), -1); }, |
| 1573 (e) { return e is RangeError; }); | 1673 (e) { return e is RangeError; }); |
| 1574 Expect.throws(() { new Uint32List.view(array.asByteArray(), 0, -1); }, | 1674 Expect.throws(() { new Uint32List.view(array.asByteArray(), 0, -1); }, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1683 view); | 1783 view); |
| 1684 Expect.listEquals([-1, -1, -1, -1, 0, 0, 0, 0, | 1784 Expect.listEquals([-1, -1, -1, -1, 0, 0, 0, 0, |
| 1685 1, 0, 0, 0, 2, 0, 0, 0, | 1785 1, 0, 0, 0, 2, 0, 0, 0, |
| 1686 1, 0, 0, 0, 0, 0, 0, 0, | 1786 1, 0, 0, 0, 0, 0, 0, 0, |
| 1687 1, 0, 0, 0, -1, -1, -1, -1, | 1787 1, 0, 0, 0, -1, -1, -1, -1, |
| 1688 7, 0, 0, 0, 8, 0, 0, 0, | 1788 7, 0, 0, 0, 8, 0, 0, 0, |
| 1689 9, 0, 0, 0, -1, -1, -1, -1], | 1789 9, 0, 0, 0, -1, -1, -1, -1], |
| 1690 array); | 1790 array); |
| 1691 } | 1791 } |
| 1692 | 1792 |
| 1693 static testInt64ListView() { | 1793 static testUint32ListView() { |
| 1694 var array = new Uint8List(96); | 1794 var array = new Int8List(48); |
| 1795 testUint32ListViewImpl(array); |
| 1796 array = new Int8List.transferrable(48); |
| 1797 testUint32ListViewImpl(array); |
| 1798 } |
| 1799 |
| 1800 static testInt64ListViewImpl(var array) { |
| 1695 Expect.equals(96, array.length); | 1801 Expect.equals(96, array.length); |
| 1696 Expect.equals(1, array.bytesPerElement()); | 1802 Expect.equals(1, array.bytesPerElement()); |
| 1697 Expect.equals(96, array.lengthInBytes()); | 1803 Expect.equals(96, array.lengthInBytes()); |
| 1698 for (int i = 0; i < array.length; ++i) { | 1804 for (int i = 0; i < array.length; ++i) { |
| 1699 array[i] = 0xFF; | 1805 array[i] = 0xFF; |
| 1700 } | 1806 } |
| 1701 Expect.throws(() { new Int64List.view(array.asByteArray(), -1); }, | 1807 Expect.throws(() { new Int64List.view(array.asByteArray(), -1); }, |
| 1702 (e) { return e is RangeError; }); | 1808 (e) { return e is RangeError; }); |
| 1703 Expect.throws(() { new Int64List.view(array.asByteArray(), 0, -1); }, | 1809 Expect.throws(() { new Int64List.view(array.asByteArray(), 0, -1); }, |
| 1704 (e) { return e is RangeError; }); | 1810 (e) { return e is RangeError; }); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1984 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1879 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1985 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1880 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, | 1986 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, |
| 1881 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1987 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1882 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1988 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1883 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1989 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1884 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 1990 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
| 1885 array); | 1991 array); |
| 1886 } | 1992 } |
| 1887 | 1993 |
| 1888 static testUint64ListView() { | 1994 static testInt64ListView() { |
| 1889 var array = new Int8List(96); | 1995 var array = new Uint8List(96); |
| 1996 testInt64ListViewImpl(array); |
| 1997 array = new Uint8List.transferrable(96); |
| 1998 testInt64ListViewImpl(array); |
| 1999 } |
| 2000 |
| 2001 static testUint64ListViewImpl(var array) { |
| 1890 Expect.isTrue(array is List<int>); | 2002 Expect.isTrue(array is List<int>); |
| 1891 Expect.equals(96, array.length); | 2003 Expect.equals(96, array.length); |
| 1892 Expect.equals(1, array.bytesPerElement()); | 2004 Expect.equals(1, array.bytesPerElement()); |
| 1893 Expect.equals(96, array.lengthInBytes()); | 2005 Expect.equals(96, array.lengthInBytes()); |
| 1894 for (int i = 0; i < array.length; ++i) { | 2006 for (int i = 0; i < array.length; ++i) { |
| 1895 array[i] = -1; | 2007 array[i] = -1; |
| 1896 } | 2008 } |
| 1897 Expect.throws(() { new Uint64List.view(array.asByteArray(), -1); }, | 2009 Expect.throws(() { new Uint64List.view(array.asByteArray(), -1); }, |
| 1898 (e) { return e is RangeError; }); | 2010 (e) { return e is RangeError; }); |
| 1899 Expect.throws(() { new Uint64List.view(array.asByteArray(), 0, -1); }, | 2011 Expect.throws(() { new Uint64List.view(array.asByteArray(), 0, -1); }, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 0, 0, 0, 0, 0, 0, 0, 0, | 2147 0, 0, 0, 0, 0, 0, 0, 0, |
| 2036 1, 0, 0, 0, 0, 0, 0, 0, | 2148 1, 0, 0, 0, 0, 0, 0, 0, |
| 2037 -1, -1, -1, -1, -1, -1, -1, -1, | 2149 -1, -1, -1, -1, -1, -1, -1, -1, |
| 2038 7, 0, 0, 0, 0, 0, 0, 0, | 2150 7, 0, 0, 0, 0, 0, 0, 0, |
| 2039 8, 0, 0, 0, 0, 0, 0, 0, | 2151 8, 0, 0, 0, 0, 0, 0, 0, |
| 2040 9, 0, 0, 0, 0, 0, 0, 0, | 2152 9, 0, 0, 0, 0, 0, 0, 0, |
| 2041 -1, -1, -1, -1, -1, -1, -1, -1], | 2153 -1, -1, -1, -1, -1, -1, -1, -1], |
| 2042 array); | 2154 array); |
| 2043 } | 2155 } |
| 2044 | 2156 |
| 2045 static testFloat32ListView() { | 2157 static testUint64ListView() { |
| 2046 var array = new Uint32List(12); | 2158 var array = new Int8List(96); |
| 2159 testUint64ListViewImpl(array); |
| 2160 array = new Int8List.transferrable(96); |
| 2161 testUint64ListViewImpl(array); |
| 2162 } |
| 2163 |
| 2164 static testFloat32ListViewImpl(var array) { |
| 2047 Expect.isTrue(array is List<int>); | 2165 Expect.isTrue(array is List<int>); |
| 2048 Expect.equals(12, array.length); | 2166 Expect.equals(12, array.length); |
| 2049 Expect.equals(4, array.bytesPerElement()); | 2167 Expect.equals(4, array.bytesPerElement()); |
| 2050 Expect.equals(48, array.lengthInBytes()); | 2168 Expect.equals(48, array.lengthInBytes()); |
| 2051 for (int i = 0; i < array.length; ++i) { | 2169 for (int i = 0; i < array.length; ++i) { |
| 2052 array[i] = 0xBF800000; | 2170 array[i] = 0xBF800000; |
| 2053 } | 2171 } |
| 2054 Expect.throws(() { new Float32List.view(array.asByteArray(), -1); }, | 2172 Expect.throws(() { new Float32List.view(array.asByteArray(), -1); }, |
| 2055 (e) { return e is RangeError; }); | 2173 (e) { return e is RangeError; }); |
| 2056 Expect.throws(() { new Float32List.view(array.asByteArray(), 0, -1); }, | 2174 Expect.throws(() { new Float32List.view(array.asByteArray(), 0, -1); }, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2138 view); | 2256 view); |
| 2139 Expect.listEquals([0xBF800000, 0x00000000, | 2257 Expect.listEquals([0xBF800000, 0x00000000, |
| 2140 0x3F800000, 0x40000000, | 2258 0x3F800000, 0x40000000, |
| 2141 0xFF800000, 0x00000000, | 2259 0xFF800000, 0x00000000, |
| 2142 0x3F800000, 0x7F800000, | 2260 0x3F800000, 0x7F800000, |
| 2143 0x40E00000, 0x41000000, | 2261 0x40E00000, 0x41000000, |
| 2144 0x41100000, 0xBF800000], | 2262 0x41100000, 0xBF800000], |
| 2145 array); | 2263 array); |
| 2146 } | 2264 } |
| 2147 | 2265 |
| 2148 static testFloat64ListView() { | 2266 static testFloat32ListView() { |
| 2149 var array = new Uint64List(12); | 2267 var array = new Uint32List(12); |
| 2268 testFloat32ListViewImpl(array); |
| 2269 array = new Uint32List.transferrable(12); |
| 2270 testFloat32ListViewImpl(array); |
| 2271 } |
| 2272 |
| 2273 static testFloat64ListViewImpl(var array) { |
| 2150 Expect.isTrue(array is List<int>); | 2274 Expect.isTrue(array is List<int>); |
| 2151 Expect.equals(12, array.length); | 2275 Expect.equals(12, array.length); |
| 2152 Expect.equals(8, array.bytesPerElement()); | 2276 Expect.equals(8, array.bytesPerElement()); |
| 2153 Expect.equals(96, array.lengthInBytes()); | 2277 Expect.equals(96, array.lengthInBytes()); |
| 2154 for (int i = 0; i < array.length; ++i) { | 2278 for (int i = 0; i < array.length; ++i) { |
| 2155 array[i] = 0xBFF0000000000000; | 2279 array[i] = 0xBFF0000000000000; |
| 2156 } | 2280 } |
| 2157 Expect.throws(() { new Float64List.view(array.asByteArray(), -1); }, | 2281 Expect.throws(() { new Float64List.view(array.asByteArray(), -1); }, |
| 2158 (e) { return e is RangeError; }); | 2282 (e) { return e is RangeError; }); |
| 2159 Expect.throws(() { new Float64List.view(array.asByteArray(), 0, -1); }, | 2283 Expect.throws(() { new Float64List.view(array.asByteArray(), 0, -1); }, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2241 view); | 2365 view); |
| 2242 Expect.listEquals([0xBFF0000000000000, 0x0000000000000000, | 2366 Expect.listEquals([0xBFF0000000000000, 0x0000000000000000, |
| 2243 0x3FF0000000000000, 0x4000000000000000, | 2367 0x3FF0000000000000, 0x4000000000000000, |
| 2244 0xFFF0000000000000, 0x0000000000000000, | 2368 0xFFF0000000000000, 0x0000000000000000, |
| 2245 0x3FF0000000000000, 0x7FF0000000000000, | 2369 0x3FF0000000000000, 0x7FF0000000000000, |
| 2246 0x401C000000000000, 0x4020000000000000, | 2370 0x401C000000000000, 0x4020000000000000, |
| 2247 0x4022000000000000, 0xBFF0000000000000], | 2371 0x4022000000000000, 0xBFF0000000000000], |
| 2248 array); | 2372 array); |
| 2249 } | 2373 } |
| 2250 | 2374 |
| 2375 static testFloat64ListView() { |
| 2376 var array = new Uint64List(12); |
| 2377 testFloat64ListViewImpl(array); |
| 2378 array = new Uint64List.transferrable(12); |
| 2379 testFloat64ListViewImpl(array); |
| 2380 } |
| 2381 |
| 2251 static testMain() { | 2382 static testMain() { |
| 2252 testInt8List(); | 2383 testInt8List(); |
| 2253 testUint8List(); | 2384 testUint8List(); |
| 2254 testInt16List(); | 2385 testInt16List(); |
| 2255 testUint16List(); | 2386 testUint16List(); |
| 2256 testInt32List(); | 2387 testInt32List(); |
| 2257 testUint32List(); | 2388 testUint32List(); |
| 2258 testInt64List(); | 2389 testInt64List(); |
| 2259 testUint64List(); | 2390 testUint64List(); |
| 2260 testFloat32List(); | 2391 testFloat32List(); |
| 2261 testFloat64List(); | 2392 testFloat64List(); |
| 2262 testByteList(); | 2393 testByteList(); |
| 2263 testInt8ListView(); | 2394 testInt8ListView(); |
| 2264 testUint8ListView(); | 2395 testUint8ListView(); |
| 2265 testInt16ListView(); | 2396 testInt16ListView(); |
| 2266 testUint16ListView(); | 2397 testUint16ListView(); |
| 2267 testInt32ListView(); | 2398 testInt32ListView(); |
| 2268 testUint32ListView(); | 2399 testUint32ListView(); |
| 2269 testInt64ListView(); | 2400 testInt64ListView(); |
| 2270 testUint64ListView(); | 2401 testUint64ListView(); |
| 2271 testFloat32ListView(); | 2402 testFloat32ListView(); |
| 2272 testFloat64ListView(); | 2403 testFloat64ListView(); |
| 2273 } | 2404 } |
| 2274 } | 2405 } |
| 2275 | 2406 |
| 2276 main() { | 2407 main() { |
| 2277 ByteArrayTest.testMain(); | 2408 ByteArrayTest.testMain(); |
| 2278 } | 2409 } |
| OLD | NEW |