| 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 { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 Expect.isTrue(copy is Int8List); | 84 Expect.isTrue(copy is Int8List); |
| 85 Expect.equals(4, region.length); | 85 Expect.equals(4, region.length); |
| 86 Expect.listEquals([3, 4, 5, 6], region); | 86 Expect.listEquals([3, 4, 5, 6], region); |
| 87 array.setRange(3, 4, [-128, 0, 1, 127]); | 87 array.setRange(3, 4, [-128, 0, 1, 127]); |
| 88 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], |
| 89 array); | 89 array); |
| 90 } | 90 } |
| 91 static testInt8List() { | 91 static testInt8List() { |
| 92 Expect.throws(() { new Int8List(-1); }, | 92 Expect.throws(() { new Int8List(-1); }, |
| 93 (e) { return e is ArgumentError; }); | 93 (e) { return e is ArgumentError; }); |
| 94 Expect.throws(() { new Int8List.transferrable(-1); }, | 94 Expect.throws(() { new Int8List.transferable(-1); }, |
| 95 (e) { return e is ArgumentError; }); | 95 (e) { return e is ArgumentError; }); |
| 96 var array = new Int8List(10); | 96 var array = new Int8List(10); |
| 97 testInt8ListImpl(array); | 97 testInt8ListImpl(array); |
| 98 array = new Int8List.transferrable(10); | 98 array = new Int8List.transferable(10); |
| 99 testInt8ListImpl(array); | 99 testInt8ListImpl(array); |
| 100 } | 100 } |
| 101 | 101 |
| 102 static testUint8ListImpl(Uint8List array) { | 102 static testUint8ListImpl(Uint8List array) { |
| 103 Expect.isTrue(array is List<int>); | 103 Expect.isTrue(array is List<int>); |
| 104 Expect.equals(10, array.length); | 104 Expect.equals(10, array.length); |
| 105 Expect.equals(1, array.bytesPerElement()); | 105 Expect.equals(1, array.bytesPerElement()); |
| 106 Expect.equals(10, array.lengthInBytes()); | 106 Expect.equals(10, array.lengthInBytes()); |
| 107 Expect.listEquals([0, 0, 0, 0, 0, | 107 Expect.listEquals([0, 0, 0, 0, 0, |
| 108 0, 0, 0, 0, 0], | 108 0, 0, 0, 0, 0], |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 Expect.equals(4, region.length); | 164 Expect.equals(4, region.length); |
| 165 Expect.listEquals([3, 4, 5, 6], region); | 165 Expect.listEquals([3, 4, 5, 6], region); |
| 166 array.setRange(3, 4, [257, 0, 1, 255]); | 166 array.setRange(3, 4, [257, 0, 1, 255]); |
| 167 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], |
| 168 array); | 168 array); |
| 169 } | 169 } |
| 170 | 170 |
| 171 static testUint8List() { | 171 static testUint8List() { |
| 172 Expect.throws(() { new Uint8List(-1); }, | 172 Expect.throws(() { new Uint8List(-1); }, |
| 173 (e) { return e is ArgumentError; }); | 173 (e) { return e is ArgumentError; }); |
| 174 Expect.throws(() { new Uint8List.transferrable(-1); }, | 174 Expect.throws(() { new Uint8List.transferable(-1); }, |
| 175 (e) { return e is ArgumentError; }); | 175 (e) { return e is ArgumentError; }); |
| 176 var array = new Uint8List(10); | 176 var array = new Uint8List(10); |
| 177 testUint8ListImpl(array); | 177 testUint8ListImpl(array); |
| 178 array = new Uint8List.transferrable(10); | 178 array = new Uint8List.transferable(10); |
| 179 testUint8ListImpl(array); | 179 testUint8ListImpl(array); |
| 180 } | 180 } |
| 181 | 181 |
| 182 static testInt16ListImpl(Int16List array) { | 182 static testInt16ListImpl(Int16List array) { |
| 183 Expect.isTrue(array is List<int>); | 183 Expect.isTrue(array is List<int>); |
| 184 Expect.equals(10, array.length); | 184 Expect.equals(10, array.length); |
| 185 Expect.equals(2, array.bytesPerElement()); | 185 Expect.equals(2, array.bytesPerElement()); |
| 186 Expect.equals(20, array.lengthInBytes()); | 186 Expect.equals(20, array.lengthInBytes()); |
| 187 Expect.listEquals([0, 0, 0, 0, 0, | 187 Expect.listEquals([0, 0, 0, 0, 0, |
| 188 0, 0, 0, 0, 0], | 188 0, 0, 0, 0, 0], |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 Expect.equals(4, region.length); | 256 Expect.equals(4, region.length); |
| 257 Expect.listEquals([3, 4, 5, 6], region); | 257 Expect.listEquals([3, 4, 5, 6], region); |
| 258 array.setRange(3, 4, [-32768, 0, 1, 32767]); | 258 array.setRange(3, 4, [-32768, 0, 1, 32767]); |
| 259 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], |
| 260 array); | 260 array); |
| 261 } | 261 } |
| 262 | 262 |
| 263 static testInt16List() { | 263 static testInt16List() { |
| 264 Expect.throws(() { new Int16List(-1); }, | 264 Expect.throws(() { new Int16List(-1); }, |
| 265 (e) { return e is ArgumentError; }); | 265 (e) { return e is ArgumentError; }); |
| 266 Expect.throws(() { new Int16List.transferrable(-1); }, | 266 Expect.throws(() { new Int16List.transferable(-1); }, |
| 267 (e) { return e is ArgumentError; }); | 267 (e) { return e is ArgumentError; }); |
| 268 var array = new Int16List(10); | 268 var array = new Int16List(10); |
| 269 testInt16ListImpl(array); | 269 testInt16ListImpl(array); |
| 270 array = new Int16List.transferrable(10); | 270 array = new Int16List.transferable(10); |
| 271 testInt16ListImpl(array); | 271 testInt16ListImpl(array); |
| 272 } | 272 } |
| 273 | 273 |
| 274 static testUint16ListImpl(Uint16List array) { | 274 static testUint16ListImpl(Uint16List array) { |
| 275 Expect.isTrue(array is List<int>); | 275 Expect.isTrue(array is List<int>); |
| 276 Expect.equals(10, array.length); | 276 Expect.equals(10, array.length); |
| 277 Expect.equals(2, array.bytesPerElement()); | 277 Expect.equals(2, array.bytesPerElement()); |
| 278 Expect.equals(20, array.lengthInBytes()); | 278 Expect.equals(20, array.lengthInBytes()); |
| 279 Expect.listEquals([0, 0, 0, 0, 0, | 279 Expect.listEquals([0, 0, 0, 0, 0, |
| 280 0, 0, 0, 0, 0], | 280 0, 0, 0, 0, 0], |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 Expect.equals(4, region.length); | 336 Expect.equals(4, region.length); |
| 337 Expect.listEquals([3, 4, 5, 6], region); | 337 Expect.listEquals([3, 4, 5, 6], region); |
| 338 array.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); | 338 array.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); |
| 339 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], |
| 340 array); | 340 array); |
| 341 } | 341 } |
| 342 | 342 |
| 343 static testUint16List() { | 343 static testUint16List() { |
| 344 Expect.throws(() { new Uint16List(-1); }, | 344 Expect.throws(() { new Uint16List(-1); }, |
| 345 (e) { return e is ArgumentError; }); | 345 (e) { return e is ArgumentError; }); |
| 346 Expect.throws(() { new Uint16List.transferrable(-1); }, | 346 Expect.throws(() { new Uint16List.transferable(-1); }, |
| 347 (e) { return e is ArgumentError; }); | 347 (e) { return e is ArgumentError; }); |
| 348 var array = new Uint16List(10); | 348 var array = new Uint16List(10); |
| 349 testUint16ListImpl(array); | 349 testUint16ListImpl(array); |
| 350 array = new Uint16List.transferrable(10); | 350 array = new Uint16List.transferable(10); |
| 351 testUint16ListImpl(array); | 351 testUint16ListImpl(array); |
| 352 } | 352 } |
| 353 | 353 |
| 354 static testInt32ListImpl(Int32List array) { | 354 static testInt32ListImpl(Int32List array) { |
| 355 Expect.isTrue(array is List<int>); | 355 Expect.isTrue(array is List<int>); |
| 356 Expect.equals(10, array.length); | 356 Expect.equals(10, array.length); |
| 357 Expect.equals(4, array.bytesPerElement()); | 357 Expect.equals(4, array.bytesPerElement()); |
| 358 Expect.equals(40, array.lengthInBytes()); | 358 Expect.equals(40, array.lengthInBytes()); |
| 359 Expect.listEquals([0, 0, 0, 0, 0, | 359 Expect.listEquals([0, 0, 0, 0, 0, |
| 360 0, 0, 0, 0, 0], | 360 0, 0, 0, 0, 0], |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 Expect.equals(4, region.length); | 434 Expect.equals(4, region.length); |
| 435 Expect.listEquals([3, 4, 5, 6], region); | 435 Expect.listEquals([3, 4, 5, 6], region); |
| 436 array.setRange(3, 4, [-0x80000000, 0, 1, 0x7FFFFFFF]); | 436 array.setRange(3, 4, [-0x80000000, 0, 1, 0x7FFFFFFF]); |
| 437 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], |
| 438 array); | 438 array); |
| 439 } | 439 } |
| 440 | 440 |
| 441 static testInt32List() { | 441 static testInt32List() { |
| 442 Expect.throws(() { new Int32List(-1); }, | 442 Expect.throws(() { new Int32List(-1); }, |
| 443 (e) { return e is ArgumentError; }); | 443 (e) { return e is ArgumentError; }); |
| 444 Expect.throws(() { new Int32List.transferrable(-1); }, | 444 Expect.throws(() { new Int32List.transferable(-1); }, |
| 445 (e) { return e is ArgumentError; }); | 445 (e) { return e is ArgumentError; }); |
| 446 var array = new Int32List(10); | 446 var array = new Int32List(10); |
| 447 testInt32ListImpl(array); | 447 testInt32ListImpl(array); |
| 448 array = new Int32List.transferrable(10); | 448 array = new Int32List.transferable(10); |
| 449 testInt32ListImpl(array); | 449 testInt32ListImpl(array); |
| 450 } | 450 } |
| 451 | 451 |
| 452 static testUint32ListImpl(Uint32List array) { | 452 static testUint32ListImpl(Uint32List array) { |
| 453 Expect.isTrue(array is List<int>); | 453 Expect.isTrue(array is List<int>); |
| 454 Expect.equals(10, array.length); | 454 Expect.equals(10, array.length); |
| 455 Expect.equals(4, array.bytesPerElement()); | 455 Expect.equals(4, array.bytesPerElement()); |
| 456 Expect.equals(40, array.lengthInBytes()); | 456 Expect.equals(40, array.lengthInBytes()); |
| 457 Expect.listEquals([0, 0, 0, 0, 0, | 457 Expect.listEquals([0, 0, 0, 0, 0, |
| 458 0, 0, 0, 0, 0], | 458 0, 0, 0, 0, 0], |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 array); | 521 array); |
| 522 } | 522 } |
| 523 | 523 |
| 524 static testUint32List() { | 524 static testUint32List() { |
| 525 Expect.throws(() { new Uint32List(-1); }, | 525 Expect.throws(() { new Uint32List(-1); }, |
| 526 (e) { return e is ArgumentError; }); | 526 (e) { return e is ArgumentError; }); |
| 527 Expect.throws(() { new Uint32List(-1); }, | 527 Expect.throws(() { new Uint32List(-1); }, |
| 528 (e) { return e is ArgumentError; }); | 528 (e) { return e is ArgumentError; }); |
| 529 var array = new Uint32List(10); | 529 var array = new Uint32List(10); |
| 530 testUint32ListImpl(array); | 530 testUint32ListImpl(array); |
| 531 array = new Uint32List.transferrable(10); | 531 array = new Uint32List.transferable(10); |
| 532 testUint32ListImpl(array); | 532 testUint32ListImpl(array); |
| 533 | 533 |
| 534 } | 534 } |
| 535 | 535 |
| 536 static testInt64ListImpl(Int64List array) { | 536 static testInt64ListImpl(Int64List array) { |
| 537 Expect.isTrue(array is List<int>); | 537 Expect.isTrue(array is List<int>); |
| 538 Expect.equals(10, array.length); | 538 Expect.equals(10, array.length); |
| 539 Expect.equals(8, array.bytesPerElement()); | 539 Expect.equals(8, array.bytesPerElement()); |
| 540 Expect.equals(80, array.lengthInBytes()); | 540 Expect.equals(80, array.lengthInBytes()); |
| 541 Expect.listEquals([0, 0, 0, 0, 0, | 541 Expect.listEquals([0, 0, 0, 0, 0, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 Expect.listEquals([3, 4, 5, 6], region); | 617 Expect.listEquals([3, 4, 5, 6], region); |
| 618 array.setRange(3, 4, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); | 618 array.setRange(3, 4, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); |
| 619 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, | 619 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, |
| 620 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], | 620 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], |
| 621 array); | 621 array); |
| 622 } | 622 } |
| 623 | 623 |
| 624 static testInt64List() { | 624 static testInt64List() { |
| 625 Expect.throws(() { new Int64List(-1); }, | 625 Expect.throws(() { new Int64List(-1); }, |
| 626 (e) { return e is ArgumentError; }); | 626 (e) { return e is ArgumentError; }); |
| 627 Expect.throws(() { new Int64List.transferrable(-1); }, | 627 Expect.throws(() { new Int64List.transferable(-1); }, |
| 628 (e) { return e is ArgumentError; }); | 628 (e) { return e is ArgumentError; }); |
| 629 var array = new Int64List(10); | 629 var array = new Int64List(10); |
| 630 testInt64ListImpl(array); | 630 testInt64ListImpl(array); |
| 631 array = new Int64List.transferrable(10); | 631 array = new Int64List.transferable(10); |
| 632 testInt64ListImpl(array); | 632 testInt64ListImpl(array); |
| 633 } | 633 } |
| 634 | 634 |
| 635 static testUint64ListImpl(Uint64List array) { | 635 static testUint64ListImpl(Uint64List array) { |
| 636 Expect.isTrue(array is List<int>); | 636 Expect.isTrue(array is List<int>); |
| 637 Expect.equals(10, array.length); | 637 Expect.equals(10, array.length); |
| 638 Expect.equals(8, array.bytesPerElement()); | 638 Expect.equals(8, array.bytesPerElement()); |
| 639 Expect.equals(80, array.lengthInBytes()); | 639 Expect.equals(80, array.lengthInBytes()); |
| 640 Expect.listEquals([0, 0, 0, 0, 0, | 640 Expect.listEquals([0, 0, 0, 0, 0, |
| 641 0, 0, 0, 0, 0], | 641 0, 0, 0, 0, 0], |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 Expect.equals(4, region.length); | 700 Expect.equals(4, region.length); |
| 701 Expect.listEquals([3, 4, 5, 6], region); | 701 Expect.listEquals([3, 4, 5, 6], region); |
| 702 array.setRange(3, 4, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); | 702 array.setRange(3, 4, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); |
| 703 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], |
| 704 array); | 704 array); |
| 705 } | 705 } |
| 706 | 706 |
| 707 static testUint64List() { | 707 static testUint64List() { |
| 708 Expect.throws(() { new Uint64List(-1); }, | 708 Expect.throws(() { new Uint64List(-1); }, |
| 709 (e) { return e is ArgumentError; }); | 709 (e) { return e is ArgumentError; }); |
| 710 Expect.throws(() { new Uint64List.transferrable(-1); }, | 710 Expect.throws(() { new Uint64List.transferable(-1); }, |
| 711 (e) { return e is ArgumentError; }); | 711 (e) { return e is ArgumentError; }); |
| 712 var array = new Uint64List(10); | 712 var array = new Uint64List(10); |
| 713 testUint64ListImpl(array); | 713 testUint64ListImpl(array); |
| 714 array = new Uint64List.transferrable(10); | 714 array = new Uint64List.transferable(10); |
| 715 testUint64ListImpl(array); | 715 testUint64ListImpl(array); |
| 716 } | 716 } |
| 717 | 717 |
| 718 static testFloat32ListImpl(Float32List array) { | 718 static testFloat32ListImpl(Float32List array) { |
| 719 Expect.isTrue(array is List<double>); | 719 Expect.isTrue(array is List<double>); |
| 720 Expect.equals(10, array.length); | 720 Expect.equals(10, array.length); |
| 721 Expect.equals(4, array.bytesPerElement()); | 721 Expect.equals(4, array.bytesPerElement()); |
| 722 Expect.equals(40, array.lengthInBytes()); | 722 Expect.equals(40, array.lengthInBytes()); |
| 723 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, |
| 724 0.0, 0.0, 0.0, 0.0, 0.0], | 724 0.0, 0.0, 0.0, 0.0, 0.0], |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 770 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
| 771 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]); |
| 772 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, |
| 773 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 773 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
| 774 array); | 774 array); |
| 775 } | 775 } |
| 776 | 776 |
| 777 static testFloat32List() { | 777 static testFloat32List() { |
| 778 Expect.throws(() { new Float32List(-1); }, | 778 Expect.throws(() { new Float32List(-1); }, |
| 779 (e) { return e is ArgumentError; }); | 779 (e) { return e is ArgumentError; }); |
| 780 Expect.throws(() { new Float32List.transferrable(-1); }, | 780 Expect.throws(() { new Float32List.transferable(-1); }, |
| 781 (e) { return e is ArgumentError; }); | 781 (e) { return e is ArgumentError; }); |
| 782 var array = new Float32List(10); | 782 var array = new Float32List(10); |
| 783 testFloat32ListImpl(array); | 783 testFloat32ListImpl(array); |
| 784 array = new Float32List.transferrable(10); | 784 array = new Float32List.transferable(10); |
| 785 testFloat32ListImpl(array); | 785 testFloat32ListImpl(array); |
| 786 } | 786 } |
| 787 | 787 |
| 788 static testFloat64ListImpl(Float64List array) { | 788 static testFloat64ListImpl(Float64List array) { |
| 789 Expect.isTrue(array is List<double>); | 789 Expect.isTrue(array is List<double>); |
| 790 Expect.equals(10, array.length); | 790 Expect.equals(10, array.length); |
| 791 Expect.equals(8, array.bytesPerElement()); | 791 Expect.equals(8, array.bytesPerElement()); |
| 792 Expect.equals(80, array.lengthInBytes()); | 792 Expect.equals(80, array.lengthInBytes()); |
| 793 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, |
| 794 0.0, 0.0, 0.0, 0.0, 0.0], | 794 0.0, 0.0, 0.0, 0.0, 0.0], |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 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, |
| 843 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 843 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
| 844 array); | 844 array); |
| 845 } | 845 } |
| 846 | 846 |
| 847 static testFloat64List() { | 847 static testFloat64List() { |
| 848 Expect.throws(() { new Float64List(-1); }, | 848 Expect.throws(() { new Float64List(-1); }, |
| 849 (e) { return e is ArgumentError; }); | 849 (e) { return e is ArgumentError; }); |
| 850 var array = new Float64List(10); | 850 var array = new Float64List(10); |
| 851 testFloat64ListImpl(array); | 851 testFloat64ListImpl(array); |
| 852 array = new Float64List.transferrable(10); | 852 array = new Float64List.transferable(10); |
| 853 testFloat64ListImpl(array); | 853 testFloat64ListImpl(array); |
| 854 } | 854 } |
| 855 | 855 |
| 856 static testByteList() { | 856 static testByteList() { |
| 857 var array = new Uint8List(8); | 857 var array = new Uint8List(8); |
| 858 Expect.equals(8, array.length); | 858 Expect.equals(8, array.length); |
| 859 Expect.equals(8, array.lengthInBytes()); | 859 Expect.equals(8, array.lengthInBytes()); |
| 860 var byte_array = array.asByteArray(0, array.lengthInBytes()); | 860 var byte_array = array.asByteArray(0, array.lengthInBytes()); |
| 861 Expect.equals(8, byte_array.lengthInBytes()); | 861 Expect.equals(8, byte_array.lengthInBytes()); |
| 862 Expect.throws(() { byte_array.getInt8(-1); }, | 862 Expect.throws(() { byte_array.getInt8(-1); }, |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 Expect.listEquals([3, 4, 5, 6], region); | 1119 Expect.listEquals([3, 4, 5, 6], region); |
| 1120 view.setRange(3, 4, [-128, 0, 1, 127]); | 1120 view.setRange(3, 4, [-128, 0, 1, 127]); |
| 1121 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], |
| 1122 view); | 1122 view); |
| 1123 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], |
| 1124 array); | 1124 array); |
| 1125 } | 1125 } |
| 1126 static testInt8ListView() { | 1126 static testInt8ListView() { |
| 1127 var array = new Uint8List(12); | 1127 var array = new Uint8List(12); |
| 1128 testInt8ListViewImpl(array); | 1128 testInt8ListViewImpl(array); |
| 1129 array = new Uint8List.transferrable(12); | 1129 array = new Uint8List.transferable(12); |
| 1130 testInt8ListViewImpl(array); | 1130 testInt8ListViewImpl(array); |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 static testUint8ListViewImpl(var array) { | 1133 static testUint8ListViewImpl(var array) { |
| 1134 Expect.isTrue(array is List<int>); | 1134 Expect.isTrue(array is List<int>); |
| 1135 Expect.equals(12, array.length); | 1135 Expect.equals(12, array.length); |
| 1136 Expect.equals(1, array.bytesPerElement()); | 1136 Expect.equals(1, array.bytesPerElement()); |
| 1137 Expect.equals(12, array.lengthInBytes()); | 1137 Expect.equals(12, array.lengthInBytes()); |
| 1138 for (int i = 0; i < array.length; ++i) { | 1138 for (int i = 0; i < array.length; ++i) { |
| 1139 array[i] = -1; | 1139 array[i] = -1; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 Expect.equals(4, region.length); | 1233 Expect.equals(4, region.length); |
| 1234 Expect.listEquals([3, 4, 5, 6], region); | 1234 Expect.listEquals([3, 4, 5, 6], region); |
| 1235 view.setRange(3, 4, [257, 0, 1, 255]); | 1235 view.setRange(3, 4, [257, 0, 1, 255]); |
| 1236 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], |
| 1237 view); | 1237 view); |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 static testUint8ListView() { | 1240 static testUint8ListView() { |
| 1241 var array = new Int8List(12); | 1241 var array = new Int8List(12); |
| 1242 testUint8ListViewImpl(array); | 1242 testUint8ListViewImpl(array); |
| 1243 array = new Int8List.transferrable(12); | 1243 array = new Int8List.transferable(12); |
| 1244 testUint8ListViewImpl(array); | 1244 testUint8ListViewImpl(array); |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 static testInt16ListViewImpl(var array) { | 1247 static testInt16ListViewImpl(var array) { |
| 1248 Expect.equals(24, array.length); | 1248 Expect.equals(24, array.length); |
| 1249 Expect.equals(1, array.bytesPerElement()); | 1249 Expect.equals(1, array.bytesPerElement()); |
| 1250 Expect.equals(24, array.lengthInBytes()); | 1250 Expect.equals(24, array.lengthInBytes()); |
| 1251 for (int i = 0; i < array.length; ++i) { | 1251 for (int i = 0; i < array.length; ++i) { |
| 1252 array[i] = 0xFF; | 1252 array[i] = 0xFF; |
| 1253 } | 1253 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 view); | 1373 view); |
| 1374 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, | 1374 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, |
| 1375 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F, | 1375 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F, |
| 1376 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], | 1376 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], |
| 1377 array); | 1377 array); |
| 1378 } | 1378 } |
| 1379 | 1379 |
| 1380 static testInt16ListView() { | 1380 static testInt16ListView() { |
| 1381 var array = new Uint8List(24); | 1381 var array = new Uint8List(24); |
| 1382 testInt16ListViewImpl(array); | 1382 testInt16ListViewImpl(array); |
| 1383 array = new Uint8List.transferrable(24); | 1383 array = new Uint8List.transferable(24); |
| 1384 testInt16ListViewImpl(array); | 1384 testInt16ListViewImpl(array); |
| 1385 } | 1385 } |
| 1386 | 1386 |
| 1387 static testUint16ListViewImpl(var array) { | 1387 static testUint16ListViewImpl(var array) { |
| 1388 Expect.isTrue(array is List<int>); | 1388 Expect.isTrue(array is List<int>); |
| 1389 Expect.equals(24, array.length); | 1389 Expect.equals(24, array.length); |
| 1390 Expect.equals(1, array.bytesPerElement()); | 1390 Expect.equals(1, array.bytesPerElement()); |
| 1391 Expect.equals(24, array.lengthInBytes()); | 1391 Expect.equals(24, array.lengthInBytes()); |
| 1392 for (int i = 0; i < array.length; ++i) { | 1392 for (int i = 0; i < array.length; ++i) { |
| 1393 array[i] = -1; | 1393 array[i] = -1; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1492 view); | 1492 view); |
| 1493 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, | 1493 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, |
| 1494 1, 0, 0, 0, 1, 0, -1, -1, | 1494 1, 0, 0, 0, 1, 0, -1, -1, |
| 1495 7, 0, 8, 0, 9, 0, -1, -1], | 1495 7, 0, 8, 0, 9, 0, -1, -1], |
| 1496 array); | 1496 array); |
| 1497 } | 1497 } |
| 1498 | 1498 |
| 1499 static testUint16ListView() { | 1499 static testUint16ListView() { |
| 1500 var array = new Int8List(24); | 1500 var array = new Int8List(24); |
| 1501 testUint16ListViewImpl(array); | 1501 testUint16ListViewImpl(array); |
| 1502 array = new Int8List.transferrable(24); | 1502 array = new Int8List.transferable(24); |
| 1503 testUint16ListViewImpl(array); | 1503 testUint16ListViewImpl(array); |
| 1504 } | 1504 } |
| 1505 | 1505 |
| 1506 static testInt32ListView() { | 1506 static testInt32ListView() { |
| 1507 var array = new Uint8List(48); | 1507 var array = new Uint8List(48); |
| 1508 Expect.equals(48, array.length); | 1508 Expect.equals(48, array.length); |
| 1509 Expect.equals(1, array.bytesPerElement()); | 1509 Expect.equals(1, array.bytesPerElement()); |
| 1510 Expect.equals(48, array.lengthInBytes()); | 1510 Expect.equals(48, array.lengthInBytes()); |
| 1511 for (int i = 0; i < array.length; ++i) { | 1511 for (int i = 0; i < array.length; ++i) { |
| 1512 array[i] = 0xFF; | 1512 array[i] = 0xFF; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 1, 0, 0, 0, 0, 0, 0, 0, | 1786 1, 0, 0, 0, 0, 0, 0, 0, |
| 1787 1, 0, 0, 0, -1, -1, -1, -1, | 1787 1, 0, 0, 0, -1, -1, -1, -1, |
| 1788 7, 0, 0, 0, 8, 0, 0, 0, | 1788 7, 0, 0, 0, 8, 0, 0, 0, |
| 1789 9, 0, 0, 0, -1, -1, -1, -1], | 1789 9, 0, 0, 0, -1, -1, -1, -1], |
| 1790 array); | 1790 array); |
| 1791 } | 1791 } |
| 1792 | 1792 |
| 1793 static testUint32ListView() { | 1793 static testUint32ListView() { |
| 1794 var array = new Int8List(48); | 1794 var array = new Int8List(48); |
| 1795 testUint32ListViewImpl(array); | 1795 testUint32ListViewImpl(array); |
| 1796 array = new Int8List.transferrable(48); | 1796 array = new Int8List.transferable(48); |
| 1797 testUint32ListViewImpl(array); | 1797 testUint32ListViewImpl(array); |
| 1798 } | 1798 } |
| 1799 | 1799 |
| 1800 static testInt64ListViewImpl(var array) { | 1800 static testInt64ListViewImpl(var array) { |
| 1801 Expect.equals(96, array.length); | 1801 Expect.equals(96, array.length); |
| 1802 Expect.equals(1, array.bytesPerElement()); | 1802 Expect.equals(1, array.bytesPerElement()); |
| 1803 Expect.equals(96, array.lengthInBytes()); | 1803 Expect.equals(96, array.lengthInBytes()); |
| 1804 for (int i = 0; i < array.length; ++i) { | 1804 for (int i = 0; i < array.length; ++i) { |
| 1805 array[i] = 0xFF; | 1805 array[i] = 0xFF; |
| 1806 } | 1806 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1987 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1987 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1988 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1988 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1989 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1989 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1990 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 1990 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
| 1991 array); | 1991 array); |
| 1992 } | 1992 } |
| 1993 | 1993 |
| 1994 static testInt64ListView() { | 1994 static testInt64ListView() { |
| 1995 var array = new Uint8List(96); | 1995 var array = new Uint8List(96); |
| 1996 testInt64ListViewImpl(array); | 1996 testInt64ListViewImpl(array); |
| 1997 array = new Uint8List.transferrable(96); | 1997 array = new Uint8List.transferable(96); |
| 1998 testInt64ListViewImpl(array); | 1998 testInt64ListViewImpl(array); |
| 1999 } | 1999 } |
| 2000 | 2000 |
| 2001 static testUint64ListViewImpl(var array) { | 2001 static testUint64ListViewImpl(var array) { |
| 2002 Expect.isTrue(array is List<int>); | 2002 Expect.isTrue(array is List<int>); |
| 2003 Expect.equals(96, array.length); | 2003 Expect.equals(96, array.length); |
| 2004 Expect.equals(1, array.bytesPerElement()); | 2004 Expect.equals(1, array.bytesPerElement()); |
| 2005 Expect.equals(96, array.lengthInBytes()); | 2005 Expect.equals(96, array.lengthInBytes()); |
| 2006 for (int i = 0; i < array.length; ++i) { | 2006 for (int i = 0; i < array.length; ++i) { |
| 2007 array[i] = -1; | 2007 array[i] = -1; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2150 7, 0, 0, 0, 0, 0, 0, 0, | 2150 7, 0, 0, 0, 0, 0, 0, 0, |
| 2151 8, 0, 0, 0, 0, 0, 0, 0, | 2151 8, 0, 0, 0, 0, 0, 0, 0, |
| 2152 9, 0, 0, 0, 0, 0, 0, 0, | 2152 9, 0, 0, 0, 0, 0, 0, 0, |
| 2153 -1, -1, -1, -1, -1, -1, -1, -1], | 2153 -1, -1, -1, -1, -1, -1, -1, -1], |
| 2154 array); | 2154 array); |
| 2155 } | 2155 } |
| 2156 | 2156 |
| 2157 static testUint64ListView() { | 2157 static testUint64ListView() { |
| 2158 var array = new Int8List(96); | 2158 var array = new Int8List(96); |
| 2159 testUint64ListViewImpl(array); | 2159 testUint64ListViewImpl(array); |
| 2160 array = new Int8List.transferrable(96); | 2160 array = new Int8List.transferable(96); |
| 2161 testUint64ListViewImpl(array); | 2161 testUint64ListViewImpl(array); |
| 2162 } | 2162 } |
| 2163 | 2163 |
| 2164 static testFloat32ListViewImpl(var array) { | 2164 static testFloat32ListViewImpl(var array) { |
| 2165 Expect.isTrue(array is List<int>); | 2165 Expect.isTrue(array is List<int>); |
| 2166 Expect.equals(12, array.length); | 2166 Expect.equals(12, array.length); |
| 2167 Expect.equals(4, array.bytesPerElement()); | 2167 Expect.equals(4, array.bytesPerElement()); |
| 2168 Expect.equals(48, array.lengthInBytes()); | 2168 Expect.equals(48, array.lengthInBytes()); |
| 2169 for (int i = 0; i < array.length; ++i) { | 2169 for (int i = 0; i < array.length; ++i) { |
| 2170 array[i] = 0xBF800000; | 2170 array[i] = 0xBF800000; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2259 0xFF800000, 0x00000000, | 2259 0xFF800000, 0x00000000, |
| 2260 0x3F800000, 0x7F800000, | 2260 0x3F800000, 0x7F800000, |
| 2261 0x40E00000, 0x41000000, | 2261 0x40E00000, 0x41000000, |
| 2262 0x41100000, 0xBF800000], | 2262 0x41100000, 0xBF800000], |
| 2263 array); | 2263 array); |
| 2264 } | 2264 } |
| 2265 | 2265 |
| 2266 static testFloat32ListView() { | 2266 static testFloat32ListView() { |
| 2267 var array = new Uint32List(12); | 2267 var array = new Uint32List(12); |
| 2268 testFloat32ListViewImpl(array); | 2268 testFloat32ListViewImpl(array); |
| 2269 array = new Uint32List.transferrable(12); | 2269 array = new Uint32List.transferable(12); |
| 2270 testFloat32ListViewImpl(array); | 2270 testFloat32ListViewImpl(array); |
| 2271 } | 2271 } |
| 2272 | 2272 |
| 2273 static testFloat64ListViewImpl(var array) { | 2273 static testFloat64ListViewImpl(var array) { |
| 2274 Expect.isTrue(array is List<int>); | 2274 Expect.isTrue(array is List<int>); |
| 2275 Expect.equals(12, array.length); | 2275 Expect.equals(12, array.length); |
| 2276 Expect.equals(8, array.bytesPerElement()); | 2276 Expect.equals(8, array.bytesPerElement()); |
| 2277 Expect.equals(96, array.lengthInBytes()); | 2277 Expect.equals(96, array.lengthInBytes()); |
| 2278 for (int i = 0; i < array.length; ++i) { | 2278 for (int i = 0; i < array.length; ++i) { |
| 2279 array[i] = 0xBFF0000000000000; | 2279 array[i] = 0xBFF0000000000000; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2368 0xFFF0000000000000, 0x0000000000000000, | 2368 0xFFF0000000000000, 0x0000000000000000, |
| 2369 0x3FF0000000000000, 0x7FF0000000000000, | 2369 0x3FF0000000000000, 0x7FF0000000000000, |
| 2370 0x401C000000000000, 0x4020000000000000, | 2370 0x401C000000000000, 0x4020000000000000, |
| 2371 0x4022000000000000, 0xBFF0000000000000], | 2371 0x4022000000000000, 0xBFF0000000000000], |
| 2372 array); | 2372 array); |
| 2373 } | 2373 } |
| 2374 | 2374 |
| 2375 static testFloat64ListView() { | 2375 static testFloat64ListView() { |
| 2376 var array = new Uint64List(12); | 2376 var array = new Uint64List(12); |
| 2377 testFloat64ListViewImpl(array); | 2377 testFloat64ListViewImpl(array); |
| 2378 array = new Uint64List.transferrable(12); | 2378 array = new Uint64List.transferable(12); |
| 2379 testFloat64ListViewImpl(array); | 2379 testFloat64ListViewImpl(array); |
| 2380 } | 2380 } |
| 2381 | 2381 |
| 2382 static testMain() { | 2382 static testMain() { |
| 2383 testInt8List(); | 2383 testInt8List(); |
| 2384 testUint8List(); | 2384 testUint8List(); |
| 2385 testInt16List(); | 2385 testInt16List(); |
| 2386 testUint16List(); | 2386 testUint16List(); |
| 2387 testInt32List(); | 2387 testInt32List(); |
| 2388 testUint32List(); | 2388 testUint32List(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2400 testInt64ListView(); | 2400 testInt64ListView(); |
| 2401 testUint64ListView(); | 2401 testUint64ListView(); |
| 2402 testFloat32ListView(); | 2402 testFloat32ListView(); |
| 2403 testFloat64ListView(); | 2403 testFloat64ListView(); |
| 2404 } | 2404 } |
| 2405 } | 2405 } |
| 2406 | 2406 |
| 2407 main() { | 2407 main() { |
| 2408 ByteArrayTest.testMain(); | 2408 ByteArrayTest.testMain(); |
| 2409 } | 2409 } |
| OLD | NEW |