| 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:typeddata'; |
| 9 | 9 |
| 10 class ByteArrayTest { | 10 class ByteArrayTest { |
| 11 static testInt8ListImpl(Int8List array) { | 11 static testInt8ListImpl(Int8List array) { |
| 12 Expect.isTrue(array is List<int>); | 12 Expect.isTrue(array is List<int>); |
| 13 Expect.equals(10, array.length); | 13 Expect.equals(10, array.length); |
| 14 Expect.equals(1, array.bytesPerElement()); | 14 Expect.equals(1, array.elementSizeInBytes); |
| 15 Expect.equals(10, array.lengthInBytes()); | 15 Expect.equals(10, array.lengthInBytes); |
| 16 Expect.listEquals([0, 0, 0, 0, 0, | 16 Expect.listEquals([0, 0, 0, 0, 0, |
| 17 0, 0, 0, 0, 0], | 17 0, 0, 0, 0, 0], |
| 18 array); | 18 array); |
| 19 Expect.throws(() { array[-1] = 0; }, | 19 Expect.throws(() { array[-1] = 0; }, |
| 20 (e) { return e is RangeError; }); | 20 (e) { return e is RangeError; }); |
| 21 Expect.throws(() { return array[-1]; }, | 21 Expect.throws(() { return array[-1]; }, |
| 22 (e) { return e is RangeError; }); | 22 (e) { return e is RangeError; }); |
| 23 Expect.throws(() { array[10]; }, | 23 Expect.throws(() { array[10]; }, |
| 24 (e) { return e is RangeError; }); | 24 (e) { return e is RangeError; }); |
| 25 Expect.throws(() { array[10] = 0; }, | 25 Expect.throws(() { array[10] = 0; }, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 (e) { return e is ArgumentError; }); | 98 (e) { return e is ArgumentError; }); |
| 99 var array = new Int8List(10); | 99 var array = new Int8List(10); |
| 100 testInt8ListImpl(array); | 100 testInt8ListImpl(array); |
| 101 array = new Int8List.transferable(10); | 101 array = new Int8List.transferable(10); |
| 102 testInt8ListImpl(array); | 102 testInt8ListImpl(array); |
| 103 } | 103 } |
| 104 | 104 |
| 105 static testUint8ListImpl(Uint8List array) { | 105 static testUint8ListImpl(Uint8List array) { |
| 106 Expect.isTrue(array is List<int>); | 106 Expect.isTrue(array is List<int>); |
| 107 Expect.equals(10, array.length); | 107 Expect.equals(10, array.length); |
| 108 Expect.equals(1, array.bytesPerElement()); | 108 Expect.equals(1, array.elementSizeInBytes); |
| 109 Expect.equals(10, array.lengthInBytes()); | 109 Expect.equals(10, array.lengthInBytes); |
| 110 Expect.listEquals([0, 0, 0, 0, 0, | 110 Expect.listEquals([0, 0, 0, 0, 0, |
| 111 0, 0, 0, 0, 0], | 111 0, 0, 0, 0, 0], |
| 112 array); | 112 array); |
| 113 Expect.throws(() { array[-1] = 0; }, | 113 Expect.throws(() { array[-1] = 0; }, |
| 114 (e) { return e is RangeError; }); | 114 (e) { return e is RangeError; }); |
| 115 Expect.throws(() { return array[-1]; }, | 115 Expect.throws(() { return array[-1]; }, |
| 116 (e) { return e is RangeError; }); | 116 (e) { return e is RangeError; }); |
| 117 Expect.throws(() { array[10]; }, | 117 Expect.throws(() { array[10]; }, |
| 118 (e) { return e is RangeError; }); | 118 (e) { return e is RangeError; }); |
| 119 Expect.throws(() { array[10] = 0; }, | 119 Expect.throws(() { array[10] = 0; }, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 (e) { return e is ArgumentError; }); | 181 (e) { return e is ArgumentError; }); |
| 182 var array = new Uint8List(10); | 182 var array = new Uint8List(10); |
| 183 testUint8ListImpl(array); | 183 testUint8ListImpl(array); |
| 184 array = new Uint8List.transferable(10); | 184 array = new Uint8List.transferable(10); |
| 185 testUint8ListImpl(array); | 185 testUint8ListImpl(array); |
| 186 } | 186 } |
| 187 | 187 |
| 188 static testUint8ClampedListImpl(Uint8ClampedList array) { | 188 static testUint8ClampedListImpl(Uint8ClampedList array) { |
| 189 Expect.isTrue(array is List<int>); | 189 Expect.isTrue(array is List<int>); |
| 190 Expect.equals(10, array.length); | 190 Expect.equals(10, array.length); |
| 191 Expect.equals(1, array.bytesPerElement()); | 191 Expect.equals(1, array.elementSizeInBytes); |
| 192 Expect.equals(10, array.lengthInBytes()); | 192 Expect.equals(10, array.lengthInBytes); |
| 193 Expect.listEquals([0, 0, 0, 0, 0, | 193 Expect.listEquals([0, 0, 0, 0, 0, |
| 194 0, 0, 0, 0, 0], | 194 0, 0, 0, 0, 0], |
| 195 array); | 195 array); |
| 196 Expect.throws(() { array[-1] = 0; }, | 196 Expect.throws(() { array[-1] = 0; }, |
| 197 (e) { return e is RangeError; }); | 197 (e) { return e is RangeError; }); |
| 198 Expect.throws(() { return array[-1]; }, | 198 Expect.throws(() { return array[-1]; }, |
| 199 (e) { return e is RangeError; }); | 199 (e) { return e is RangeError; }); |
| 200 Expect.throws(() { array[10]; }, | 200 Expect.throws(() { array[10]; }, |
| 201 (e) { return e is RangeError; }); | 201 (e) { return e is RangeError; }); |
| 202 Expect.throws(() { array[10] = 0; }, | 202 Expect.throws(() { array[10] = 0; }, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 (e) { return e is ArgumentError; }); | 260 (e) { return e is ArgumentError; }); |
| 261 var array = new Uint8ClampedList(10); | 261 var array = new Uint8ClampedList(10); |
| 262 testUint8ClampedListImpl(array); | 262 testUint8ClampedListImpl(array); |
| 263 array = new Uint8ClampedList.transferable(10); | 263 array = new Uint8ClampedList.transferable(10); |
| 264 testUint8ClampedListImpl(array); | 264 testUint8ClampedListImpl(array); |
| 265 } | 265 } |
| 266 | 266 |
| 267 static testInt16ListImpl(Int16List array) { | 267 static testInt16ListImpl(Int16List array) { |
| 268 Expect.isTrue(array is List<int>); | 268 Expect.isTrue(array is List<int>); |
| 269 Expect.equals(10, array.length); | 269 Expect.equals(10, array.length); |
| 270 Expect.equals(2, array.bytesPerElement()); | 270 Expect.equals(2, array.elementSizeInBytes); |
| 271 Expect.equals(20, array.lengthInBytes()); | 271 Expect.equals(20, array.lengthInBytes); |
| 272 Expect.listEquals([0, 0, 0, 0, 0, | 272 Expect.listEquals([0, 0, 0, 0, 0, |
| 273 0, 0, 0, 0, 0], | 273 0, 0, 0, 0, 0], |
| 274 array); | 274 array); |
| 275 Expect.throws(() { array[-1] = 0; }, | 275 Expect.throws(() { array[-1] = 0; }, |
| 276 (e) { return e is RangeError; }); | 276 (e) { return e is RangeError; }); |
| 277 Expect.throws(() { return array[-1]; }, | 277 Expect.throws(() { return array[-1]; }, |
| 278 (e) { return e is RangeError; }); | 278 (e) { return e is RangeError; }); |
| 279 Expect.throws(() { array[10]; }, | 279 Expect.throws(() { array[10]; }, |
| 280 (e) { return e is RangeError; }); | 280 (e) { return e is RangeError; }); |
| 281 Expect.throws(() { array[10] = 0; }, | 281 Expect.throws(() { array[10] = 0; }, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 (e) { return e is ArgumentError; }); | 355 (e) { return e is ArgumentError; }); |
| 356 var array = new Int16List(10); | 356 var array = new Int16List(10); |
| 357 testInt16ListImpl(array); | 357 testInt16ListImpl(array); |
| 358 array = new Int16List.transferable(10); | 358 array = new Int16List.transferable(10); |
| 359 testInt16ListImpl(array); | 359 testInt16ListImpl(array); |
| 360 } | 360 } |
| 361 | 361 |
| 362 static testUint16ListImpl(Uint16List array) { | 362 static testUint16ListImpl(Uint16List array) { |
| 363 Expect.isTrue(array is List<int>); | 363 Expect.isTrue(array is List<int>); |
| 364 Expect.equals(10, array.length); | 364 Expect.equals(10, array.length); |
| 365 Expect.equals(2, array.bytesPerElement()); | 365 Expect.equals(2, array.elementSizeInBytes); |
| 366 Expect.equals(20, array.lengthInBytes()); | 366 Expect.equals(20, array.lengthInBytes); |
| 367 Expect.listEquals([0, 0, 0, 0, 0, | 367 Expect.listEquals([0, 0, 0, 0, 0, |
| 368 0, 0, 0, 0, 0], | 368 0, 0, 0, 0, 0], |
| 369 array); | 369 array); |
| 370 Expect.throws(() { array[-1] = 0; }, | 370 Expect.throws(() { array[-1] = 0; }, |
| 371 (e) { return e is RangeError; }); | 371 (e) { return e is RangeError; }); |
| 372 Expect.throws(() { return array[-1]; }, | 372 Expect.throws(() { return array[-1]; }, |
| 373 (e) { return e is RangeError; }); | 373 (e) { return e is RangeError; }); |
| 374 Expect.throws(() { array[10]; }, | 374 Expect.throws(() { array[10]; }, |
| 375 (e) { return e is RangeError; }); | 375 (e) { return e is RangeError; }); |
| 376 Expect.throws(() { array[10] = 0; }, | 376 Expect.throws(() { array[10] = 0; }, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 (e) { return e is ArgumentError; }); | 438 (e) { return e is ArgumentError; }); |
| 439 var array = new Uint16List(10); | 439 var array = new Uint16List(10); |
| 440 testUint16ListImpl(array); | 440 testUint16ListImpl(array); |
| 441 array = new Uint16List.transferable(10); | 441 array = new Uint16List.transferable(10); |
| 442 testUint16ListImpl(array); | 442 testUint16ListImpl(array); |
| 443 } | 443 } |
| 444 | 444 |
| 445 static testInt32ListImpl(Int32List array) { | 445 static testInt32ListImpl(Int32List array) { |
| 446 Expect.isTrue(array is List<int>); | 446 Expect.isTrue(array is List<int>); |
| 447 Expect.equals(10, array.length); | 447 Expect.equals(10, array.length); |
| 448 Expect.equals(4, array.bytesPerElement()); | 448 Expect.equals(4, array.elementSizeInBytes); |
| 449 Expect.equals(40, array.lengthInBytes()); | 449 Expect.equals(40, array.lengthInBytes); |
| 450 Expect.listEquals([0, 0, 0, 0, 0, | 450 Expect.listEquals([0, 0, 0, 0, 0, |
| 451 0, 0, 0, 0, 0], | 451 0, 0, 0, 0, 0], |
| 452 array); | 452 array); |
| 453 Expect.throws(() { array[-1] = 0; }, | 453 Expect.throws(() { array[-1] = 0; }, |
| 454 (e) { return e is RangeError; }); | 454 (e) { return e is RangeError; }); |
| 455 Expect.throws(() { return array[-1]; }, | 455 Expect.throws(() { return array[-1]; }, |
| 456 (e) { return e is RangeError; }); | 456 (e) { return e is RangeError; }); |
| 457 Expect.throws(() { array[10]; }, | 457 Expect.throws(() { array[10]; }, |
| 458 (e) { return e is RangeError; }); | 458 (e) { return e is RangeError; }); |
| 459 Expect.throws(() { array[10] = 0; }, | 459 Expect.throws(() { array[10] = 0; }, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 (e) { return e is ArgumentError; }); | 539 (e) { return e is ArgumentError; }); |
| 540 var array = new Int32List(10); | 540 var array = new Int32List(10); |
| 541 testInt32ListImpl(array); | 541 testInt32ListImpl(array); |
| 542 array = new Int32List.transferable(10); | 542 array = new Int32List.transferable(10); |
| 543 testInt32ListImpl(array); | 543 testInt32ListImpl(array); |
| 544 } | 544 } |
| 545 | 545 |
| 546 static testUint32ListImpl(Uint32List array) { | 546 static testUint32ListImpl(Uint32List array) { |
| 547 Expect.isTrue(array is List<int>); | 547 Expect.isTrue(array is List<int>); |
| 548 Expect.equals(10, array.length); | 548 Expect.equals(10, array.length); |
| 549 Expect.equals(4, array.bytesPerElement()); | 549 Expect.equals(4, array.elementSizeInBytes); |
| 550 Expect.equals(40, array.lengthInBytes()); | 550 Expect.equals(40, array.lengthInBytes); |
| 551 Expect.listEquals([0, 0, 0, 0, 0, | 551 Expect.listEquals([0, 0, 0, 0, 0, |
| 552 0, 0, 0, 0, 0], | 552 0, 0, 0, 0, 0], |
| 553 array); | 553 array); |
| 554 Expect.throws(() { array[-1] = 0; }, | 554 Expect.throws(() { array[-1] = 0; }, |
| 555 (e) { return e is RangeError; }); | 555 (e) { return e is RangeError; }); |
| 556 Expect.throws(() { return array[-1]; }, | 556 Expect.throws(() { return array[-1]; }, |
| 557 (e) { return e is RangeError; }); | 557 (e) { return e is RangeError; }); |
| 558 Expect.throws(() { array[10]; }, | 558 Expect.throws(() { array[10]; }, |
| 559 (e) { return e is RangeError; }); | 559 (e) { return e is RangeError; }); |
| 560 Expect.throws(() { array[10] = 0; }, | 560 Expect.throws(() { array[10] = 0; }, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 var array = new Uint32List(10); | 626 var array = new Uint32List(10); |
| 627 testUint32ListImpl(array); | 627 testUint32ListImpl(array); |
| 628 array = new Uint32List.transferable(10); | 628 array = new Uint32List.transferable(10); |
| 629 testUint32ListImpl(array); | 629 testUint32ListImpl(array); |
| 630 | 630 |
| 631 } | 631 } |
| 632 | 632 |
| 633 static testInt64ListImpl(Int64List array) { | 633 static testInt64ListImpl(Int64List array) { |
| 634 Expect.isTrue(array is List<int>); | 634 Expect.isTrue(array is List<int>); |
| 635 Expect.equals(10, array.length); | 635 Expect.equals(10, array.length); |
| 636 Expect.equals(8, array.bytesPerElement()); | 636 Expect.equals(8, array.elementSizeInBytes); |
| 637 Expect.equals(80, array.lengthInBytes()); | 637 Expect.equals(80, array.lengthInBytes); |
| 638 Expect.listEquals([0, 0, 0, 0, 0, | 638 Expect.listEquals([0, 0, 0, 0, 0, |
| 639 0, 0, 0, 0, 0], | 639 0, 0, 0, 0, 0], |
| 640 array); | 640 array); |
| 641 Expect.throws(() { array[-1] = 0; }, | 641 Expect.throws(() { array[-1] = 0; }, |
| 642 (e) { return e is RangeError; }); | 642 (e) { return e is RangeError; }); |
| 643 Expect.throws(() { return array[-1]; }, | 643 Expect.throws(() { return array[-1]; }, |
| 644 (e) { return e is RangeError; }); | 644 (e) { return e is RangeError; }); |
| 645 Expect.throws(() { array[10]; }, | 645 Expect.throws(() { array[10]; }, |
| 646 (e) { return e is RangeError; }); | 646 (e) { return e is RangeError; }); |
| 647 Expect.throws(() { array[10] = 0; }, | 647 Expect.throws(() { array[10] = 0; }, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 (e) { return e is ArgumentError; }); | 728 (e) { return e is ArgumentError; }); |
| 729 var array = new Int64List(10); | 729 var array = new Int64List(10); |
| 730 testInt64ListImpl(array); | 730 testInt64ListImpl(array); |
| 731 array = new Int64List.transferable(10); | 731 array = new Int64List.transferable(10); |
| 732 testInt64ListImpl(array); | 732 testInt64ListImpl(array); |
| 733 } | 733 } |
| 734 | 734 |
| 735 static testUint64ListImpl(Uint64List array) { | 735 static testUint64ListImpl(Uint64List array) { |
| 736 Expect.isTrue(array is List<int>); | 736 Expect.isTrue(array is List<int>); |
| 737 Expect.equals(10, array.length); | 737 Expect.equals(10, array.length); |
| 738 Expect.equals(8, array.bytesPerElement()); | 738 Expect.equals(8, array.elementSizeInBytes); |
| 739 Expect.equals(80, array.lengthInBytes()); | 739 Expect.equals(80, array.lengthInBytes); |
| 740 Expect.listEquals([0, 0, 0, 0, 0, | 740 Expect.listEquals([0, 0, 0, 0, 0, |
| 741 0, 0, 0, 0, 0], | 741 0, 0, 0, 0, 0], |
| 742 array); | 742 array); |
| 743 Expect.throws(() { array[-1] = 0; }, | 743 Expect.throws(() { array[-1] = 0; }, |
| 744 (e) { return e is RangeError; }); | 744 (e) { return e is RangeError; }); |
| 745 Expect.throws(() { return array[-1]; }, | 745 Expect.throws(() { return array[-1]; }, |
| 746 (e) { return e is RangeError; }); | 746 (e) { return e is RangeError; }); |
| 747 Expect.throws(() { array[10]; }, | 747 Expect.throws(() { array[10]; }, |
| 748 (e) { return e is RangeError; }); | 748 (e) { return e is RangeError; }); |
| 749 Expect.throws(() { array[10] = 0; }, | 749 Expect.throws(() { array[10] = 0; }, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 (e) { return e is ArgumentError; }); | 814 (e) { return e is ArgumentError; }); |
| 815 var array = new Uint64List(10); | 815 var array = new Uint64List(10); |
| 816 testUint64ListImpl(array); | 816 testUint64ListImpl(array); |
| 817 array = new Uint64List.transferable(10); | 817 array = new Uint64List.transferable(10); |
| 818 testUint64ListImpl(array); | 818 testUint64ListImpl(array); |
| 819 } | 819 } |
| 820 | 820 |
| 821 static testFloat32ListImpl(Float32List array) { | 821 static testFloat32ListImpl(Float32List array) { |
| 822 Expect.isTrue(array is List<double>); | 822 Expect.isTrue(array is List<double>); |
| 823 Expect.equals(10, array.length); | 823 Expect.equals(10, array.length); |
| 824 Expect.equals(4, array.bytesPerElement()); | 824 Expect.equals(4, array.elementSizeInBytes); |
| 825 Expect.equals(40, array.lengthInBytes()); | 825 Expect.equals(40, array.lengthInBytes); |
| 826 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, | 826 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, |
| 827 0.0, 0.0, 0.0, 0.0, 0.0], | 827 0.0, 0.0, 0.0, 0.0, 0.0], |
| 828 array); | 828 array); |
| 829 Expect.throws(() { array[-1] = 0.0; }, | 829 Expect.throws(() { array[-1] = 0.0; }, |
| 830 (e) { return e is RangeError; }); | 830 (e) { return e is RangeError; }); |
| 831 Expect.throws(() { return array[-1]; }, | 831 Expect.throws(() { return array[-1]; }, |
| 832 (e) { return e is RangeError; }); | 832 (e) { return e is RangeError; }); |
| 833 Expect.throws(() { array[10]; }, | 833 Expect.throws(() { array[10]; }, |
| 834 (e) { return e is RangeError; }); | 834 (e) { return e is RangeError; }); |
| 835 Expect.throws(() { array[10] = 0.0; }, | 835 Expect.throws(() { array[10] = 0.0; }, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 (e) { return e is ArgumentError; }); | 887 (e) { return e is ArgumentError; }); |
| 888 var array = new Float32List(10); | 888 var array = new Float32List(10); |
| 889 testFloat32ListImpl(array); | 889 testFloat32ListImpl(array); |
| 890 array = new Float32List.transferable(10); | 890 array = new Float32List.transferable(10); |
| 891 testFloat32ListImpl(array); | 891 testFloat32ListImpl(array); |
| 892 } | 892 } |
| 893 | 893 |
| 894 static testFloat64ListImpl(Float64List array) { | 894 static testFloat64ListImpl(Float64List array) { |
| 895 Expect.isTrue(array is List<double>); | 895 Expect.isTrue(array is List<double>); |
| 896 Expect.equals(10, array.length); | 896 Expect.equals(10, array.length); |
| 897 Expect.equals(8, array.bytesPerElement()); | 897 Expect.equals(8, array.elementSizeInBytes); |
| 898 Expect.equals(80, array.lengthInBytes()); | 898 Expect.equals(80, array.lengthInBytes); |
| 899 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, | 899 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, |
| 900 0.0, 0.0, 0.0, 0.0, 0.0], | 900 0.0, 0.0, 0.0, 0.0, 0.0], |
| 901 array); | 901 array); |
| 902 Expect.throws(() { array[-1] = 0.0; }, | 902 Expect.throws(() { array[-1] = 0.0; }, |
| 903 (e) { return e is RangeError; }); | 903 (e) { return e is RangeError; }); |
| 904 Expect.throws(() { return array[-1]; }, | 904 Expect.throws(() { return array[-1]; }, |
| 905 (e) { return e is RangeError; }); | 905 (e) { return e is RangeError; }); |
| 906 Expect.throws(() { array[10]; }, | 906 Expect.throws(() { array[10]; }, |
| 907 (e) { return e is RangeError; }); | 907 (e) { return e is RangeError; }); |
| 908 Expect.throws(() { array[10] = 0.0; }, | 908 Expect.throws(() { array[10] = 0.0; }, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 (e) { return e is ArgumentError; }); | 958 (e) { return e is ArgumentError; }); |
| 959 var array = new Float64List(10); | 959 var array = new Float64List(10); |
| 960 testFloat64ListImpl(array); | 960 testFloat64ListImpl(array); |
| 961 array = new Float64List.transferable(10); | 961 array = new Float64List.transferable(10); |
| 962 testFloat64ListImpl(array); | 962 testFloat64ListImpl(array); |
| 963 } | 963 } |
| 964 | 964 |
| 965 static testByteList() { | 965 static testByteList() { |
| 966 var array = new Uint8List(8); | 966 var array = new Uint8List(8); |
| 967 Expect.equals(8, array.length); | 967 Expect.equals(8, array.length); |
| 968 Expect.equals(8, array.lengthInBytes()); | 968 Expect.equals(8, array.lengthInBytes); |
| 969 var byte_array = array.asByteArray(0, array.lengthInBytes()); | 969 var byte_array = new ByteData.view(array.buffer); |
| 970 Expect.equals(8, byte_array.lengthInBytes()); | 970 Expect.equals(8, byte_array.lengthInBytes); |
| 971 Expect.throws(() { byte_array.getInt8(-1); }, | 971 Expect.throws(() { byte_array.getInt8(-1); }, |
| 972 (e) { return e is RangeError; }); | 972 (e) { return e is RangeError; }); |
| 973 Expect.throws(() { byte_array.getUint8(-1); }, | 973 Expect.throws(() { byte_array.getUint8(-1); }, |
| 974 (e) { return e is RangeError; }); | 974 (e) { return e is RangeError; }); |
| 975 Expect.throws(() { byte_array.getInt16(-1); }, | 975 Expect.throws(() { byte_array.getInt16(-1); }, |
| 976 (e) { return e is RangeError; }); | 976 (e) { return e is RangeError; }); |
| 977 Expect.throws(() { byte_array.getUint16(-1); }, | 977 Expect.throws(() { byte_array.getUint16(-1); }, |
| 978 (e) { return e is RangeError; }); | 978 (e) { return e is RangeError; }); |
| 979 Expect.throws(() { byte_array.getInt32(-1); }, | 979 Expect.throws(() { byte_array.getInt32(-1); }, |
| 980 (e) { return e is RangeError; }); | 980 (e) { return e is RangeError; }); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 Expect.equals(-1082130432, byte_array.getInt32(0)); | 1102 Expect.equals(-1082130432, byte_array.getInt32(0)); |
| 1103 Expect.equals(0xBF800000, byte_array.getUint32(0)); | 1103 Expect.equals(0xBF800000, byte_array.getUint32(0)); |
| 1104 Expect.equals(-506097523945897984, byte_array.getInt64(0)); | 1104 Expect.equals(-506097523945897984, byte_array.getInt64(0)); |
| 1105 Expect.equals(0xF8F9FAFBBF800000, byte_array.getUint64(0)); | 1105 Expect.equals(0xF8F9FAFBBF800000, byte_array.getUint64(0)); |
| 1106 Expect.equals(-1.0, byte_array.getFloat32(0)); | 1106 Expect.equals(-1.0, byte_array.getFloat32(0)); |
| 1107 // TODO: byte_array.getFloat64(0) | 1107 // TODO: byte_array.getFloat64(0) |
| 1108 } | 1108 } |
| 1109 | 1109 |
| 1110 static testInt8ListViewImpl(var array) { | 1110 static testInt8ListViewImpl(var array) { |
| 1111 Expect.equals(12, array.length); | 1111 Expect.equals(12, array.length); |
| 1112 Expect.equals(1, array.bytesPerElement()); | 1112 Expect.equals(1, array.elementSizeInBytes); |
| 1113 Expect.equals(12, array.lengthInBytes()); | 1113 Expect.equals(12, array.lengthInBytes); |
| 1114 for (int i = 0; i < array.length; ++i) { | 1114 for (int i = 0; i < array.length; ++i) { |
| 1115 array[i] = 0xFF; | 1115 array[i] = 0xFF; |
| 1116 } | 1116 } |
| 1117 Expect.throws(() { new Int8List.view(array.asByteArray(), -1); }, | 1117 Expect.throws(() { new Int8List.view(array.buffer, -1); }, |
| 1118 (e) { return e is RangeError; }); | 1118 (e) { return e is RangeError; }); |
| 1119 Expect.throws(() { new Int8List.view(array.asByteArray(), 0, -1); }, | 1119 Expect.throws(() { new Int8List.view(array.buffer, 0, -1); }, |
| 1120 (e) { return e is RangeError; }); | 1120 (e) { return e is RangeError; }); |
| 1121 Expect.throws(() { new Int8List.view(array.asByteArray(), | 1121 Expect.throws(() { new Int8List.view(array.buffer, |
| 1122 array.lengthInBytes() + 1); }, | 1122 array.lengthInBytes + 1); }, |
| 1123 (e) { return e is RangeError; }); | 1123 (e) { return e is RangeError; }); |
| 1124 Expect.throws(() { new Int8List.view(array.asByteArray(), | 1124 Expect.throws(() { new Int8List.view(array.buffer, |
| 1125 0, array.length + 1); }, | 1125 0, array.length + 1); }, |
| 1126 (e) { return e is RangeError; }); | 1126 (e) { return e is RangeError; }); |
| 1127 Expect.throws(() { new Int8List.view(array.asByteArray(), | 1127 Expect.throws(() { new Int8List.view(array.buffer, |
| 1128 array.length - 1, 2); }, | 1128 array.length - 1, 2); }, |
| 1129 (e) { return e is RangeError; }); | 1129 (e) { return e is RangeError; }); |
| 1130 var empty = new Int8List.view(array.asByteArray(), | 1130 var empty = new Int8List.view(array.buffer, |
| 1131 array.lengthInBytes()); | 1131 array.lengthInBytes); |
| 1132 Expect.isTrue(empty is List<int>); | 1132 Expect.isTrue(empty is List<int>); |
| 1133 Expect.isTrue(empty is Int8List); | 1133 Expect.isTrue(empty is Int8List); |
| 1134 Expect.equals(0, empty.length); | 1134 Expect.equals(0, empty.length); |
| 1135 var whole = new Int8List.view(array.asByteArray()); | 1135 var whole = new Int8List.view(array.buffer); |
| 1136 Expect.isTrue(whole is List<int>); | 1136 Expect.isTrue(whole is List<int>); |
| 1137 Expect.isTrue(whole is Int8List); | 1137 Expect.isTrue(whole is Int8List); |
| 1138 Expect.equals(12, whole.length); | 1138 Expect.equals(12, whole.length); |
| 1139 var view = new Int8List.view(array.asByteArray(), 1, array.length - 2); | 1139 var view = new Int8List.view(array.buffer, 1, array.length - 2); |
| 1140 Expect.isTrue(view is List<int>); | 1140 Expect.isTrue(view is List<int>); |
| 1141 Expect.isTrue(view is Int8List); | 1141 Expect.isTrue(view is Int8List); |
| 1142 Expect.equals(10, view.length); | 1142 Expect.equals(10, view.length); |
| 1143 Expect.equals(1, view.bytesPerElement()); | 1143 Expect.equals(1, view.elementSizeInBytes); |
| 1144 Expect.equals(10, view.lengthInBytes()); | 1144 Expect.equals(10, view.lengthInBytes); |
| 1145 Expect.listEquals([-1, -1, -1, -1, -1, | 1145 Expect.listEquals([-1, -1, -1, -1, -1, |
| 1146 -1, -1, -1, -1, -1], | 1146 -1, -1, -1, -1, -1], |
| 1147 view); | 1147 view); |
| 1148 Expect.throws(() { view[-1] = 0; }, | 1148 Expect.throws(() { view[-1] = 0; }, |
| 1149 (e) { return e is RangeError; }); | 1149 (e) { return e is RangeError; }); |
| 1150 Expect.throws(() { return view[-1]; }, | 1150 Expect.throws(() { return view[-1]; }, |
| 1151 (e) { return e is RangeError; }); | 1151 (e) { return e is RangeError; }); |
| 1152 Expect.throws(() { view[view.length]; }, | 1152 Expect.throws(() { view[view.length]; }, |
| 1153 (e) { return e is RangeError; }); | 1153 (e) { return e is RangeError; }); |
| 1154 Expect.throws(() { view[10] = 0; }, | 1154 Expect.throws(() { view[10] = 0; }, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 static testInt8ListView() { | 1235 static testInt8ListView() { |
| 1236 var array = new Uint8List(12); | 1236 var array = new Uint8List(12); |
| 1237 testInt8ListViewImpl(array); | 1237 testInt8ListViewImpl(array); |
| 1238 array = new Uint8List.transferable(12); | 1238 array = new Uint8List.transferable(12); |
| 1239 testInt8ListViewImpl(array); | 1239 testInt8ListViewImpl(array); |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 static testUint8ListViewImpl(var array) { | 1242 static testUint8ListViewImpl(var array) { |
| 1243 Expect.isTrue(array is List<int>); | 1243 Expect.isTrue(array is List<int>); |
| 1244 Expect.equals(12, array.length); | 1244 Expect.equals(12, array.length); |
| 1245 Expect.equals(1, array.bytesPerElement()); | 1245 Expect.equals(1, array.elementSizeInBytes); |
| 1246 Expect.equals(12, array.lengthInBytes()); | 1246 Expect.equals(12, array.lengthInBytes); |
| 1247 for (int i = 0; i < array.length; ++i) { | 1247 for (int i = 0; i < array.length; ++i) { |
| 1248 array[i] = -1; | 1248 array[i] = -1; |
| 1249 } | 1249 } |
| 1250 Expect.throws(() { new Uint8List.view(array.asByteArray(), -1); }, | 1250 Expect.throws(() { new Uint8List.view(array.buffer, -1); }, |
| 1251 (e) { return e is RangeError; }); | 1251 (e) { return e is RangeError; }); |
| 1252 Expect.throws(() { new Uint8List.view(array.asByteArray(), 0, -1); }, | 1252 Expect.throws(() { new Uint8List.view(array.buffer, 0, -1); }, |
| 1253 (e) { return e is RangeError; }); | 1253 (e) { return e is RangeError; }); |
| 1254 Expect.throws(() { new Uint8List.view(array.asByteArray(), | 1254 Expect.throws(() { new Uint8List.view(array.buffer, |
| 1255 array.lengthInBytes() + 1); }, | 1255 array.lengthInBytes + 1); }, |
| 1256 (e) { return e is RangeError; }); | 1256 (e) { return e is RangeError; }); |
| 1257 Expect.throws(() { new Uint8List.view(array.asByteArray(), | 1257 Expect.throws(() { new Uint8List.view(array.buffer, |
| 1258 0, array.length + 1); }, | 1258 0, array.length + 1); }, |
| 1259 (e) { return e is RangeError; }); | 1259 (e) { return e is RangeError; }); |
| 1260 Expect.throws(() { new Uint8List.view(array.asByteArray(), | 1260 Expect.throws(() { new Uint8List.view(array.buffer, |
| 1261 array.length - 1, 2); }, | 1261 array.length - 1, 2); }, |
| 1262 (e) { return e is RangeError; }); | 1262 (e) { return e is RangeError; }); |
| 1263 var empty = new Uint8List.view(array.asByteArray(), | 1263 var empty = new Uint8List.view(array.buffer, |
| 1264 array.lengthInBytes()); | 1264 array.lengthInBytes); |
| 1265 Expect.isTrue(empty is List<int>); | 1265 Expect.isTrue(empty is List<int>); |
| 1266 Expect.isTrue(empty is Uint8List); | 1266 Expect.isTrue(empty is Uint8List); |
| 1267 Expect.equals(0, empty.length); | 1267 Expect.equals(0, empty.length); |
| 1268 var whole = new Uint8List.view(array.asByteArray()); | 1268 var whole = new Uint8List.view(array.buffer); |
| 1269 Expect.isTrue(whole is List<int>); | 1269 Expect.isTrue(whole is List<int>); |
| 1270 Expect.isTrue(whole is Uint8List); | 1270 Expect.isTrue(whole is Uint8List); |
| 1271 Expect.equals(12, whole.length); | 1271 Expect.equals(12, whole.length); |
| 1272 var view = new Uint8List.view(array.asByteArray(), 1, array.length - 2); | 1272 var view = new Uint8List.view(array.buffer, 1, array.length - 2); |
| 1273 Expect.isTrue(view is List<int>); | 1273 Expect.isTrue(view is List<int>); |
| 1274 Expect.isTrue(view is Uint8List); | 1274 Expect.isTrue(view is Uint8List); |
| 1275 Expect.equals(10, view.length); | 1275 Expect.equals(10, view.length); |
| 1276 Expect.equals(1, view.bytesPerElement()); | 1276 Expect.equals(1, view.elementSizeInBytes); |
| 1277 Expect.equals(10, view.lengthInBytes()); | 1277 Expect.equals(10, view.lengthInBytes); |
| 1278 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 1278 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 1279 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 1279 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
| 1280 view); | 1280 view); |
| 1281 Expect.throws(() { view[-1] = 0; }, | 1281 Expect.throws(() { view[-1] = 0; }, |
| 1282 (e) { return e is RangeError; }); | 1282 (e) { return e is RangeError; }); |
| 1283 Expect.throws(() { return view[-1]; }, | 1283 Expect.throws(() { return view[-1]; }, |
| 1284 (e) { return e is RangeError; }); | 1284 (e) { return e is RangeError; }); |
| 1285 Expect.throws(() { view[view.length]; }, | 1285 Expect.throws(() { view[view.length]; }, |
| 1286 (e) { return e is RangeError; }); | 1286 (e) { return e is RangeError; }); |
| 1287 Expect.throws(() { view[view.length] = 0; }, | 1287 Expect.throws(() { view[view.length] = 0; }, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 | 1348 |
| 1349 static testUint8ListView() { | 1349 static testUint8ListView() { |
| 1350 var array = new Int8List(12); | 1350 var array = new Int8List(12); |
| 1351 testUint8ListViewImpl(array); | 1351 testUint8ListViewImpl(array); |
| 1352 array = new Int8List.transferable(12); | 1352 array = new Int8List.transferable(12); |
| 1353 testUint8ListViewImpl(array); | 1353 testUint8ListViewImpl(array); |
| 1354 } | 1354 } |
| 1355 | 1355 |
| 1356 static testInt16ListViewImpl(var array) { | 1356 static testInt16ListViewImpl(var array) { |
| 1357 Expect.equals(24, array.length); | 1357 Expect.equals(24, array.length); |
| 1358 Expect.equals(1, array.bytesPerElement()); | 1358 Expect.equals(1, array.elementSizeInBytes); |
| 1359 Expect.equals(24, array.lengthInBytes()); | 1359 Expect.equals(24, array.lengthInBytes); |
| 1360 for (int i = 0; i < array.length; ++i) { | 1360 for (int i = 0; i < array.length; ++i) { |
| 1361 array[i] = 0xFF; | 1361 array[i] = 0xFF; |
| 1362 } | 1362 } |
| 1363 Expect.throws(() { new Int16List.view(array.asByteArray(), -1); }, | 1363 Expect.throws(() { new Int16List.view(array.buffer, -1); }, |
| 1364 (e) { return e is RangeError; }); | 1364 (e) { return e is RangeError; }); |
| 1365 Expect.throws(() { new Int16List.view(array.asByteArray(), 0, -1); }, | 1365 Expect.throws(() { new Int16List.view(array.buffer, 0, -1); }, |
| 1366 (e) { return e is RangeError; }); | 1366 (e) { return e is RangeError; }); |
| 1367 Expect.throws(() { new Int16List.view(array.asByteArray(), | 1367 Expect.throws(() { new Int16List.view(array.buffer, |
| 1368 array.lengthInBytes() + 1); }, | 1368 array.lengthInBytes + 1); }, |
| 1369 (e) { return e is RangeError; }); | 1369 (e) { return e is RangeError; }); |
| 1370 Expect.throws(() { new Int16List.view(array.asByteArray(), | 1370 Expect.throws(() { new Int16List.view(array.buffer, |
| 1371 0, array.length + 1); }, | 1371 0, array.length + 1); }, |
| 1372 (e) { return e is RangeError; }); | 1372 (e) { return e is RangeError; }); |
| 1373 Expect.throws(() { new Int16List.view(array.asByteArray(), | 1373 Expect.throws(() { new Int16List.view(array.buffer, |
| 1374 array.length - 1, 2); }, | 1374 array.length - 1, 2); }, |
| 1375 (e) { return e is RangeError; }); | 1375 (e) { return e is RangeError; }); |
| 1376 var empty = new Int16List.view(array.asByteArray(), | 1376 var empty = new Int16List.view(array.buffer, |
| 1377 array.lengthInBytes()); | 1377 array.lengthInBytes); |
| 1378 Expect.isTrue(empty is List<int>); | 1378 Expect.isTrue(empty is List<int>); |
| 1379 Expect.isTrue(empty is Int16List); | 1379 Expect.isTrue(empty is Int16List); |
| 1380 Expect.equals(0, empty.length); | 1380 Expect.equals(0, empty.length); |
| 1381 var whole = new Int16List.view(array.asByteArray()); | 1381 var whole = new Int16List.view(array.buffer); |
| 1382 Expect.isTrue(whole is List<int>); | 1382 Expect.isTrue(whole is List<int>); |
| 1383 Expect.isTrue(whole is Int16List); | 1383 Expect.isTrue(whole is Int16List); |
| 1384 Expect.equals(12, whole.length); | 1384 Expect.equals(12, whole.length); |
| 1385 var view = new Int16List.view(array.asByteArray(), 2, 10); | 1385 var view = new Int16List.view(array.buffer, 2, 10); |
| 1386 Expect.isTrue(view is List<int>); | 1386 Expect.isTrue(view is List<int>); |
| 1387 Expect.isTrue(view is Int16List); | 1387 Expect.isTrue(view is Int16List); |
| 1388 Expect.equals(10, view.length); | 1388 Expect.equals(10, view.length); |
| 1389 Expect.equals(2, view.bytesPerElement()); | 1389 Expect.equals(2, view.elementSizeInBytes); |
| 1390 Expect.equals(20, view.lengthInBytes()); | 1390 Expect.equals(20, view.lengthInBytes); |
| 1391 Expect.listEquals([-1, -1, -1, -1, -1, | 1391 Expect.listEquals([-1, -1, -1, -1, -1, |
| 1392 -1, -1, -1, -1, -1], | 1392 -1, -1, -1, -1, -1], |
| 1393 view); | 1393 view); |
| 1394 Expect.throws(() { view[-1] = 0; }, | 1394 Expect.throws(() { view[-1] = 0; }, |
| 1395 (e) { return e is RangeError; }); | 1395 (e) { return e is RangeError; }); |
| 1396 Expect.throws(() { return view[-1]; }, | 1396 Expect.throws(() { return view[-1]; }, |
| 1397 (e) { return e is RangeError; }); | 1397 (e) { return e is RangeError; }); |
| 1398 Expect.throws(() { view[view.length]; }, | 1398 Expect.throws(() { view[view.length]; }, |
| 1399 (e) { return e is RangeError; }); | 1399 (e) { return e is RangeError; }); |
| 1400 Expect.throws(() { view[10] = 0; }, | 1400 Expect.throws(() { view[10] = 0; }, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1489 static testInt16ListView() { | 1489 static testInt16ListView() { |
| 1490 var array = new Uint8List(24); | 1490 var array = new Uint8List(24); |
| 1491 testInt16ListViewImpl(array); | 1491 testInt16ListViewImpl(array); |
| 1492 array = new Uint8List.transferable(24); | 1492 array = new Uint8List.transferable(24); |
| 1493 testInt16ListViewImpl(array); | 1493 testInt16ListViewImpl(array); |
| 1494 } | 1494 } |
| 1495 | 1495 |
| 1496 static testUint16ListViewImpl(var array) { | 1496 static testUint16ListViewImpl(var array) { |
| 1497 Expect.isTrue(array is List<int>); | 1497 Expect.isTrue(array is List<int>); |
| 1498 Expect.equals(24, array.length); | 1498 Expect.equals(24, array.length); |
| 1499 Expect.equals(1, array.bytesPerElement()); | 1499 Expect.equals(1, array.elementSizeInBytes); |
| 1500 Expect.equals(24, array.lengthInBytes()); | 1500 Expect.equals(24, array.lengthInBytes); |
| 1501 for (int i = 0; i < array.length; ++i) { | 1501 for (int i = 0; i < array.length; ++i) { |
| 1502 array[i] = -1; | 1502 array[i] = -1; |
| 1503 } | 1503 } |
| 1504 Expect.throws(() { new Uint16List.view(array.asByteArray(), -1); }, | 1504 Expect.throws(() { new Uint16List.view(array.buffer, -1); }, |
| 1505 (e) { return e is RangeError; }); | 1505 (e) { return e is RangeError; }); |
| 1506 Expect.throws(() { new Uint16List.view(array.asByteArray(), 0, -1); }, | 1506 Expect.throws(() { new Uint16List.view(array.buffer, 0, -1); }, |
| 1507 (e) { return e is RangeError; }); | 1507 (e) { return e is RangeError; }); |
| 1508 Expect.throws(() { new Uint16List.view(array.asByteArray(), | 1508 Expect.throws(() { new Uint16List.view(array.buffer, |
| 1509 array.lengthInBytes() + 1); }, | 1509 array.lengthInBytes + 1); }, |
| 1510 (e) { return e is RangeError; }); | 1510 (e) { return e is RangeError; }); |
| 1511 Expect.throws(() { new Uint16List.view(array.asByteArray(), | 1511 Expect.throws(() { new Uint16List.view(array.buffer, |
| 1512 0, array.length + 1); }, | 1512 0, array.length + 1); }, |
| 1513 (e) { return e is RangeError; }); | 1513 (e) { return e is RangeError; }); |
| 1514 Expect.throws(() { new Uint16List.view(array.asByteArray(), | 1514 Expect.throws(() { new Uint16List.view(array.buffer, |
| 1515 array.length - 1, 2); }, | 1515 array.length - 1, 2); }, |
| 1516 (e) { return e is RangeError; }); | 1516 (e) { return e is RangeError; }); |
| 1517 var empty = new Uint16List.view(array.asByteArray(), | 1517 var empty = new Uint16List.view(array.buffer, |
| 1518 array.lengthInBytes()); | 1518 array.lengthInBytes); |
| 1519 Expect.isTrue(empty is List<int>); | 1519 Expect.isTrue(empty is List<int>); |
| 1520 Expect.isTrue(empty is Uint16List); | 1520 Expect.isTrue(empty is Uint16List); |
| 1521 Expect.equals(0, empty.length); | 1521 Expect.equals(0, empty.length); |
| 1522 var whole = new Uint16List.view(array.asByteArray()); | 1522 var whole = new Uint16List.view(array.buffer); |
| 1523 Expect.isTrue(whole is List<int>); | 1523 Expect.isTrue(whole is List<int>); |
| 1524 Expect.isTrue(whole is Uint16List); | 1524 Expect.isTrue(whole is Uint16List); |
| 1525 Expect.equals(12, whole.length); | 1525 Expect.equals(12, whole.length); |
| 1526 var view = new Uint16List.view(array.asByteArray(), 2, 10); | 1526 var view = new Uint16List.view(array.buffer, 2, 10); |
| 1527 Expect.isTrue(view is List<int>); | 1527 Expect.isTrue(view is List<int>); |
| 1528 Expect.isTrue(view is Uint16List); | 1528 Expect.isTrue(view is Uint16List); |
| 1529 Expect.equals(10, view.length); | 1529 Expect.equals(10, view.length); |
| 1530 Expect.equals(2, view.bytesPerElement()); | 1530 Expect.equals(2, view.elementSizeInBytes); |
| 1531 Expect.equals(20, view.lengthInBytes()); | 1531 Expect.equals(20, view.lengthInBytes); |
| 1532 Expect.listEquals([0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, | 1532 Expect.listEquals([0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 1533 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF], | 1533 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF], |
| 1534 view); | 1534 view); |
| 1535 Expect.throws(() { view[-1] = 0; }, | 1535 Expect.throws(() { view[-1] = 0; }, |
| 1536 (e) { return e is RangeError; }); | 1536 (e) { return e is RangeError; }); |
| 1537 Expect.throws(() { return view[-1]; }, | 1537 Expect.throws(() { return view[-1]; }, |
| 1538 (e) { return e is RangeError; }); | 1538 (e) { return e is RangeError; }); |
| 1539 Expect.throws(() { view[view.length]; }, | 1539 Expect.throws(() { view[view.length]; }, |
| 1540 (e) { return e is RangeError; }); | 1540 (e) { return e is RangeError; }); |
| 1541 Expect.throws(() { view[view.length] = 0; }, | 1541 Expect.throws(() { view[view.length] = 0; }, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 static testUint16ListView() { | 1608 static testUint16ListView() { |
| 1609 var array = new Int8List(24); | 1609 var array = new Int8List(24); |
| 1610 testUint16ListViewImpl(array); | 1610 testUint16ListViewImpl(array); |
| 1611 array = new Int8List.transferable(24); | 1611 array = new Int8List.transferable(24); |
| 1612 testUint16ListViewImpl(array); | 1612 testUint16ListViewImpl(array); |
| 1613 } | 1613 } |
| 1614 | 1614 |
| 1615 static testInt32ListView() { | 1615 static testInt32ListView() { |
| 1616 var array = new Uint8List(48); | 1616 var array = new Uint8List(48); |
| 1617 Expect.equals(48, array.length); | 1617 Expect.equals(48, array.length); |
| 1618 Expect.equals(1, array.bytesPerElement()); | 1618 Expect.equals(1, array.elementSizeInBytes); |
| 1619 Expect.equals(48, array.lengthInBytes()); | 1619 Expect.equals(48, array.lengthInBytes); |
| 1620 for (int i = 0; i < array.length; ++i) { | 1620 for (int i = 0; i < array.length; ++i) { |
| 1621 array[i] = 0xFF; | 1621 array[i] = 0xFF; |
| 1622 } | 1622 } |
| 1623 Expect.throws(() { new Int32List.view(array.asByteArray(), -1); }, | 1623 Expect.throws(() { new Int32List.view(array.buffer, -1); }, |
| 1624 (e) { return e is RangeError; }); | 1624 (e) { return e is RangeError; }); |
| 1625 Expect.throws(() { new Int32List.view(array.asByteArray(), 0, -1); }, | 1625 Expect.throws(() { new Int32List.view(array.buffer, 0, -1); }, |
| 1626 (e) { return e is RangeError; }); | 1626 (e) { return e is RangeError; }); |
| 1627 Expect.throws(() { new Int32List.view(array.asByteArray(), | 1627 Expect.throws(() { new Int32List.view(array.buffer, |
| 1628 array.lengthInBytes() + 1); }, | 1628 array.lengthInBytes + 1); }, |
| 1629 (e) { return e is RangeError; }); | 1629 (e) { return e is RangeError; }); |
| 1630 Expect.throws(() { new Int32List.view(array.asByteArray(), | 1630 Expect.throws(() { new Int32List.view(array.buffer, |
| 1631 0, array.length + 1); }, | 1631 0, array.length + 1); }, |
| 1632 (e) { return e is RangeError; }); | 1632 (e) { return e is RangeError; }); |
| 1633 Expect.throws(() { new Int32List.view(array.asByteArray(), | 1633 Expect.throws(() { new Int32List.view(array.buffer, |
| 1634 array.length - 1, 2); }, | 1634 array.length - 1, 2); }, |
| 1635 (e) { return e is RangeError; }); | 1635 (e) { return e is RangeError; }); |
| 1636 var empty = new Int32List.view(array.asByteArray(), | 1636 var empty = new Int32List.view(array.buffer, |
| 1637 array.lengthInBytes()); | 1637 array.lengthInBytes); |
| 1638 Expect.isTrue(empty is List<int>); | 1638 Expect.isTrue(empty is List<int>); |
| 1639 Expect.isTrue(empty is Int32List); | 1639 Expect.isTrue(empty is Int32List); |
| 1640 Expect.equals(0, empty.length); | 1640 Expect.equals(0, empty.length); |
| 1641 var whole = new Int32List.view(array.asByteArray()); | 1641 var whole = new Int32List.view(array.buffer); |
| 1642 Expect.isTrue(whole is List<int>); | 1642 Expect.isTrue(whole is List<int>); |
| 1643 Expect.isTrue(whole is Int32List); | 1643 Expect.isTrue(whole is Int32List); |
| 1644 Expect.equals(12, whole.length); | 1644 Expect.equals(12, whole.length); |
| 1645 var view = new Int32List.view(array.asByteArray(), 4, 10); | 1645 var view = new Int32List.view(array.buffer, 4, 10); |
| 1646 Expect.isTrue(view is List<int>); | 1646 Expect.isTrue(view is List<int>); |
| 1647 Expect.isTrue(view is Int32List); | 1647 Expect.isTrue(view is Int32List); |
| 1648 Expect.equals(10, view.length); | 1648 Expect.equals(10, view.length); |
| 1649 Expect.equals(4, view.bytesPerElement()); | 1649 Expect.equals(4, view.elementSizeInBytes); |
| 1650 Expect.equals(40, view.lengthInBytes()); | 1650 Expect.equals(40, view.lengthInBytes); |
| 1651 Expect.listEquals([-1, -1, -1, -1, -1, | 1651 Expect.listEquals([-1, -1, -1, -1, -1, |
| 1652 -1, -1, -1, -1, -1], | 1652 -1, -1, -1, -1, -1], |
| 1653 view); | 1653 view); |
| 1654 Expect.throws(() { view[-1] = 0; }, | 1654 Expect.throws(() { view[-1] = 0; }, |
| 1655 (e) { return e is RangeError; }); | 1655 (e) { return e is RangeError; }); |
| 1656 Expect.throws(() { return view[-1]; }, | 1656 Expect.throws(() { return view[-1]; }, |
| 1657 (e) { return e is RangeError; }); | 1657 (e) { return e is RangeError; }); |
| 1658 Expect.throws(() { view[view.length]; }, | 1658 Expect.throws(() { view[view.length]; }, |
| 1659 (e) { return e is RangeError; }); | 1659 (e) { return e is RangeError; }); |
| 1660 Expect.throws(() { view[10] = 0; }, | 1660 Expect.throws(() { view[10] = 0; }, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1766 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, | 1766 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, |
| 1767 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, | 1767 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, |
| 1768 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, | 1768 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, |
| 1769 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], | 1769 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], |
| 1770 array); | 1770 array); |
| 1771 } | 1771 } |
| 1772 | 1772 |
| 1773 static testUint32ListViewImpl(var array) { | 1773 static testUint32ListViewImpl(var array) { |
| 1774 Expect.isTrue(array is List<int>); | 1774 Expect.isTrue(array is List<int>); |
| 1775 Expect.equals(48, array.length); | 1775 Expect.equals(48, array.length); |
| 1776 Expect.equals(1, array.bytesPerElement()); | 1776 Expect.equals(1, array.elementSizeInBytes); |
| 1777 Expect.equals(48, array.lengthInBytes()); | 1777 Expect.equals(48, array.lengthInBytes); |
| 1778 for (int i = 0; i < array.length; ++i) { | 1778 for (int i = 0; i < array.length; ++i) { |
| 1779 array[i] = -1; | 1779 array[i] = -1; |
| 1780 } | 1780 } |
| 1781 Expect.throws(() { new Uint32List.view(array.asByteArray(), -1); }, | 1781 Expect.throws(() { new Uint32List.view(array.buffer, -1); }, |
| 1782 (e) { return e is RangeError; }); | 1782 (e) { return e is RangeError; }); |
| 1783 Expect.throws(() { new Uint32List.view(array.asByteArray(), 0, -1); }, | 1783 Expect.throws(() { new Uint32List.view(array.buffer, 0, -1); }, |
| 1784 (e) { return e is RangeError; }); | 1784 (e) { return e is RangeError; }); |
| 1785 Expect.throws(() { new Uint32List.view(array.asByteArray(), | 1785 Expect.throws(() { new Uint32List.view(array.buffer, |
| 1786 array.lengthInBytes() + 1); }, | 1786 array.lengthInBytes + 1); }, |
| 1787 (e) { return e is RangeError; }); | 1787 (e) { return e is RangeError; }); |
| 1788 Expect.throws(() { new Uint32List.view(array.asByteArray(), | 1788 Expect.throws(() { new Uint32List.view(array.buffer, |
| 1789 0, array.length + 1); }, | 1789 0, array.length + 1); }, |
| 1790 (e) { return e is RangeError; }); | 1790 (e) { return e is RangeError; }); |
| 1791 Expect.throws(() { new Uint32List.view(array.asByteArray(), | 1791 Expect.throws(() { new Uint32List.view(array.buffer, |
| 1792 array.length - 1, 2); }, | 1792 array.length - 1, 2); }, |
| 1793 (e) { return e is RangeError; }); | 1793 (e) { return e is RangeError; }); |
| 1794 var empty = new Uint32List.view(array.asByteArray(), | 1794 var empty = new Uint32List.view(array.buffer, |
| 1795 array.lengthInBytes()); | 1795 array.lengthInBytes); |
| 1796 Expect.isTrue(empty is List<int>); | 1796 Expect.isTrue(empty is List<int>); |
| 1797 Expect.isTrue(empty is Uint32List); | 1797 Expect.isTrue(empty is Uint32List); |
| 1798 Expect.equals(0, empty.length); | 1798 Expect.equals(0, empty.length); |
| 1799 var whole = new Uint32List.view(array.asByteArray()); | 1799 var whole = new Uint32List.view(array.buffer); |
| 1800 Expect.isTrue(whole is List<int>); | 1800 Expect.isTrue(whole is List<int>); |
| 1801 Expect.isTrue(whole is Uint32List); | 1801 Expect.isTrue(whole is Uint32List); |
| 1802 Expect.equals(12, whole.length); | 1802 Expect.equals(12, whole.length); |
| 1803 var view = new Uint32List.view(array.asByteArray(), 4, 10); | 1803 var view = new Uint32List.view(array.buffer, 4, 10); |
| 1804 Expect.isTrue(view is List<int>); | 1804 Expect.isTrue(view is List<int>); |
| 1805 Expect.isTrue(view is Uint32List); | 1805 Expect.isTrue(view is Uint32List); |
| 1806 Expect.equals(10, view.length); | 1806 Expect.equals(10, view.length); |
| 1807 Expect.equals(4, view.bytesPerElement()); | 1807 Expect.equals(4, view.elementSizeInBytes); |
| 1808 Expect.equals(40, view.lengthInBytes()); | 1808 Expect.equals(40, view.lengthInBytes); |
| 1809 Expect.listEquals([0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF
F, | 1809 Expect.listEquals([0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF
F, |
| 1810 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF
F], | 1810 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF
F], |
| 1811 view); | 1811 view); |
| 1812 Expect.throws(() { view[-1] = 0; }, | 1812 Expect.throws(() { view[-1] = 0; }, |
| 1813 (e) { return e is RangeError; }); | 1813 (e) { return e is RangeError; }); |
| 1814 Expect.throws(() { return view[-1]; }, | 1814 Expect.throws(() { return view[-1]; }, |
| 1815 (e) { return e is RangeError; }); | 1815 (e) { return e is RangeError; }); |
| 1816 Expect.throws(() { view[view.length]; }, | 1816 Expect.throws(() { view[view.length]; }, |
| 1817 (e) { return e is RangeError; }); | 1817 (e) { return e is RangeError; }); |
| 1818 Expect.throws(() { view[view.length] = 0; }, | 1818 Expect.throws(() { view[view.length] = 0; }, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1901 | 1901 |
| 1902 static testUint32ListView() { | 1902 static testUint32ListView() { |
| 1903 var array = new Int8List(48); | 1903 var array = new Int8List(48); |
| 1904 testUint32ListViewImpl(array); | 1904 testUint32ListViewImpl(array); |
| 1905 array = new Int8List.transferable(48); | 1905 array = new Int8List.transferable(48); |
| 1906 testUint32ListViewImpl(array); | 1906 testUint32ListViewImpl(array); |
| 1907 } | 1907 } |
| 1908 | 1908 |
| 1909 static testInt64ListViewImpl(var array) { | 1909 static testInt64ListViewImpl(var array) { |
| 1910 Expect.equals(96, array.length); | 1910 Expect.equals(96, array.length); |
| 1911 Expect.equals(1, array.bytesPerElement()); | 1911 Expect.equals(1, array.elementSizeInBytes); |
| 1912 Expect.equals(96, array.lengthInBytes()); | 1912 Expect.equals(96, array.lengthInBytes); |
| 1913 for (int i = 0; i < array.length; ++i) { | 1913 for (int i = 0; i < array.length; ++i) { |
| 1914 array[i] = 0xFF; | 1914 array[i] = 0xFF; |
| 1915 } | 1915 } |
| 1916 Expect.throws(() { new Int64List.view(array.asByteArray(), -1); }, | 1916 Expect.throws(() { new Int64List.view(array.buffer, -1); }, |
| 1917 (e) { return e is RangeError; }); | 1917 (e) { return e is RangeError; }); |
| 1918 Expect.throws(() { new Int64List.view(array.asByteArray(), 0, -1); }, | 1918 Expect.throws(() { new Int64List.view(array.buffer, 0, -1); }, |
| 1919 (e) { return e is RangeError; }); | 1919 (e) { return e is RangeError; }); |
| 1920 Expect.throws(() { new Int64List.view(array.asByteArray(), | 1920 Expect.throws(() { new Int64List.view(array.buffer, |
| 1921 array.lengthInBytes() + 1); }, | 1921 array.lengthInBytes + 1); }, |
| 1922 (e) { return e is RangeError; }); | 1922 (e) { return e is RangeError; }); |
| 1923 Expect.throws(() { new Int64List.view(array.asByteArray(), | 1923 Expect.throws(() { new Int64List.view(array.buffer, |
| 1924 0, array.length + 1); }, | 1924 0, array.length + 1); }, |
| 1925 (e) { return e is RangeError; }); | 1925 (e) { return e is RangeError; }); |
| 1926 Expect.throws(() { new Int64List.view(array.asByteArray(), | 1926 Expect.throws(() { new Int64List.view(array.buffer, |
| 1927 array.length - 1, 2); }, | 1927 array.length - 1, 2); }, |
| 1928 (e) { return e is RangeError; }); | 1928 (e) { return e is RangeError; }); |
| 1929 var empty = new Int64List.view(array.asByteArray(), | 1929 var empty = new Int64List.view(array.buffer, |
| 1930 array.lengthInBytes()); | 1930 array.lengthInBytes); |
| 1931 Expect.isTrue(empty is List<int>); | 1931 Expect.isTrue(empty is List<int>); |
| 1932 Expect.isTrue(empty is Int64List); | 1932 Expect.isTrue(empty is Int64List); |
| 1933 Expect.equals(0, empty.length); | 1933 Expect.equals(0, empty.length); |
| 1934 var whole = new Int64List.view(array.asByteArray()); | 1934 var whole = new Int64List.view(array.buffer); |
| 1935 Expect.isTrue(whole is List<int>); | 1935 Expect.isTrue(whole is List<int>); |
| 1936 Expect.isTrue(whole is Int64List); | 1936 Expect.isTrue(whole is Int64List); |
| 1937 Expect.equals(12, whole.length); | 1937 Expect.equals(12, whole.length); |
| 1938 var view = new Int64List.view(array.asByteArray(), 8, 10); | 1938 var view = new Int64List.view(array.buffer, 8, 10); |
| 1939 Expect.isTrue(view is List<int>); | 1939 Expect.isTrue(view is List<int>); |
| 1940 Expect.isTrue(view is Int64List); | 1940 Expect.isTrue(view is Int64List); |
| 1941 Expect.equals(10, view.length); | 1941 Expect.equals(10, view.length); |
| 1942 Expect.equals(8, view.bytesPerElement()); | 1942 Expect.equals(8, view.elementSizeInBytes); |
| 1943 Expect.equals(80, view.lengthInBytes()); | 1943 Expect.equals(80, view.lengthInBytes); |
| 1944 Expect.listEquals([-1, -1, -1, -1, -1, | 1944 Expect.listEquals([-1, -1, -1, -1, -1, |
| 1945 -1, -1, -1, -1, -1], | 1945 -1, -1, -1, -1, -1], |
| 1946 view); | 1946 view); |
| 1947 Expect.throws(() { view[-1] = 0; }, | 1947 Expect.throws(() { view[-1] = 0; }, |
| 1948 (e) { return e is RangeError; }); | 1948 (e) { return e is RangeError; }); |
| 1949 Expect.throws(() { return view[-1]; }, | 1949 Expect.throws(() { return view[-1]; }, |
| 1950 (e) { return e is RangeError; }); | 1950 (e) { return e is RangeError; }); |
| 1951 Expect.throws(() { view[view.length]; }, | 1951 Expect.throws(() { view[view.length]; }, |
| 1952 (e) { return e is RangeError; }); | 1952 (e) { return e is RangeError; }); |
| 1953 Expect.throws(() { view[10] = 0; }, | 1953 Expect.throws(() { view[10] = 0; }, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2103 static testInt64ListView() { | 2103 static testInt64ListView() { |
| 2104 var array = new Uint8List(96); | 2104 var array = new Uint8List(96); |
| 2105 testInt64ListViewImpl(array); | 2105 testInt64ListViewImpl(array); |
| 2106 array = new Uint8List.transferable(96); | 2106 array = new Uint8List.transferable(96); |
| 2107 testInt64ListViewImpl(array); | 2107 testInt64ListViewImpl(array); |
| 2108 } | 2108 } |
| 2109 | 2109 |
| 2110 static testUint64ListViewImpl(var array) { | 2110 static testUint64ListViewImpl(var array) { |
| 2111 Expect.isTrue(array is List<int>); | 2111 Expect.isTrue(array is List<int>); |
| 2112 Expect.equals(96, array.length); | 2112 Expect.equals(96, array.length); |
| 2113 Expect.equals(1, array.bytesPerElement()); | 2113 Expect.equals(1, array.elementSizeInBytes); |
| 2114 Expect.equals(96, array.lengthInBytes()); | 2114 Expect.equals(96, array.lengthInBytes); |
| 2115 for (int i = 0; i < array.length; ++i) { | 2115 for (int i = 0; i < array.length; ++i) { |
| 2116 array[i] = -1; | 2116 array[i] = -1; |
| 2117 } | 2117 } |
| 2118 Expect.throws(() { new Uint64List.view(array.asByteArray(), -1); }, | 2118 Expect.throws(() { new Uint64List.view(array.buffer, -1); }, |
| 2119 (e) { return e is RangeError; }); | 2119 (e) { return e is RangeError; }); |
| 2120 Expect.throws(() { new Uint64List.view(array.asByteArray(), 0, -1); }, | 2120 Expect.throws(() { new Uint64List.view(array.buffer, 0, -1); }, |
| 2121 (e) { return e is RangeError; }); | 2121 (e) { return e is RangeError; }); |
| 2122 Expect.throws(() { new Uint64List.view(array.asByteArray(), | 2122 Expect.throws(() { new Uint64List.view(array.buffer, |
| 2123 array.lengthInBytes() + 1); }, | 2123 array.lengthInBytes + 1); }, |
| 2124 (e) { return e is RangeError; }); | 2124 (e) { return e is RangeError; }); |
| 2125 Expect.throws(() { new Uint64List.view(array.asByteArray(), | 2125 Expect.throws(() { new Uint64List.view(array.buffer, |
| 2126 0, array.length + 1); }, | 2126 0, array.length + 1); }, |
| 2127 (e) { return e is RangeError; }); | 2127 (e) { return e is RangeError; }); |
| 2128 Expect.throws(() { new Uint64List.view(array.asByteArray(), | 2128 Expect.throws(() { new Uint64List.view(array.buffer, |
| 2129 array.length - 1, 2); }, | 2129 array.length - 1, 2); }, |
| 2130 (e) { return e is RangeError; }); | 2130 (e) { return e is RangeError; }); |
| 2131 var empty = new Uint64List.view(array.asByteArray(), | 2131 var empty = new Uint64List.view(array.buffer, |
| 2132 array.lengthInBytes()); | 2132 array.lengthInBytes); |
| 2133 Expect.isTrue(empty is List<int>); | 2133 Expect.isTrue(empty is List<int>); |
| 2134 Expect.isTrue(empty is Uint64List); | 2134 Expect.isTrue(empty is Uint64List); |
| 2135 Expect.equals(0, empty.length); | 2135 Expect.equals(0, empty.length); |
| 2136 var whole = new Uint64List.view(array.asByteArray()); | 2136 var whole = new Uint64List.view(array.buffer); |
| 2137 Expect.isTrue(whole is List<int>); | 2137 Expect.isTrue(whole is List<int>); |
| 2138 Expect.isTrue(whole is Uint64List); | 2138 Expect.isTrue(whole is Uint64List); |
| 2139 Expect.equals(12, whole.length); | 2139 Expect.equals(12, whole.length); |
| 2140 var view = new Uint64List.view(array.asByteArray(), 8, 10); | 2140 var view = new Uint64List.view(array.buffer, 8, 10); |
| 2141 Expect.isTrue(view is List<int>); | 2141 Expect.isTrue(view is List<int>); |
| 2142 Expect.isTrue(view is Uint64List); | 2142 Expect.isTrue(view is Uint64List); |
| 2143 Expect.equals(10, view.length); | 2143 Expect.equals(10, view.length); |
| 2144 Expect.equals(8, view.bytesPerElement()); | 2144 Expect.equals(8, view.elementSizeInBytes); |
| 2145 Expect.equals(80, view.lengthInBytes()); | 2145 Expect.equals(80, view.lengthInBytes); |
| 2146 Expect.listEquals([0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, | 2146 Expect.listEquals([0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, |
| 2147 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, | 2147 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, |
| 2148 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, | 2148 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, |
| 2149 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, | 2149 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, |
| 2150 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF], | 2150 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF], |
| 2151 view); | 2151 view); |
| 2152 Expect.throws(() { view[-1] = 0; }, | 2152 Expect.throws(() { view[-1] = 0; }, |
| 2153 (e) { return e is RangeError; }); | 2153 (e) { return e is RangeError; }); |
| 2154 Expect.throws(() { return view[-1]; }, | 2154 Expect.throws(() { return view[-1]; }, |
| 2155 (e) { return e is RangeError; }); | 2155 (e) { return e is RangeError; }); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2266 static testUint64ListView() { | 2266 static testUint64ListView() { |
| 2267 var array = new Int8List(96); | 2267 var array = new Int8List(96); |
| 2268 testUint64ListViewImpl(array); | 2268 testUint64ListViewImpl(array); |
| 2269 array = new Int8List.transferable(96); | 2269 array = new Int8List.transferable(96); |
| 2270 testUint64ListViewImpl(array); | 2270 testUint64ListViewImpl(array); |
| 2271 } | 2271 } |
| 2272 | 2272 |
| 2273 static testFloat32ListViewImpl(var array) { | 2273 static testFloat32ListViewImpl(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(4, array.bytesPerElement()); | 2276 Expect.equals(4, array.elementSizeInBytes); |
| 2277 Expect.equals(48, array.lengthInBytes()); | 2277 Expect.equals(48, array.lengthInBytes); |
| 2278 for (int i = 0; i < array.length; ++i) { | 2278 for (int i = 0; i < array.length; ++i) { |
| 2279 array[i] = 0xBF800000; | 2279 array[i] = 0xBF800000; |
| 2280 } | 2280 } |
| 2281 Expect.throws(() { new Float32List.view(array.asByteArray(), -1); }, | 2281 Expect.throws(() { new Float32List.view(array.buffer, -1); }, |
| 2282 (e) { return e is RangeError; }); | 2282 (e) { return e is RangeError; }); |
| 2283 Expect.throws(() { new Float32List.view(array.asByteArray(), 0, -1); }, | 2283 Expect.throws(() { new Float32List.view(array.buffer, 0, -1); }, |
| 2284 (e) { return e is RangeError; }); | 2284 (e) { return e is RangeError; }); |
| 2285 Expect.throws(() { new Float32List.view(array.asByteArray(), | 2285 Expect.throws(() { new Float32List.view(array.buffer, |
| 2286 array.lengthInBytes() + 1); }, | 2286 array.lengthInBytes + 1); }, |
| 2287 (e) { return e is RangeError; }); | 2287 (e) { return e is RangeError; }); |
| 2288 Expect.throws(() { new Float32List.view(array.asByteArray(), | 2288 Expect.throws(() { new Float32List.view(array.buffer, |
| 2289 0, array.lengthInBytes() + 1); }, | 2289 0, array.lengthInBytes + 1); }, |
| 2290 (e) { return e is RangeError; }); | 2290 (e) { return e is RangeError; }); |
| 2291 Expect.throws(() { new Float32List.view(array.asByteArray(), | 2291 Expect.throws(() { new Float32List.view(array.buffer, |
| 2292 array.lengthInBytes() - 1, 2); }, | 2292 array.lengthInBytes - 1, 2); }, |
| 2293 (e) { return e is RangeError; }); | 2293 (e) { return e is RangeError; }); |
| 2294 var empty = new Float32List.view(array.asByteArray(), | 2294 var empty = new Float32List.view(array.buffer, |
| 2295 array.lengthInBytes()); | 2295 array.lengthInBytes); |
| 2296 Expect.isTrue(empty is List<double>); | 2296 Expect.isTrue(empty is List<double>); |
| 2297 Expect.isTrue(empty is Float32List); | 2297 Expect.isTrue(empty is Float32List); |
| 2298 Expect.equals(0, empty.length); | 2298 Expect.equals(0, empty.length); |
| 2299 var whole = new Float32List.view(array.asByteArray()); | 2299 var whole = new Float32List.view(array.buffer); |
| 2300 Expect.isTrue(whole is List<double>); | 2300 Expect.isTrue(whole is List<double>); |
| 2301 Expect.isTrue(whole is Float32List); | 2301 Expect.isTrue(whole is Float32List); |
| 2302 Expect.equals(12, whole.length); | 2302 Expect.equals(12, whole.length); |
| 2303 var view = new Float32List.view(array.asByteArray(), 4, 10); | 2303 var view = new Float32List.view(array.buffer, 4, 10); |
| 2304 Expect.isTrue(view is List<double>); | 2304 Expect.isTrue(view is List<double>); |
| 2305 Expect.isTrue(view is Float32List); | 2305 Expect.isTrue(view is Float32List); |
| 2306 Expect.equals(10, view.length); | 2306 Expect.equals(10, view.length); |
| 2307 Expect.equals(4, view.bytesPerElement()); | 2307 Expect.equals(4, view.elementSizeInBytes); |
| 2308 Expect.equals(40, view.lengthInBytes()); | 2308 Expect.equals(40, view.lengthInBytes); |
| 2309 Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0, | 2309 Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0, |
| 2310 -1.0, -1.0, -1.0, -1.0, -1.0], | 2310 -1.0, -1.0, -1.0, -1.0, -1.0], |
| 2311 view); | 2311 view); |
| 2312 Expect.throws(() { view[-1] = 0.0; }, | 2312 Expect.throws(() { view[-1] = 0.0; }, |
| 2313 (e) { return e is RangeError; }); | 2313 (e) { return e is RangeError; }); |
| 2314 Expect.throws(() { return view[-1]; }, | 2314 Expect.throws(() { return view[-1]; }, |
| 2315 (e) { return e is RangeError; }); | 2315 (e) { return e is RangeError; }); |
| 2316 Expect.throws(() { view[10]; }, | 2316 Expect.throws(() { view[10]; }, |
| 2317 (e) { return e is RangeError; }); | 2317 (e) { return e is RangeError; }); |
| 2318 Expect.throws(() { view[10] = 0.0; }, | 2318 Expect.throws(() { view[10] = 0.0; }, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2375 static testFloat32ListView() { | 2375 static testFloat32ListView() { |
| 2376 var array = new Uint32List(12); | 2376 var array = new Uint32List(12); |
| 2377 testFloat32ListViewImpl(array); | 2377 testFloat32ListViewImpl(array); |
| 2378 array = new Uint32List.transferable(12); | 2378 array = new Uint32List.transferable(12); |
| 2379 testFloat32ListViewImpl(array); | 2379 testFloat32ListViewImpl(array); |
| 2380 } | 2380 } |
| 2381 | 2381 |
| 2382 static testFloat64ListViewImpl(var array) { | 2382 static testFloat64ListViewImpl(var array) { |
| 2383 Expect.isTrue(array is List<int>); | 2383 Expect.isTrue(array is List<int>); |
| 2384 Expect.equals(12, array.length); | 2384 Expect.equals(12, array.length); |
| 2385 Expect.equals(8, array.bytesPerElement()); | 2385 Expect.equals(8, array.elementSizeInBytes); |
| 2386 Expect.equals(96, array.lengthInBytes()); | 2386 Expect.equals(96, array.lengthInBytes); |
| 2387 for (int i = 0; i < array.length; ++i) { | 2387 for (int i = 0; i < array.length; ++i) { |
| 2388 array[i] = 0xBFF0000000000000; | 2388 array[i] = 0xBFF0000000000000; |
| 2389 } | 2389 } |
| 2390 Expect.throws(() { new Float64List.view(array.asByteArray(), -1); }, | 2390 Expect.throws(() { new Float64List.view(array.buffer, -1); }, |
| 2391 (e) { return e is RangeError; }); | 2391 (e) { return e is RangeError; }); |
| 2392 Expect.throws(() { new Float64List.view(array.asByteArray(), 0, -1); }, | 2392 Expect.throws(() { new Float64List.view(array.buffer, 0, -1); }, |
| 2393 (e) { return e is RangeError; }); | 2393 (e) { return e is RangeError; }); |
| 2394 Expect.throws(() { new Float64List.view(array.asByteArray(), | 2394 Expect.throws(() { new Float64List.view(array.buffer, |
| 2395 array.lengthInBytes() + 1); }, | 2395 array.lengthInBytes + 1); }, |
| 2396 (e) { return e is RangeError; }); | 2396 (e) { return e is RangeError; }); |
| 2397 Expect.throws(() { new Float64List.view(array.asByteArray(), | 2397 Expect.throws(() { new Float64List.view(array.buffer, |
| 2398 0, array.lengthInBytes() + 1); }, | 2398 0, array.lengthInBytes + 1); }, |
| 2399 (e) { return e is RangeError; }); | 2399 (e) { return e is RangeError; }); |
| 2400 Expect.throws(() { new Float64List.view(array.asByteArray(), | 2400 Expect.throws(() { new Float64List.view(array.buffer, |
| 2401 array.lengthInBytes() - 1, 2); }, | 2401 array.lengthInBytes - 1, 2); }, |
| 2402 (e) { return e is RangeError; }); | 2402 (e) { return e is RangeError; }); |
| 2403 var empty = new Float64List.view(array.asByteArray(), | 2403 var empty = new Float64List.view(array.buffer, |
| 2404 array.lengthInBytes()); | 2404 array.lengthInBytes); |
| 2405 Expect.isTrue(empty is List<double>); | 2405 Expect.isTrue(empty is List<double>); |
| 2406 Expect.isTrue(empty is Float64List); | 2406 Expect.isTrue(empty is Float64List); |
| 2407 Expect.equals(0, empty.length); | 2407 Expect.equals(0, empty.length); |
| 2408 var whole = new Float64List.view(array.asByteArray()); | 2408 var whole = new Float64List.view(array.buffer); |
| 2409 Expect.isTrue(whole is List<double>); | 2409 Expect.isTrue(whole is List<double>); |
| 2410 Expect.isTrue(whole is Float64List); | 2410 Expect.isTrue(whole is Float64List); |
| 2411 Expect.equals(12, whole.length); | 2411 Expect.equals(12, whole.length); |
| 2412 var view = new Float64List.view(array.asByteArray(), 8, 10); | 2412 var view = new Float64List.view(array.buffer, 8, 10); |
| 2413 Expect.isTrue(view is List<double>); | 2413 Expect.isTrue(view is List<double>); |
| 2414 Expect.isTrue(view is Float64List); | 2414 Expect.isTrue(view is Float64List); |
| 2415 Expect.equals(10, view.length); | 2415 Expect.equals(10, view.length); |
| 2416 Expect.equals(8, view.bytesPerElement()); | 2416 Expect.equals(8, view.elementSizeInBytes); |
| 2417 Expect.equals(80, view.lengthInBytes()); | 2417 Expect.equals(80, view.lengthInBytes); |
| 2418 Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0, | 2418 Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0, |
| 2419 -1.0, -1.0, -1.0, -1.0, -1.0], | 2419 -1.0, -1.0, -1.0, -1.0, -1.0], |
| 2420 view); | 2420 view); |
| 2421 Expect.throws(() { view[-1] = 0.0; }, | 2421 Expect.throws(() { view[-1] = 0.0; }, |
| 2422 (e) { return e is RangeError; }); | 2422 (e) { return e is RangeError; }); |
| 2423 Expect.throws(() { return view[-1]; }, | 2423 Expect.throws(() { return view[-1]; }, |
| 2424 (e) { return e is RangeError; }); | 2424 (e) { return e is RangeError; }); |
| 2425 Expect.throws(() { view[10]; }, | 2425 Expect.throws(() { view[10]; }, |
| 2426 (e) { return e is RangeError; }); | 2426 (e) { return e is RangeError; }); |
| 2427 Expect.throws(() { view[10] = 0.0; }, | 2427 Expect.throws(() { view[10] = 0.0; }, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2493 testUint8List(); | 2493 testUint8List(); |
| 2494 testUint8ClampedList(); | 2494 testUint8ClampedList(); |
| 2495 testInt16List(); | 2495 testInt16List(); |
| 2496 testUint16List(); | 2496 testUint16List(); |
| 2497 testInt32List(); | 2497 testInt32List(); |
| 2498 testUint32List(); | 2498 testUint32List(); |
| 2499 testInt64List(); | 2499 testInt64List(); |
| 2500 testUint64List(); | 2500 testUint64List(); |
| 2501 testFloat32List(); | 2501 testFloat32List(); |
| 2502 testFloat64List(); | 2502 testFloat64List(); |
| 2503 testByteList(); | 2503 |
| 2504 testInt8ListView(); | 2504 testInt8ListView(); |
| 2505 testUint8ListView(); | 2505 testUint8ListView(); |
| 2506 testInt16ListView(); | 2506 testInt16ListView(); |
| 2507 testUint16ListView(); | 2507 testUint16ListView(); |
| 2508 testInt32ListView(); | 2508 testInt32ListView(); |
| 2509 testUint32ListView(); | 2509 testUint32ListView(); |
| 2510 testInt64ListView(); | 2510 testInt64ListView(); |
| 2511 testUint64ListView(); | 2511 testUint64ListView(); |
| 2512 testFloat32ListView(); | 2512 testFloat32ListView(); |
| 2513 testFloat64ListView(); | 2513 testFloat64ListView(); |
| 2514 |
| 2515 testByteList(); |
| 2514 } | 2516 } |
| 2515 } | 2517 } |
| 2516 | 2518 |
| 2517 main() { | 2519 main() { |
| 2518 for (var i=0; i<1000; i++) { | 2520 for (var i=0; i<1000; i++) { |
| 2519 ByteArrayTest.testMain(); | 2521 ByteArrayTest.testMain(); |
| 2520 } | 2522 } |
| 2521 } | 2523 } |
| OLD | NEW |