| 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 // This test exercises optimized [] and []= operators | 10 // This test exercises optimized [] and []= operators |
| 11 // on byte array views. | 11 // on byte array views. |
| 12 class OptimizedByteArrayTest { | 12 class OptimizedByteArrayTest { |
| 13 static testInt8ListImpl(Int8List array) { | 13 static testInt8ListImpl(Int8List array) { |
| 14 Expect.isTrue(array is List<int>); | 14 Expect.isTrue(array is List<int>); |
| 15 Expect.equals(10, array.length); | 15 Expect.equals(10, array.length); |
| 16 Expect.equals(1, array.bytesPerElement()); | 16 Expect.equals(1, array.elementSizeInBytes); |
| 17 Expect.equals(10, array.lengthInBytes()); | 17 Expect.equals(10, array.lengthInBytes); |
| 18 Expect.listEquals([0, 0, 0, 0, 0, | 18 Expect.listEquals([0, 0, 0, 0, 0, |
| 19 0, 0, 0, 0, 0], | 19 0, 0, 0, 0, 0], |
| 20 array); | 20 array); |
| 21 Expect.throws(() { array[-1] = 0; }, | 21 Expect.throws(() { array[-1] = 0; }, |
| 22 (e) { return e is RangeError; }); | 22 (e) { return e is RangeError; }); |
| 23 Expect.throws(() { return array[-1]; }, | 23 Expect.throws(() { return array[-1]; }, |
| 24 (e) { return e is RangeError; }); | 24 (e) { return e is RangeError; }); |
| 25 Expect.throws(() { array[10]; }, | 25 Expect.throws(() { array[10]; }, |
| 26 (e) { return e is RangeError; }); | 26 (e) { return e is RangeError; }); |
| 27 Expect.throws(() { array[10] = 0; }, | 27 Expect.throws(() { array[10] = 0; }, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 static testInt8List() { | 93 static testInt8List() { |
| 94 Expect.throws(() { new Int8List(-1); }, | 94 Expect.throws(() { new Int8List(-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 } | 98 } |
| 99 | 99 |
| 100 static testUint8ListImpl(Uint8List array) { | 100 static testUint8ListImpl(Uint8List array) { |
| 101 Expect.isTrue(array is List<int>); | 101 Expect.isTrue(array is List<int>); |
| 102 Expect.equals(10, array.length); | 102 Expect.equals(10, array.length); |
| 103 Expect.equals(1, array.bytesPerElement()); | 103 Expect.equals(1, array.elementSizeInBytes); |
| 104 Expect.equals(10, array.lengthInBytes()); | 104 Expect.equals(10, array.lengthInBytes); |
| 105 Expect.listEquals([0, 0, 0, 0, 0, | 105 Expect.listEquals([0, 0, 0, 0, 0, |
| 106 0, 0, 0, 0, 0], | 106 0, 0, 0, 0, 0], |
| 107 array); | 107 array); |
| 108 Expect.throws(() { array[-1] = 0; }, | 108 Expect.throws(() { array[-1] = 0; }, |
| 109 (e) { return e is RangeError; }); | 109 (e) { return e is RangeError; }); |
| 110 Expect.throws(() { return array[-1]; }, | 110 Expect.throws(() { return array[-1]; }, |
| 111 (e) { return e is RangeError; }); | 111 (e) { return e is RangeError; }); |
| 112 Expect.throws(() { array[10]; }, | 112 Expect.throws(() { array[10]; }, |
| 113 (e) { return e is RangeError; }); | 113 (e) { return e is RangeError; }); |
| 114 Expect.throws(() { array[10] = 0; }, | 114 Expect.throws(() { array[10] = 0; }, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 static testUint8List() { | 169 static testUint8List() { |
| 170 Expect.throws(() { new Uint8List(-1); }, | 170 Expect.throws(() { new Uint8List(-1); }, |
| 171 (e) { return e is ArgumentError; }); | 171 (e) { return e is ArgumentError; }); |
| 172 var array = new Uint8List(10); | 172 var array = new Uint8List(10); |
| 173 testUint8ListImpl(array); | 173 testUint8ListImpl(array); |
| 174 } | 174 } |
| 175 | 175 |
| 176 static testInt16ListImpl(Int16List array) { | 176 static testInt16ListImpl(Int16List array) { |
| 177 Expect.isTrue(array is List<int>); | 177 Expect.isTrue(array is List<int>); |
| 178 Expect.equals(10, array.length); | 178 Expect.equals(10, array.length); |
| 179 Expect.equals(2, array.bytesPerElement()); | 179 Expect.equals(2, array.elementSizeInBytes); |
| 180 Expect.equals(20, array.lengthInBytes()); | 180 Expect.equals(20, array.lengthInBytes); |
| 181 Expect.listEquals([0, 0, 0, 0, 0, | 181 Expect.listEquals([0, 0, 0, 0, 0, |
| 182 0, 0, 0, 0, 0], | 182 0, 0, 0, 0, 0], |
| 183 array); | 183 array); |
| 184 Expect.throws(() { array[-1] = 0; }, | 184 Expect.throws(() { array[-1] = 0; }, |
| 185 (e) { return e is RangeError; }); | 185 (e) { return e is RangeError; }); |
| 186 Expect.throws(() { return array[-1]; }, | 186 Expect.throws(() { return array[-1]; }, |
| 187 (e) { return e is RangeError; }); | 187 (e) { return e is RangeError; }); |
| 188 Expect.throws(() { array[10]; }, | 188 Expect.throws(() { array[10]; }, |
| 189 (e) { return e is RangeError; }); | 189 (e) { return e is RangeError; }); |
| 190 Expect.throws(() { array[10] = 0; }, | 190 Expect.throws(() { array[10] = 0; }, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 static testInt16List() { | 257 static testInt16List() { |
| 258 Expect.throws(() { new Int16List(-1); }, | 258 Expect.throws(() { new Int16List(-1); }, |
| 259 (e) { return e is ArgumentError; }); | 259 (e) { return e is ArgumentError; }); |
| 260 var array = new Int16List(10); | 260 var array = new Int16List(10); |
| 261 testInt16ListImpl(array); | 261 testInt16ListImpl(array); |
| 262 } | 262 } |
| 263 | 263 |
| 264 static testUint16ListImpl(Uint16List array) { | 264 static testUint16ListImpl(Uint16List array) { |
| 265 Expect.isTrue(array is List<int>); | 265 Expect.isTrue(array is List<int>); |
| 266 Expect.equals(10, array.length); | 266 Expect.equals(10, array.length); |
| 267 Expect.equals(2, array.bytesPerElement()); | 267 Expect.equals(2, array.elementSizeInBytes); |
| 268 Expect.equals(20, array.lengthInBytes()); | 268 Expect.equals(20, array.lengthInBytes); |
| 269 Expect.listEquals([0, 0, 0, 0, 0, | 269 Expect.listEquals([0, 0, 0, 0, 0, |
| 270 0, 0, 0, 0, 0], | 270 0, 0, 0, 0, 0], |
| 271 array); | 271 array); |
| 272 Expect.throws(() { array[-1] = 0; }, | 272 Expect.throws(() { array[-1] = 0; }, |
| 273 (e) { return e is RangeError; }); | 273 (e) { return e is RangeError; }); |
| 274 Expect.throws(() { return array[-1]; }, | 274 Expect.throws(() { return array[-1]; }, |
| 275 (e) { return e is RangeError; }); | 275 (e) { return e is RangeError; }); |
| 276 Expect.throws(() { array[10]; }, | 276 Expect.throws(() { array[10]; }, |
| 277 (e) { return e is RangeError; }); | 277 (e) { return e is RangeError; }); |
| 278 Expect.throws(() { array[10] = 0; }, | 278 Expect.throws(() { array[10] = 0; }, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 static testUint16List() { | 333 static testUint16List() { |
| 334 Expect.throws(() { new Uint16List(-1); }, | 334 Expect.throws(() { new Uint16List(-1); }, |
| 335 (e) { return e is ArgumentError; }); | 335 (e) { return e is ArgumentError; }); |
| 336 var array = new Uint16List(10); | 336 var array = new Uint16List(10); |
| 337 testUint16ListImpl(array); | 337 testUint16ListImpl(array); |
| 338 } | 338 } |
| 339 | 339 |
| 340 static testInt32ListImpl(Int32List array) { | 340 static testInt32ListImpl(Int32List array) { |
| 341 Expect.isTrue(array is List<int>); | 341 Expect.isTrue(array is List<int>); |
| 342 Expect.equals(10, array.length); | 342 Expect.equals(10, array.length); |
| 343 Expect.equals(4, array.bytesPerElement()); | 343 Expect.equals(4, array.elementSizeInBytes); |
| 344 Expect.equals(40, array.lengthInBytes()); | 344 Expect.equals(40, array.lengthInBytes); |
| 345 Expect.listEquals([0, 0, 0, 0, 0, | 345 Expect.listEquals([0, 0, 0, 0, 0, |
| 346 0, 0, 0, 0, 0], | 346 0, 0, 0, 0, 0], |
| 347 array); | 347 array); |
| 348 Expect.throws(() { array[-1] = 0; }, | 348 Expect.throws(() { array[-1] = 0; }, |
| 349 (e) { return e is RangeError; }); | 349 (e) { return e is RangeError; }); |
| 350 Expect.throws(() { return array[-1]; }, | 350 Expect.throws(() { return array[-1]; }, |
| 351 (e) { return e is RangeError; }); | 351 (e) { return e is RangeError; }); |
| 352 Expect.throws(() { array[10]; }, | 352 Expect.throws(() { array[10]; }, |
| 353 (e) { return e is RangeError; }); | 353 (e) { return e is RangeError; }); |
| 354 Expect.throws(() { array[10] = 0; }, | 354 Expect.throws(() { array[10] = 0; }, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 static testInt32List() { | 427 static testInt32List() { |
| 428 Expect.throws(() { new Int32List(-1); }, | 428 Expect.throws(() { new Int32List(-1); }, |
| 429 (e) { return e is ArgumentError; }); | 429 (e) { return e is ArgumentError; }); |
| 430 var array = new Int32List(10); | 430 var array = new Int32List(10); |
| 431 testInt32ListImpl(array); | 431 testInt32ListImpl(array); |
| 432 } | 432 } |
| 433 | 433 |
| 434 static testUint32ListImpl(Uint32List array) { | 434 static testUint32ListImpl(Uint32List array) { |
| 435 Expect.isTrue(array is List<int>); | 435 Expect.isTrue(array is List<int>); |
| 436 Expect.equals(10, array.length); | 436 Expect.equals(10, array.length); |
| 437 Expect.equals(4, array.bytesPerElement()); | 437 Expect.equals(4, array.elementSizeInBytes); |
| 438 Expect.equals(40, array.lengthInBytes()); | 438 Expect.equals(40, array.lengthInBytes); |
| 439 Expect.listEquals([0, 0, 0, 0, 0, | 439 Expect.listEquals([0, 0, 0, 0, 0, |
| 440 0, 0, 0, 0, 0], | 440 0, 0, 0, 0, 0], |
| 441 array); | 441 array); |
| 442 Expect.throws(() { array[-1] = 0; }, | 442 Expect.throws(() { array[-1] = 0; }, |
| 443 (e) { return e is RangeError; }); | 443 (e) { return e is RangeError; }); |
| 444 Expect.throws(() { return array[-1]; }, | 444 Expect.throws(() { return array[-1]; }, |
| 445 (e) { return e is RangeError; }); | 445 (e) { return e is RangeError; }); |
| 446 Expect.throws(() { array[10]; }, | 446 Expect.throws(() { array[10]; }, |
| 447 (e) { return e is RangeError; }); | 447 (e) { return e is RangeError; }); |
| 448 Expect.throws(() { array[10] = 0; }, | 448 Expect.throws(() { array[10] = 0; }, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 Expect.throws(() { new Uint32List(-1); }, | 509 Expect.throws(() { new Uint32List(-1); }, |
| 510 (e) { return e is ArgumentError; }); | 510 (e) { return e is ArgumentError; }); |
| 511 var array = new Uint32List(10); | 511 var array = new Uint32List(10); |
| 512 testUint32ListImpl(array); | 512 testUint32ListImpl(array); |
| 513 | 513 |
| 514 } | 514 } |
| 515 | 515 |
| 516 static testInt64ListImpl(Int64List array) { | 516 static testInt64ListImpl(Int64List array) { |
| 517 Expect.isTrue(array is List<int>); | 517 Expect.isTrue(array is List<int>); |
| 518 Expect.equals(10, array.length); | 518 Expect.equals(10, array.length); |
| 519 Expect.equals(8, array.bytesPerElement()); | 519 Expect.equals(8, array.elementSizeInBytes); |
| 520 Expect.equals(80, array.lengthInBytes()); | 520 Expect.equals(80, array.lengthInBytes); |
| 521 Expect.listEquals([0, 0, 0, 0, 0, | 521 Expect.listEquals([0, 0, 0, 0, 0, |
| 522 0, 0, 0, 0, 0], | 522 0, 0, 0, 0, 0], |
| 523 array); | 523 array); |
| 524 Expect.throws(() { array[-1] = 0; }, | 524 Expect.throws(() { array[-1] = 0; }, |
| 525 (e) { return e is RangeError; }); | 525 (e) { return e is RangeError; }); |
| 526 Expect.throws(() { return array[-1]; }, | 526 Expect.throws(() { return array[-1]; }, |
| 527 (e) { return e is RangeError; }); | 527 (e) { return e is RangeError; }); |
| 528 Expect.throws(() { array[10]; }, | 528 Expect.throws(() { array[10]; }, |
| 529 (e) { return e is RangeError; }); | 529 (e) { return e is RangeError; }); |
| 530 Expect.throws(() { array[10] = 0; }, | 530 Expect.throws(() { array[10] = 0; }, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 static testInt64List() { | 604 static testInt64List() { |
| 605 Expect.throws(() { new Int64List(-1); }, | 605 Expect.throws(() { new Int64List(-1); }, |
| 606 (e) { return e is ArgumentError; }); | 606 (e) { return e is ArgumentError; }); |
| 607 var array = new Int64List(10); | 607 var array = new Int64List(10); |
| 608 testInt64ListImpl(array); | 608 testInt64ListImpl(array); |
| 609 } | 609 } |
| 610 | 610 |
| 611 static testUint64ListImpl(Uint64List array) { | 611 static testUint64ListImpl(Uint64List array) { |
| 612 Expect.isTrue(array is List<int>); | 612 Expect.isTrue(array is List<int>); |
| 613 Expect.equals(10, array.length); | 613 Expect.equals(10, array.length); |
| 614 Expect.equals(8, array.bytesPerElement()); | 614 Expect.equals(8, array.elementSizeInBytes); |
| 615 Expect.equals(80, array.lengthInBytes()); | 615 Expect.equals(80, array.lengthInBytes); |
| 616 Expect.listEquals([0, 0, 0, 0, 0, | 616 Expect.listEquals([0, 0, 0, 0, 0, |
| 617 0, 0, 0, 0, 0], | 617 0, 0, 0, 0, 0], |
| 618 array); | 618 array); |
| 619 Expect.throws(() { array[-1] = 0; }, | 619 Expect.throws(() { array[-1] = 0; }, |
| 620 (e) { return e is RangeError; }); | 620 (e) { return e is RangeError; }); |
| 621 Expect.throws(() { return array[-1]; }, | 621 Expect.throws(() { return array[-1]; }, |
| 622 (e) { return e is RangeError; }); | 622 (e) { return e is RangeError; }); |
| 623 Expect.throws(() { array[10]; }, | 623 Expect.throws(() { array[10]; }, |
| 624 (e) { return e is RangeError; }); | 624 (e) { return e is RangeError; }); |
| 625 Expect.throws(() { array[10] = 0; }, | 625 Expect.throws(() { array[10] = 0; }, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 static testUint64List() { | 683 static testUint64List() { |
| 684 Expect.throws(() { new Uint64List(-1); }, | 684 Expect.throws(() { new Uint64List(-1); }, |
| 685 (e) { return e is ArgumentError; }); | 685 (e) { return e is ArgumentError; }); |
| 686 var array = new Uint64List(10); | 686 var array = new Uint64List(10); |
| 687 testUint64ListImpl(array); | 687 testUint64ListImpl(array); |
| 688 } | 688 } |
| 689 | 689 |
| 690 static testFloat32ListImpl(Float32List array) { | 690 static testFloat32ListImpl(Float32List array) { |
| 691 Expect.isTrue(array is List<double>); | 691 Expect.isTrue(array is List<double>); |
| 692 Expect.equals(10, array.length); | 692 Expect.equals(10, array.length); |
| 693 Expect.equals(4, array.bytesPerElement()); | 693 Expect.equals(4, array.elementSizeInBytes); |
| 694 Expect.equals(40, array.lengthInBytes()); | 694 Expect.equals(40, array.lengthInBytes); |
| 695 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, | 695 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, |
| 696 0.0, 0.0, 0.0, 0.0, 0.0], | 696 0.0, 0.0, 0.0, 0.0, 0.0], |
| 697 array); | 697 array); |
| 698 Expect.throws(() { array[-1] = 0.0; }, | 698 Expect.throws(() { array[-1] = 0.0; }, |
| 699 (e) { return e is RangeError; }); | 699 (e) { return e is RangeError; }); |
| 700 Expect.throws(() { return array[-1]; }, | 700 Expect.throws(() { return array[-1]; }, |
| 701 (e) { return e is RangeError; }); | 701 (e) { return e is RangeError; }); |
| 702 Expect.throws(() { array[10]; }, | 702 Expect.throws(() { array[10]; }, |
| 703 (e) { return e is RangeError; }); | 703 (e) { return e is RangeError; }); |
| 704 Expect.throws(() { array[10] = 0.0; }, | 704 Expect.throws(() { array[10] = 0.0; }, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 static testFloat32List() { | 749 static testFloat32List() { |
| 750 Expect.throws(() { new Float32List(-1); }, | 750 Expect.throws(() { new Float32List(-1); }, |
| 751 (e) { return e is ArgumentError; }); | 751 (e) { return e is ArgumentError; }); |
| 752 var array = new Float32List(10); | 752 var array = new Float32List(10); |
| 753 testFloat32ListImpl(array); | 753 testFloat32ListImpl(array); |
| 754 } | 754 } |
| 755 | 755 |
| 756 static testFloat64ListImpl(Float64List array) { | 756 static testFloat64ListImpl(Float64List array) { |
| 757 Expect.isTrue(array is List<double>); | 757 Expect.isTrue(array is List<double>); |
| 758 Expect.equals(10, array.length); | 758 Expect.equals(10, array.length); |
| 759 Expect.equals(8, array.bytesPerElement()); | 759 Expect.equals(8, array.elementSizeInBytes); |
| 760 Expect.equals(80, array.lengthInBytes()); | 760 Expect.equals(80, array.lengthInBytes); |
| 761 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, | 761 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, |
| 762 0.0, 0.0, 0.0, 0.0, 0.0], | 762 0.0, 0.0, 0.0, 0.0, 0.0], |
| 763 array); | 763 array); |
| 764 Expect.throws(() { array[-1] = 0.0; }, | 764 Expect.throws(() { array[-1] = 0.0; }, |
| 765 (e) { return e is RangeError; }); | 765 (e) { return e is RangeError; }); |
| 766 Expect.throws(() { return array[-1]; }, | 766 Expect.throws(() { return array[-1]; }, |
| 767 (e) { return e is RangeError; }); | 767 (e) { return e is RangeError; }); |
| 768 Expect.throws(() { array[10]; }, | 768 Expect.throws(() { array[10]; }, |
| 769 (e) { return e is RangeError; }); | 769 (e) { return e is RangeError; }); |
| 770 Expect.throws(() { array[10] = 0.0; }, | 770 Expect.throws(() { array[10] = 0.0; }, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 | 814 |
| 815 static testFloat64List() { | 815 static testFloat64List() { |
| 816 Expect.throws(() { new Float64List(-1); }, | 816 Expect.throws(() { new Float64List(-1); }, |
| 817 (e) { return e is ArgumentError; }); | 817 (e) { return e is ArgumentError; }); |
| 818 var array = new Float64List(10); | 818 var array = new Float64List(10); |
| 819 testFloat64ListImpl(array); | 819 testFloat64ListImpl(array); |
| 820 } | 820 } |
| 821 | 821 |
| 822 static testInt8ListViewImpl(var array) { | 822 static testInt8ListViewImpl(var array) { |
| 823 Expect.equals(12, array.length); | 823 Expect.equals(12, array.length); |
| 824 Expect.equals(1, array.bytesPerElement()); | 824 Expect.equals(1, array.elementSizeInBytes); |
| 825 Expect.equals(12, array.lengthInBytes()); | 825 Expect.equals(12, array.lengthInBytes); |
| 826 for (int i = 0; i < array.length; ++i) { | 826 for (int i = 0; i < array.length; ++i) { |
| 827 array[i] = 0xFF; | 827 array[i] = 0xFF; |
| 828 } | 828 } |
| 829 Expect.throws(() { new Int8List.view(array.asByteArray(), -1); }, | 829 Expect.throws(() { new Int8List.view(array.buffer, -1); }, |
| 830 (e) { return e is RangeError; }); | 830 (e) { return e is RangeError; }); |
| 831 Expect.throws(() { new Int8List.view(array.asByteArray(), 0, -1); }, | 831 Expect.throws(() { new Int8List.view(array.buffer, 0, -1); }, |
| 832 (e) { return e is RangeError; }); | 832 (e) { return e is RangeError; }); |
| 833 Expect.throws(() { new Int8List.view(array.asByteArray(), | 833 Expect.throws(() { new Int8List.view(array.buffer, |
| 834 array.lengthInBytes() + 1); }, | 834 array.lengthInBytes + 1); }, |
| 835 (e) { return e is RangeError; }); | 835 (e) { return e is RangeError; }); |
| 836 Expect.throws(() { new Int8List.view(array.asByteArray(), | 836 Expect.throws(() { new Int8List.view(array.buffer, |
| 837 0, array.length + 1); }, | 837 0, array.length + 1); }, |
| 838 (e) { return e is RangeError; }); | 838 (e) { return e is RangeError; }); |
| 839 Expect.throws(() { new Int8List.view(array.asByteArray(), | 839 Expect.throws(() { new Int8List.view(array.buffer, |
| 840 array.length - 1, 2); }, | 840 array.length - 1, 2); }, |
| 841 (e) { return e is RangeError; }); | 841 (e) { return e is RangeError; }); |
| 842 var empty = new Int8List.view(array.asByteArray(), | 842 var empty = new Int8List.view(array.buffer, |
| 843 array.lengthInBytes()); | 843 array.lengthInBytes); |
| 844 Expect.isTrue(empty is List<int>); | 844 Expect.isTrue(empty is List<int>); |
| 845 Expect.isTrue(empty is Int8List); | 845 Expect.isTrue(empty is Int8List); |
| 846 Expect.equals(0, empty.length); | 846 Expect.equals(0, empty.length); |
| 847 var whole = new Int8List.view(array.asByteArray()); | 847 var whole = new Int8List.view(array.buffer); |
| 848 Expect.isTrue(whole is List<int>); | 848 Expect.isTrue(whole is List<int>); |
| 849 Expect.isTrue(whole is Int8List); | 849 Expect.isTrue(whole is Int8List); |
| 850 Expect.equals(12, whole.length); | 850 Expect.equals(12, whole.length); |
| 851 var view = new Int8List.view(array.asByteArray(), 1, array.length - 2); | 851 var view = new Int8List.view(array.buffer, 1, array.length - 2); |
| 852 Expect.isTrue(view is List<int>); | 852 Expect.isTrue(view is List<int>); |
| 853 Expect.isTrue(view is Int8List); | 853 Expect.isTrue(view is Int8List); |
| 854 Expect.equals(10, view.length); | 854 Expect.equals(10, view.length); |
| 855 Expect.equals(1, view.bytesPerElement()); | 855 Expect.equals(1, view.elementSizeInBytes); |
| 856 Expect.equals(10, view.lengthInBytes()); | 856 Expect.equals(10, view.lengthInBytes); |
| 857 Expect.listEquals([-1, -1, -1, -1, -1, | 857 Expect.listEquals([-1, -1, -1, -1, -1, |
| 858 -1, -1, -1, -1, -1], | 858 -1, -1, -1, -1, -1], |
| 859 view); | 859 view); |
| 860 Expect.throws(() { view[-1] = 0; }, | 860 Expect.throws(() { view[-1] = 0; }, |
| 861 (e) { return e is RangeError; }); | 861 (e) { return e is RangeError; }); |
| 862 Expect.throws(() { return view[-1]; }, | 862 Expect.throws(() { return view[-1]; }, |
| 863 (e) { return e is RangeError; }); | 863 (e) { return e is RangeError; }); |
| 864 Expect.throws(() { view[view.length]; }, | 864 Expect.throws(() { view[view.length]; }, |
| 865 (e) { return e is RangeError; }); | 865 (e) { return e is RangeError; }); |
| 866 Expect.throws(() { view[10] = 0; }, | 866 Expect.throws(() { view[10] = 0; }, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 array); | 945 array); |
| 946 } | 946 } |
| 947 static testInt8ListView() { | 947 static testInt8ListView() { |
| 948 var array = new Uint8List(12); | 948 var array = new Uint8List(12); |
| 949 testInt8ListViewImpl(array); | 949 testInt8ListViewImpl(array); |
| 950 } | 950 } |
| 951 | 951 |
| 952 static testUint8ListViewImpl(var array) { | 952 static testUint8ListViewImpl(var array) { |
| 953 Expect.isTrue(array is List<int>); | 953 Expect.isTrue(array is List<int>); |
| 954 Expect.equals(12, array.length); | 954 Expect.equals(12, array.length); |
| 955 Expect.equals(1, array.bytesPerElement()); | 955 Expect.equals(1, array.elementSizeInBytes); |
| 956 Expect.equals(12, array.lengthInBytes()); | 956 Expect.equals(12, array.lengthInBytes); |
| 957 for (int i = 0; i < array.length; ++i) { | 957 for (int i = 0; i < array.length; ++i) { |
| 958 array[i] = -1; | 958 array[i] = -1; |
| 959 } | 959 } |
| 960 Expect.throws(() { new Uint8List.view(array.asByteArray(), -1); }, | 960 Expect.throws(() { new Uint8List.view(array.buffer, -1); }, |
| 961 (e) { return e is RangeError; }); | 961 (e) { return e is RangeError; }); |
| 962 Expect.throws(() { new Uint8List.view(array.asByteArray(), 0, -1); }, | 962 Expect.throws(() { new Uint8List.view(array.buffer, 0, -1); }, |
| 963 (e) { return e is RangeError; }); | 963 (e) { return e is RangeError; }); |
| 964 Expect.throws(() { new Uint8List.view(array.asByteArray(), | 964 Expect.throws(() { new Uint8List.view(array.buffer, |
| 965 array.lengthInBytes() + 1); }, | 965 array.lengthInBytes + 1); }, |
| 966 (e) { return e is RangeError; }); | 966 (e) { return e is RangeError; }); |
| 967 Expect.throws(() { new Uint8List.view(array.asByteArray(), | 967 Expect.throws(() { new Uint8List.view(array.buffer, |
| 968 0, array.length + 1); }, | 968 0, array.length + 1); }, |
| 969 (e) { return e is RangeError; }); | 969 (e) { return e is RangeError; }); |
| 970 Expect.throws(() { new Uint8List.view(array.asByteArray(), | 970 Expect.throws(() { new Uint8List.view(array.buffer, |
| 971 array.length - 1, 2); }, | 971 array.length - 1, 2); }, |
| 972 (e) { return e is RangeError; }); | 972 (e) { return e is RangeError; }); |
| 973 var empty = new Uint8List.view(array.asByteArray(), | 973 var empty = new Uint8List.view(array.buffer, |
| 974 array.lengthInBytes()); | 974 array.lengthInBytes); |
| 975 Expect.isTrue(empty is List<int>); | 975 Expect.isTrue(empty is List<int>); |
| 976 Expect.isTrue(empty is Uint8List); | 976 Expect.isTrue(empty is Uint8List); |
| 977 Expect.equals(0, empty.length); | 977 Expect.equals(0, empty.length); |
| 978 var whole = new Uint8List.view(array.asByteArray()); | 978 var whole = new Uint8List.view(array.buffer); |
| 979 Expect.isTrue(whole is List<int>); | 979 Expect.isTrue(whole is List<int>); |
| 980 Expect.isTrue(whole is Uint8List); | 980 Expect.isTrue(whole is Uint8List); |
| 981 Expect.equals(12, whole.length); | 981 Expect.equals(12, whole.length); |
| 982 var view = new Uint8List.view(array.asByteArray(), 1, array.length - 2); | 982 var view = new Uint8List.view(array.buffer, 1, array.length - 2); |
| 983 Expect.isTrue(view is List<int>); | 983 Expect.isTrue(view is List<int>); |
| 984 Expect.isTrue(view is Uint8List); | 984 Expect.isTrue(view is Uint8List); |
| 985 Expect.equals(10, view.length); | 985 Expect.equals(10, view.length); |
| 986 Expect.equals(1, view.bytesPerElement()); | 986 Expect.equals(1, view.elementSizeInBytes); |
| 987 Expect.equals(10, view.lengthInBytes()); | 987 Expect.equals(10, view.lengthInBytes); |
| 988 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 988 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 989 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 989 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
| 990 view); | 990 view); |
| 991 Expect.throws(() { view[-1] = 0; }, | 991 Expect.throws(() { view[-1] = 0; }, |
| 992 (e) { return e is RangeError; }); | 992 (e) { return e is RangeError; }); |
| 993 Expect.throws(() { return view[-1]; }, | 993 Expect.throws(() { return view[-1]; }, |
| 994 (e) { return e is RangeError; }); | 994 (e) { return e is RangeError; }); |
| 995 Expect.throws(() { view[view.length]; }, | 995 Expect.throws(() { view[view.length]; }, |
| 996 (e) { return e is RangeError; }); | 996 (e) { return e is RangeError; }); |
| 997 Expect.throws(() { view[view.length] = 0; }, | 997 Expect.throws(() { view[view.length] = 0; }, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 view); | 1056 view); |
| 1057 } | 1057 } |
| 1058 | 1058 |
| 1059 static testUint8ListView() { | 1059 static testUint8ListView() { |
| 1060 var array = new Int8List(12); | 1060 var array = new Int8List(12); |
| 1061 testUint8ListViewImpl(array); | 1061 testUint8ListViewImpl(array); |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 static testInt16ListViewImpl(var array) { | 1064 static testInt16ListViewImpl(var array) { |
| 1065 Expect.equals(24, array.length); | 1065 Expect.equals(24, array.length); |
| 1066 Expect.equals(1, array.bytesPerElement()); | 1066 Expect.equals(1, array.elementSizeInBytes); |
| 1067 Expect.equals(24, array.lengthInBytes()); | 1067 Expect.equals(24, array.lengthInBytes); |
| 1068 for (int i = 0; i < array.length; ++i) { | 1068 for (int i = 0; i < array.length; ++i) { |
| 1069 array[i] = 0xFF; | 1069 array[i] = 0xFF; |
| 1070 } | 1070 } |
| 1071 Expect.throws(() { new Int16List.view(array.asByteArray(), -1); }, | 1071 Expect.throws(() { new Int16List.view(array.buffer, -1); }, |
| 1072 (e) { return e is RangeError; }); | 1072 (e) { return e is RangeError; }); |
| 1073 Expect.throws(() { new Int16List.view(array.asByteArray(), 0, -1); }, | 1073 Expect.throws(() { new Int16List.view(array.buffer, 0, -1); }, |
| 1074 (e) { return e is RangeError; }); | 1074 (e) { return e is RangeError; }); |
| 1075 Expect.throws(() { new Int16List.view(array.asByteArray(), | 1075 Expect.throws(() { new Int16List.view(array.buffer, |
| 1076 array.lengthInBytes() + 1); }, | 1076 array.lengthInBytes + 1); }, |
| 1077 (e) { return e is RangeError; }); | 1077 (e) { return e is RangeError; }); |
| 1078 Expect.throws(() { new Int16List.view(array.asByteArray(), | 1078 Expect.throws(() { new Int16List.view(array.buffer, |
| 1079 0, array.length + 1); }, | 1079 0, array.length + 1); }, |
| 1080 (e) { return e is RangeError; }); | 1080 (e) { return e is RangeError; }); |
| 1081 Expect.throws(() { new Int16List.view(array.asByteArray(), | 1081 Expect.throws(() { new Int16List.view(array.buffer, |
| 1082 array.length - 1, 2); }, | 1082 array.length - 1, 2); }, |
| 1083 (e) { return e is RangeError; }); | 1083 (e) { return e is RangeError; }); |
| 1084 var empty = new Int16List.view(array.asByteArray(), | 1084 var empty = new Int16List.view(array.buffer, |
| 1085 array.lengthInBytes()); | 1085 array.lengthInBytes); |
| 1086 Expect.isTrue(empty is List<int>); | 1086 Expect.isTrue(empty is List<int>); |
| 1087 Expect.isTrue(empty is Int16List); | 1087 Expect.isTrue(empty is Int16List); |
| 1088 Expect.equals(0, empty.length); | 1088 Expect.equals(0, empty.length); |
| 1089 var whole = new Int16List.view(array.asByteArray()); | 1089 var whole = new Int16List.view(array.buffer); |
| 1090 Expect.isTrue(whole is List<int>); | 1090 Expect.isTrue(whole is List<int>); |
| 1091 Expect.isTrue(whole is Int16List); | 1091 Expect.isTrue(whole is Int16List); |
| 1092 Expect.equals(12, whole.length); | 1092 Expect.equals(12, whole.length); |
| 1093 var view = new Int16List.view(array.asByteArray(), 2, 10); | 1093 var view = new Int16List.view(array.buffer, 2, 10); |
| 1094 Expect.isTrue(view is List<int>); | 1094 Expect.isTrue(view is List<int>); |
| 1095 Expect.isTrue(view is Int16List); | 1095 Expect.isTrue(view is Int16List); |
| 1096 Expect.equals(10, view.length); | 1096 Expect.equals(10, view.length); |
| 1097 Expect.equals(2, view.bytesPerElement()); | 1097 Expect.equals(2, view.elementSizeInBytes); |
| 1098 Expect.equals(20, view.lengthInBytes()); | 1098 Expect.equals(20, view.lengthInBytes); |
| 1099 Expect.listEquals([-1, -1, -1, -1, -1, | 1099 Expect.listEquals([-1, -1, -1, -1, -1, |
| 1100 -1, -1, -1, -1, -1], | 1100 -1, -1, -1, -1, -1], |
| 1101 view); | 1101 view); |
| 1102 Expect.throws(() { view[-1] = 0; }, | 1102 Expect.throws(() { view[-1] = 0; }, |
| 1103 (e) { return e is RangeError; }); | 1103 (e) { return e is RangeError; }); |
| 1104 Expect.throws(() { return view[-1]; }, | 1104 Expect.throws(() { return view[-1]; }, |
| 1105 (e) { return e is RangeError; }); | 1105 (e) { return e is RangeError; }); |
| 1106 Expect.throws(() { view[view.length]; }, | 1106 Expect.throws(() { view[view.length]; }, |
| 1107 (e) { return e is RangeError; }); | 1107 (e) { return e is RangeError; }); |
| 1108 Expect.throws(() { view[10] = 0; }, | 1108 Expect.throws(() { view[10] = 0; }, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 } | 1195 } |
| 1196 | 1196 |
| 1197 static testInt16ListView() { | 1197 static testInt16ListView() { |
| 1198 var array = new Uint8List(24); | 1198 var array = new Uint8List(24); |
| 1199 testInt16ListViewImpl(array); | 1199 testInt16ListViewImpl(array); |
| 1200 } | 1200 } |
| 1201 | 1201 |
| 1202 static testUint16ListViewImpl(var array) { | 1202 static testUint16ListViewImpl(var array) { |
| 1203 Expect.isTrue(array is List<int>); | 1203 Expect.isTrue(array is List<int>); |
| 1204 Expect.equals(24, array.length); | 1204 Expect.equals(24, array.length); |
| 1205 Expect.equals(1, array.bytesPerElement()); | 1205 Expect.equals(1, array.elementSizeInBytes); |
| 1206 Expect.equals(24, array.lengthInBytes()); | 1206 Expect.equals(24, array.lengthInBytes); |
| 1207 for (int i = 0; i < array.length; ++i) { | 1207 for (int i = 0; i < array.length; ++i) { |
| 1208 array[i] = -1; | 1208 array[i] = -1; |
| 1209 } | 1209 } |
| 1210 Expect.throws(() { new Uint16List.view(array.asByteArray(), -1); }, | 1210 Expect.throws(() { new Uint16List.view(array.buffer, -1); }, |
| 1211 (e) { return e is RangeError; }); | 1211 (e) { return e is RangeError; }); |
| 1212 Expect.throws(() { new Uint16List.view(array.asByteArray(), 0, -1); }, | 1212 Expect.throws(() { new Uint16List.view(array.buffer, 0, -1); }, |
| 1213 (e) { return e is RangeError; }); | 1213 (e) { return e is RangeError; }); |
| 1214 Expect.throws(() { new Uint16List.view(array.asByteArray(), | 1214 Expect.throws(() { new Uint16List.view(array.buffer, |
| 1215 array.lengthInBytes() + 1); }, | 1215 array.lengthInBytes + 1); }, |
| 1216 (e) { return e is RangeError; }); | 1216 (e) { return e is RangeError; }); |
| 1217 Expect.throws(() { new Uint16List.view(array.asByteArray(), | 1217 Expect.throws(() { new Uint16List.view(array.buffer, |
| 1218 0, array.length + 1); }, | 1218 0, array.length + 1); }, |
| 1219 (e) { return e is RangeError; }); | 1219 (e) { return e is RangeError; }); |
| 1220 Expect.throws(() { new Uint16List.view(array.asByteArray(), | 1220 Expect.throws(() { new Uint16List.view(array.buffer, |
| 1221 array.length - 1, 2); }, | 1221 array.length - 1, 2); }, |
| 1222 (e) { return e is RangeError; }); | 1222 (e) { return e is RangeError; }); |
| 1223 var empty = new Uint16List.view(array.asByteArray(), | 1223 var empty = new Uint16List.view(array.buffer, |
| 1224 array.lengthInBytes()); | 1224 array.lengthInBytes); |
| 1225 Expect.isTrue(empty is List<int>); | 1225 Expect.isTrue(empty is List<int>); |
| 1226 Expect.isTrue(empty is Uint16List); | 1226 Expect.isTrue(empty is Uint16List); |
| 1227 Expect.equals(0, empty.length); | 1227 Expect.equals(0, empty.length); |
| 1228 var whole = new Uint16List.view(array.asByteArray()); | 1228 var whole = new Uint16List.view(array.buffer); |
| 1229 Expect.isTrue(whole is List<int>); | 1229 Expect.isTrue(whole is List<int>); |
| 1230 Expect.isTrue(whole is Uint16List); | 1230 Expect.isTrue(whole is Uint16List); |
| 1231 Expect.equals(12, whole.length); | 1231 Expect.equals(12, whole.length); |
| 1232 var view = new Uint16List.view(array.asByteArray(), 2, 10); | 1232 var view = new Uint16List.view(array.buffer, 2, 10); |
| 1233 Expect.isTrue(view is List<int>); | 1233 Expect.isTrue(view is List<int>); |
| 1234 Expect.isTrue(view is Uint16List); | 1234 Expect.isTrue(view is Uint16List); |
| 1235 Expect.equals(10, view.length); | 1235 Expect.equals(10, view.length); |
| 1236 Expect.equals(2, view.bytesPerElement()); | 1236 Expect.equals(2, view.elementSizeInBytes); |
| 1237 Expect.equals(20, view.lengthInBytes()); | 1237 Expect.equals(20, view.lengthInBytes); |
| 1238 Expect.listEquals([0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, | 1238 Expect.listEquals([0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 1239 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF], | 1239 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF], |
| 1240 view); | 1240 view); |
| 1241 Expect.throws(() { view[-1] = 0; }, | 1241 Expect.throws(() { view[-1] = 0; }, |
| 1242 (e) { return e is RangeError; }); | 1242 (e) { return e is RangeError; }); |
| 1243 Expect.throws(() { return view[-1]; }, | 1243 Expect.throws(() { return view[-1]; }, |
| 1244 (e) { return e is RangeError; }); | 1244 (e) { return e is RangeError; }); |
| 1245 Expect.throws(() { view[view.length]; }, | 1245 Expect.throws(() { view[view.length]; }, |
| 1246 (e) { return e is RangeError; }); | 1246 (e) { return e is RangeError; }); |
| 1247 Expect.throws(() { view[view.length] = 0; }, | 1247 Expect.throws(() { view[view.length] = 0; }, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 } | 1312 } |
| 1313 | 1313 |
| 1314 static testUint16ListView() { | 1314 static testUint16ListView() { |
| 1315 var array = new Int8List(24); | 1315 var array = new Int8List(24); |
| 1316 testUint16ListViewImpl(array); | 1316 testUint16ListViewImpl(array); |
| 1317 } | 1317 } |
| 1318 | 1318 |
| 1319 static testInt32ListView() { | 1319 static testInt32ListView() { |
| 1320 var array = new Uint8List(48); | 1320 var array = new Uint8List(48); |
| 1321 Expect.equals(48, array.length); | 1321 Expect.equals(48, array.length); |
| 1322 Expect.equals(1, array.bytesPerElement()); | 1322 Expect.equals(1, array.elementSizeInBytes); |
| 1323 Expect.equals(48, array.lengthInBytes()); | 1323 Expect.equals(48, array.lengthInBytes); |
| 1324 for (int i = 0; i < array.length; ++i) { | 1324 for (int i = 0; i < array.length; ++i) { |
| 1325 array[i] = 0xFF; | 1325 array[i] = 0xFF; |
| 1326 } | 1326 } |
| 1327 Expect.throws(() { new Int32List.view(array.asByteArray(), -1); }, | 1327 Expect.throws(() { new Int32List.view(array.buffer, -1); }, |
| 1328 (e) { return e is RangeError; }); | 1328 (e) { return e is RangeError; }); |
| 1329 Expect.throws(() { new Int32List.view(array.asByteArray(), 0, -1); }, | 1329 Expect.throws(() { new Int32List.view(array.buffer, 0, -1); }, |
| 1330 (e) { return e is RangeError; }); | 1330 (e) { return e is RangeError; }); |
| 1331 Expect.throws(() { new Int32List.view(array.asByteArray(), | 1331 Expect.throws(() { new Int32List.view(array.buffer, |
| 1332 array.lengthInBytes() + 1); }, | 1332 array.lengthInBytes + 1); }, |
| 1333 (e) { return e is RangeError; }); | 1333 (e) { return e is RangeError; }); |
| 1334 Expect.throws(() { new Int32List.view(array.asByteArray(), | 1334 Expect.throws(() { new Int32List.view(array.buffer, |
| 1335 0, array.length + 1); }, | 1335 0, array.length + 1); }, |
| 1336 (e) { return e is RangeError; }); | 1336 (e) { return e is RangeError; }); |
| 1337 Expect.throws(() { new Int32List.view(array.asByteArray(), | 1337 Expect.throws(() { new Int32List.view(array.buffer, |
| 1338 array.length - 1, 2); }, | 1338 array.length - 1, 2); }, |
| 1339 (e) { return e is RangeError; }); | 1339 (e) { return e is RangeError; }); |
| 1340 var empty = new Int32List.view(array.asByteArray(), | 1340 var empty = new Int32List.view(array.buffer, |
| 1341 array.lengthInBytes()); | 1341 array.lengthInBytes); |
| 1342 Expect.isTrue(empty is List<int>); | 1342 Expect.isTrue(empty is List<int>); |
| 1343 Expect.isTrue(empty is Int32List); | 1343 Expect.isTrue(empty is Int32List); |
| 1344 Expect.equals(0, empty.length); | 1344 Expect.equals(0, empty.length); |
| 1345 var whole = new Int32List.view(array.asByteArray()); | 1345 var whole = new Int32List.view(array.buffer); |
| 1346 Expect.isTrue(whole is List<int>); | 1346 Expect.isTrue(whole is List<int>); |
| 1347 Expect.isTrue(whole is Int32List); | 1347 Expect.isTrue(whole is Int32List); |
| 1348 Expect.equals(12, whole.length); | 1348 Expect.equals(12, whole.length); |
| 1349 var view = new Int32List.view(array.asByteArray(), 4, 10); | 1349 var view = new Int32List.view(array.buffer, 4, 10); |
| 1350 Expect.isTrue(view is List<int>); | 1350 Expect.isTrue(view is List<int>); |
| 1351 Expect.isTrue(view is Int32List); | 1351 Expect.isTrue(view is Int32List); |
| 1352 Expect.equals(10, view.length); | 1352 Expect.equals(10, view.length); |
| 1353 Expect.equals(4, view.bytesPerElement()); | 1353 Expect.equals(4, view.elementSizeInBytes); |
| 1354 Expect.equals(40, view.lengthInBytes()); | 1354 Expect.equals(40, view.lengthInBytes); |
| 1355 Expect.listEquals([-1, -1, -1, -1, -1, | 1355 Expect.listEquals([-1, -1, -1, -1, -1, |
| 1356 -1, -1, -1, -1, -1], | 1356 -1, -1, -1, -1, -1], |
| 1357 view); | 1357 view); |
| 1358 Expect.throws(() { view[-1] = 0; }, | 1358 Expect.throws(() { view[-1] = 0; }, |
| 1359 (e) { return e is RangeError; }); | 1359 (e) { return e is RangeError; }); |
| 1360 Expect.throws(() { return view[-1]; }, | 1360 Expect.throws(() { return view[-1]; }, |
| 1361 (e) { return e is RangeError; }); | 1361 (e) { return e is RangeError; }); |
| 1362 Expect.throws(() { view[view.length]; }, | 1362 Expect.throws(() { view[view.length]; }, |
| 1363 (e) { return e is RangeError; }); | 1363 (e) { return e is RangeError; }); |
| 1364 Expect.throws(() { view[10] = 0; }, | 1364 Expect.throws(() { view[10] = 0; }, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, | 1470 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, |
| 1471 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, | 1471 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, |
| 1472 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, | 1472 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, |
| 1473 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], | 1473 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], |
| 1474 array); | 1474 array); |
| 1475 } | 1475 } |
| 1476 | 1476 |
| 1477 static testUint32ListViewImpl(var array) { | 1477 static testUint32ListViewImpl(var array) { |
| 1478 Expect.isTrue(array is List<int>); | 1478 Expect.isTrue(array is List<int>); |
| 1479 Expect.equals(48, array.length); | 1479 Expect.equals(48, array.length); |
| 1480 Expect.equals(1, array.bytesPerElement()); | 1480 Expect.equals(1, array.elementSizeInBytes); |
| 1481 Expect.equals(48, array.lengthInBytes()); | 1481 Expect.equals(48, array.lengthInBytes); |
| 1482 for (int i = 0; i < array.length; ++i) { | 1482 for (int i = 0; i < array.length; ++i) { |
| 1483 array[i] = -1; | 1483 array[i] = -1; |
| 1484 } | 1484 } |
| 1485 Expect.throws(() { new Uint32List.view(array.asByteArray(), -1); }, | 1485 Expect.throws(() { new Uint32List.view(array.buffer, -1); }, |
| 1486 (e) { return e is RangeError; }); | 1486 (e) { return e is RangeError; }); |
| 1487 Expect.throws(() { new Uint32List.view(array.asByteArray(), 0, -1); }, | 1487 Expect.throws(() { new Uint32List.view(array.buffer, 0, -1); }, |
| 1488 (e) { return e is RangeError; }); | 1488 (e) { return e is RangeError; }); |
| 1489 Expect.throws(() { new Uint32List.view(array.asByteArray(), | 1489 Expect.throws(() { new Uint32List.view(array.buffer, |
| 1490 array.lengthInBytes() + 1); }, | 1490 array.lengthInBytes + 1); }, |
| 1491 (e) { return e is RangeError; }); | 1491 (e) { return e is RangeError; }); |
| 1492 Expect.throws(() { new Uint32List.view(array.asByteArray(), | 1492 Expect.throws(() { new Uint32List.view(array.buffer, |
| 1493 0, array.length + 1); }, | 1493 0, array.length + 1); }, |
| 1494 (e) { return e is RangeError; }); | 1494 (e) { return e is RangeError; }); |
| 1495 Expect.throws(() { new Uint32List.view(array.asByteArray(), | 1495 Expect.throws(() { new Uint32List.view(array.buffer, |
| 1496 array.length - 1, 2); }, | 1496 array.length - 1, 2); }, |
| 1497 (e) { return e is RangeError; }); | 1497 (e) { return e is RangeError; }); |
| 1498 var empty = new Uint32List.view(array.asByteArray(), | 1498 var empty = new Uint32List.view(array.buffer, |
| 1499 array.lengthInBytes()); | 1499 array.lengthInBytes); |
| 1500 Expect.isTrue(empty is List<int>); | 1500 Expect.isTrue(empty is List<int>); |
| 1501 Expect.isTrue(empty is Uint32List); | 1501 Expect.isTrue(empty is Uint32List); |
| 1502 Expect.equals(0, empty.length); | 1502 Expect.equals(0, empty.length); |
| 1503 var whole = new Uint32List.view(array.asByteArray()); | 1503 var whole = new Uint32List.view(array.buffer); |
| 1504 Expect.isTrue(whole is List<int>); | 1504 Expect.isTrue(whole is List<int>); |
| 1505 Expect.isTrue(whole is Uint32List); | 1505 Expect.isTrue(whole is Uint32List); |
| 1506 Expect.equals(12, whole.length); | 1506 Expect.equals(12, whole.length); |
| 1507 var view = new Uint32List.view(array.asByteArray(), 4, 10); | 1507 var view = new Uint32List.view(array.buffer, 4, 10); |
| 1508 Expect.isTrue(view is List<int>); | 1508 Expect.isTrue(view is List<int>); |
| 1509 Expect.isTrue(view is Uint32List); | 1509 Expect.isTrue(view is Uint32List); |
| 1510 Expect.equals(10, view.length); | 1510 Expect.equals(10, view.length); |
| 1511 Expect.equals(4, view.bytesPerElement()); | 1511 Expect.equals(4, view.elementSizeInBytes); |
| 1512 Expect.equals(40, view.lengthInBytes()); | 1512 Expect.equals(40, view.lengthInBytes); |
| 1513 Expect.listEquals([0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF
F, | 1513 Expect.listEquals([0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF
F, |
| 1514 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF
F], | 1514 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF
F], |
| 1515 view); | 1515 view); |
| 1516 Expect.throws(() { view[-1] = 0; }, | 1516 Expect.throws(() { view[-1] = 0; }, |
| 1517 (e) { return e is RangeError; }); | 1517 (e) { return e is RangeError; }); |
| 1518 Expect.throws(() { return view[-1]; }, | 1518 Expect.throws(() { return view[-1]; }, |
| 1519 (e) { return e is RangeError; }); | 1519 (e) { return e is RangeError; }); |
| 1520 Expect.throws(() { view[view.length]; }, | 1520 Expect.throws(() { view[view.length]; }, |
| 1521 (e) { return e is RangeError; }); | 1521 (e) { return e is RangeError; }); |
| 1522 Expect.throws(() { view[view.length] = 0; }, | 1522 Expect.throws(() { view[view.length] = 0; }, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 array); | 1603 array); |
| 1604 } | 1604 } |
| 1605 | 1605 |
| 1606 static testUint32ListView() { | 1606 static testUint32ListView() { |
| 1607 var array = new Int8List(48); | 1607 var array = new Int8List(48); |
| 1608 testUint32ListViewImpl(array); | 1608 testUint32ListViewImpl(array); |
| 1609 } | 1609 } |
| 1610 | 1610 |
| 1611 static testInt64ListViewImpl(var array) { | 1611 static testInt64ListViewImpl(var array) { |
| 1612 Expect.equals(96, array.length); | 1612 Expect.equals(96, array.length); |
| 1613 Expect.equals(1, array.bytesPerElement()); | 1613 Expect.equals(1, array.elementSizeInBytes); |
| 1614 Expect.equals(96, array.lengthInBytes()); | 1614 Expect.equals(96, array.lengthInBytes); |
| 1615 for (int i = 0; i < array.length; ++i) { | 1615 for (int i = 0; i < array.length; ++i) { |
| 1616 array[i] = 0xFF; | 1616 array[i] = 0xFF; |
| 1617 } | 1617 } |
| 1618 Expect.throws(() { new Int64List.view(array.asByteArray(), -1); }, | 1618 Expect.throws(() { new Int64List.view(array.buffer, -1); }, |
| 1619 (e) { return e is RangeError; }); | 1619 (e) { return e is RangeError; }); |
| 1620 Expect.throws(() { new Int64List.view(array.asByteArray(), 0, -1); }, | 1620 Expect.throws(() { new Int64List.view(array.buffer, 0, -1); }, |
| 1621 (e) { return e is RangeError; }); | 1621 (e) { return e is RangeError; }); |
| 1622 Expect.throws(() { new Int64List.view(array.asByteArray(), | 1622 Expect.throws(() { new Int64List.view(array.buffer, |
| 1623 array.lengthInBytes() + 1); }, | 1623 array.lengthInBytes + 1); }, |
| 1624 (e) { return e is RangeError; }); | 1624 (e) { return e is RangeError; }); |
| 1625 Expect.throws(() { new Int64List.view(array.asByteArray(), | 1625 Expect.throws(() { new Int64List.view(array.buffer, |
| 1626 0, array.length + 1); }, | 1626 0, array.length + 1); }, |
| 1627 (e) { return e is RangeError; }); | 1627 (e) { return e is RangeError; }); |
| 1628 Expect.throws(() { new Int64List.view(array.asByteArray(), | 1628 Expect.throws(() { new Int64List.view(array.buffer, |
| 1629 array.length - 1, 2); }, | 1629 array.length - 1, 2); }, |
| 1630 (e) { return e is RangeError; }); | 1630 (e) { return e is RangeError; }); |
| 1631 var empty = new Int64List.view(array.asByteArray(), | 1631 var empty = new Int64List.view(array.buffer, |
| 1632 array.lengthInBytes()); | 1632 array.lengthInBytes); |
| 1633 Expect.isTrue(empty is List<int>); | 1633 Expect.isTrue(empty is List<int>); |
| 1634 Expect.isTrue(empty is Int64List); | 1634 Expect.isTrue(empty is Int64List); |
| 1635 Expect.equals(0, empty.length); | 1635 Expect.equals(0, empty.length); |
| 1636 var whole = new Int64List.view(array.asByteArray()); | 1636 var whole = new Int64List.view(array.buffer); |
| 1637 Expect.isTrue(whole is List<int>); | 1637 Expect.isTrue(whole is List<int>); |
| 1638 Expect.isTrue(whole is Int64List); | 1638 Expect.isTrue(whole is Int64List); |
| 1639 Expect.equals(12, whole.length); | 1639 Expect.equals(12, whole.length); |
| 1640 var view = new Int64List.view(array.asByteArray(), 8, 10); | 1640 var view = new Int64List.view(array.buffer, 8, 10); |
| 1641 Expect.isTrue(view is List<int>); | 1641 Expect.isTrue(view is List<int>); |
| 1642 Expect.isTrue(view is Int64List); | 1642 Expect.isTrue(view is Int64List); |
| 1643 Expect.equals(10, view.length); | 1643 Expect.equals(10, view.length); |
| 1644 Expect.equals(8, view.bytesPerElement()); | 1644 Expect.equals(8, view.elementSizeInBytes); |
| 1645 Expect.equals(80, view.lengthInBytes()); | 1645 Expect.equals(80, view.lengthInBytes); |
| 1646 Expect.listEquals([-1, -1, -1, -1, -1, | 1646 Expect.listEquals([-1, -1, -1, -1, -1, |
| 1647 -1, -1, -1, -1, -1], | 1647 -1, -1, -1, -1, -1], |
| 1648 view); | 1648 view); |
| 1649 Expect.throws(() { view[-1] = 0; }, | 1649 Expect.throws(() { view[-1] = 0; }, |
| 1650 (e) { return e is RangeError; }); | 1650 (e) { return e is RangeError; }); |
| 1651 Expect.throws(() { return view[-1]; }, | 1651 Expect.throws(() { return view[-1]; }, |
| 1652 (e) { return e is RangeError; }); | 1652 (e) { return e is RangeError; }); |
| 1653 Expect.throws(() { view[view.length]; }, | 1653 Expect.throws(() { view[view.length]; }, |
| 1654 (e) { return e is RangeError; }); | 1654 (e) { return e is RangeError; }); |
| 1655 Expect.throws(() { view[10] = 0; }, | 1655 Expect.throws(() { view[10] = 0; }, |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1803 } | 1803 } |
| 1804 | 1804 |
| 1805 static testInt64ListView() { | 1805 static testInt64ListView() { |
| 1806 var array = new Uint8List(96); | 1806 var array = new Uint8List(96); |
| 1807 testInt64ListViewImpl(array); | 1807 testInt64ListViewImpl(array); |
| 1808 } | 1808 } |
| 1809 | 1809 |
| 1810 static testUint64ListViewImpl(var array) { | 1810 static testUint64ListViewImpl(var array) { |
| 1811 Expect.isTrue(array is List<int>); | 1811 Expect.isTrue(array is List<int>); |
| 1812 Expect.equals(96, array.length); | 1812 Expect.equals(96, array.length); |
| 1813 Expect.equals(1, array.bytesPerElement()); | 1813 Expect.equals(1, array.elementSizeInBytes); |
| 1814 Expect.equals(96, array.lengthInBytes()); | 1814 Expect.equals(96, array.lengthInBytes); |
| 1815 for (int i = 0; i < array.length; ++i) { | 1815 for (int i = 0; i < array.length; ++i) { |
| 1816 array[i] = -1; | 1816 array[i] = -1; |
| 1817 } | 1817 } |
| 1818 Expect.throws(() { new Uint64List.view(array.asByteArray(), -1); }, | 1818 Expect.throws(() { new Uint64List.view(array.buffer, -1); }, |
| 1819 (e) { return e is RangeError; }); | 1819 (e) { return e is RangeError; }); |
| 1820 Expect.throws(() { new Uint64List.view(array.asByteArray(), 0, -1); }, | 1820 Expect.throws(() { new Uint64List.view(array.buffer, 0, -1); }, |
| 1821 (e) { return e is RangeError; }); | 1821 (e) { return e is RangeError; }); |
| 1822 Expect.throws(() { new Uint64List.view(array.asByteArray(), | 1822 Expect.throws(() { new Uint64List.view(array.buffer, |
| 1823 array.lengthInBytes() + 1); }, | 1823 array.lengthInBytes + 1); }, |
| 1824 (e) { return e is RangeError; }); | 1824 (e) { return e is RangeError; }); |
| 1825 Expect.throws(() { new Uint64List.view(array.asByteArray(), | 1825 Expect.throws(() { new Uint64List.view(array.buffer, |
| 1826 0, array.length + 1); }, | 1826 0, array.length + 1); }, |
| 1827 (e) { return e is RangeError; }); | 1827 (e) { return e is RangeError; }); |
| 1828 Expect.throws(() { new Uint64List.view(array.asByteArray(), | 1828 Expect.throws(() { new Uint64List.view(array.buffer, |
| 1829 array.length - 1, 2); }, | 1829 array.length - 1, 2); }, |
| 1830 (e) { return e is RangeError; }); | 1830 (e) { return e is RangeError; }); |
| 1831 var empty = new Uint64List.view(array.asByteArray(), | 1831 var empty = new Uint64List.view(array.buffer, |
| 1832 array.lengthInBytes()); | 1832 array.lengthInBytes); |
| 1833 Expect.isTrue(empty is List<int>); | 1833 Expect.isTrue(empty is List<int>); |
| 1834 Expect.isTrue(empty is Uint64List); | 1834 Expect.isTrue(empty is Uint64List); |
| 1835 Expect.equals(0, empty.length); | 1835 Expect.equals(0, empty.length); |
| 1836 var whole = new Uint64List.view(array.asByteArray()); | 1836 var whole = new Uint64List.view(array.buffer); |
| 1837 Expect.isTrue(whole is List<int>); | 1837 Expect.isTrue(whole is List<int>); |
| 1838 Expect.isTrue(whole is Uint64List); | 1838 Expect.isTrue(whole is Uint64List); |
| 1839 Expect.equals(12, whole.length); | 1839 Expect.equals(12, whole.length); |
| 1840 var view = new Uint64List.view(array.asByteArray(), 8, 10); | 1840 var view = new Uint64List.view(array.buffer, 8, 10); |
| 1841 Expect.isTrue(view is List<int>); | 1841 Expect.isTrue(view is List<int>); |
| 1842 Expect.isTrue(view is Uint64List); | 1842 Expect.isTrue(view is Uint64List); |
| 1843 Expect.equals(10, view.length); | 1843 Expect.equals(10, view.length); |
| 1844 Expect.equals(8, view.bytesPerElement()); | 1844 Expect.equals(8, view.elementSizeInBytes); |
| 1845 Expect.equals(80, view.lengthInBytes()); | 1845 Expect.equals(80, view.lengthInBytes); |
| 1846 Expect.listEquals([0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, | 1846 Expect.listEquals([0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, |
| 1847 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, | 1847 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, |
| 1848 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, | 1848 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, |
| 1849 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, | 1849 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, |
| 1850 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF], | 1850 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF], |
| 1851 view); | 1851 view); |
| 1852 Expect.throws(() { view[-1] = 0; }, | 1852 Expect.throws(() { view[-1] = 0; }, |
| 1853 (e) { return e is RangeError; }); | 1853 (e) { return e is RangeError; }); |
| 1854 Expect.throws(() { return view[-1]; }, | 1854 Expect.throws(() { return view[-1]; }, |
| 1855 (e) { return e is RangeError; }); | 1855 (e) { return e is RangeError; }); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1964 } | 1964 } |
| 1965 | 1965 |
| 1966 static testUint64ListView() { | 1966 static testUint64ListView() { |
| 1967 var array = new Int8List(96); | 1967 var array = new Int8List(96); |
| 1968 testUint64ListViewImpl(array); | 1968 testUint64ListViewImpl(array); |
| 1969 } | 1969 } |
| 1970 | 1970 |
| 1971 static testFloat32ListViewImpl(var array) { | 1971 static testFloat32ListViewImpl(var array) { |
| 1972 Expect.isTrue(array is List<int>); | 1972 Expect.isTrue(array is List<int>); |
| 1973 Expect.equals(12, array.length); | 1973 Expect.equals(12, array.length); |
| 1974 Expect.equals(4, array.bytesPerElement()); | 1974 Expect.equals(4, array.elementSizeInBytes); |
| 1975 Expect.equals(48, array.lengthInBytes()); | 1975 Expect.equals(48, array.lengthInBytes); |
| 1976 for (int i = 0; i < array.length; ++i) { | 1976 for (int i = 0; i < array.length; ++i) { |
| 1977 array[i] = 0xBF800000; | 1977 array[i] = 0xBF800000; |
| 1978 } | 1978 } |
| 1979 Expect.throws(() { new Float32List.view(array.asByteArray(), -1); }, | 1979 Expect.throws(() { new Float32List.view(array.buffer, -1); }, |
| 1980 (e) { return e is RangeError; }); | 1980 (e) { return e is RangeError; }); |
| 1981 Expect.throws(() { new Float32List.view(array.asByteArray(), 0, -1); }, | 1981 Expect.throws(() { new Float32List.view(array.buffer, 0, -1); }, |
| 1982 (e) { return e is RangeError; }); | 1982 (e) { return e is RangeError; }); |
| 1983 Expect.throws(() { new Float32List.view(array.asByteArray(), | 1983 Expect.throws(() { new Float32List.view(array.buffer, |
| 1984 array.lengthInBytes() + 1); }, | 1984 array.lengthInBytes + 1); }, |
| 1985 (e) { return e is RangeError; }); | 1985 (e) { return e is RangeError; }); |
| 1986 Expect.throws(() { new Float32List.view(array.asByteArray(), | 1986 Expect.throws(() { new Float32List.view(array.buffer, |
| 1987 0, array.lengthInBytes() + 1); }, | 1987 0, array.lengthInBytes + 1); }, |
| 1988 (e) { return e is RangeError; }); | 1988 (e) { return e is RangeError; }); |
| 1989 Expect.throws(() { new Float32List.view(array.asByteArray(), | 1989 Expect.throws(() { new Float32List.view(array.buffer, |
| 1990 array.lengthInBytes() - 1, 2); }, | 1990 array.lengthInBytes - 1, 2); }, |
| 1991 (e) { return e is RangeError; }); | 1991 (e) { return e is RangeError; }); |
| 1992 var empty = new Float32List.view(array.asByteArray(), | 1992 var empty = new Float32List.view(array.buffer, |
| 1993 array.lengthInBytes()); | 1993 array.lengthInBytes); |
| 1994 Expect.isTrue(empty is List<double>); | 1994 Expect.isTrue(empty is List<double>); |
| 1995 Expect.isTrue(empty is Float32List); | 1995 Expect.isTrue(empty is Float32List); |
| 1996 Expect.equals(0, empty.length); | 1996 Expect.equals(0, empty.length); |
| 1997 var whole = new Float32List.view(array.asByteArray()); | 1997 var whole = new Float32List.view(array.buffer); |
| 1998 Expect.isTrue(whole is List<double>); | 1998 Expect.isTrue(whole is List<double>); |
| 1999 Expect.isTrue(whole is Float32List); | 1999 Expect.isTrue(whole is Float32List); |
| 2000 Expect.equals(12, whole.length); | 2000 Expect.equals(12, whole.length); |
| 2001 var view = new Float32List.view(array.asByteArray(), 4, 10); | 2001 var view = new Float32List.view(array.buffer, 4, 10); |
| 2002 Expect.isTrue(view is List<double>); | 2002 Expect.isTrue(view is List<double>); |
| 2003 Expect.isTrue(view is Float32List); | 2003 Expect.isTrue(view is Float32List); |
| 2004 Expect.equals(10, view.length); | 2004 Expect.equals(10, view.length); |
| 2005 Expect.equals(4, view.bytesPerElement()); | 2005 Expect.equals(4, view.elementSizeInBytes); |
| 2006 Expect.equals(40, view.lengthInBytes()); | 2006 Expect.equals(40, view.lengthInBytes); |
| 2007 Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0, | 2007 Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0, |
| 2008 -1.0, -1.0, -1.0, -1.0, -1.0], | 2008 -1.0, -1.0, -1.0, -1.0, -1.0], |
| 2009 view); | 2009 view); |
| 2010 Expect.throws(() { view[-1] = 0.0; }, | 2010 Expect.throws(() { view[-1] = 0.0; }, |
| 2011 (e) { return e is RangeError; }); | 2011 (e) { return e is RangeError; }); |
| 2012 Expect.throws(() { return view[-1]; }, | 2012 Expect.throws(() { return view[-1]; }, |
| 2013 (e) { return e is RangeError; }); | 2013 (e) { return e is RangeError; }); |
| 2014 Expect.throws(() { view[10]; }, | 2014 Expect.throws(() { view[10]; }, |
| 2015 (e) { return e is RangeError; }); | 2015 (e) { return e is RangeError; }); |
| 2016 Expect.throws(() { view[10] = 0.0; }, | 2016 Expect.throws(() { view[10] = 0.0; }, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2071 } | 2071 } |
| 2072 | 2072 |
| 2073 static testFloat32ListView() { | 2073 static testFloat32ListView() { |
| 2074 var array = new Uint32List(12); | 2074 var array = new Uint32List(12); |
| 2075 testFloat32ListViewImpl(array); | 2075 testFloat32ListViewImpl(array); |
| 2076 } | 2076 } |
| 2077 | 2077 |
| 2078 static testFloat64ListViewImpl(var array) { | 2078 static testFloat64ListViewImpl(var array) { |
| 2079 Expect.isTrue(array is List<int>); | 2079 Expect.isTrue(array is List<int>); |
| 2080 Expect.equals(12, array.length); | 2080 Expect.equals(12, array.length); |
| 2081 Expect.equals(8, array.bytesPerElement()); | 2081 Expect.equals(8, array.elementSizeInBytes); |
| 2082 Expect.equals(96, array.lengthInBytes()); | 2082 Expect.equals(96, array.lengthInBytes); |
| 2083 for (int i = 0; i < array.length; ++i) { | 2083 for (int i = 0; i < array.length; ++i) { |
| 2084 array[i] = 0xBFF0000000000000; | 2084 array[i] = 0xBFF0000000000000; |
| 2085 } | 2085 } |
| 2086 Expect.throws(() { new Float64List.view(array.asByteArray(), -1); }, | 2086 Expect.throws(() { new Float64List.view(array.buffer, -1); }, |
| 2087 (e) { return e is RangeError; }); | 2087 (e) { return e is RangeError; }); |
| 2088 Expect.throws(() { new Float64List.view(array.asByteArray(), 0, -1); }, | 2088 Expect.throws(() { new Float64List.view(array.buffer, 0, -1); }, |
| 2089 (e) { return e is RangeError; }); | 2089 (e) { return e is RangeError; }); |
| 2090 Expect.throws(() { new Float64List.view(array.asByteArray(), | 2090 Expect.throws(() { new Float64List.view(array.buffer, |
| 2091 array.lengthInBytes() + 1); }, | 2091 array.lengthInBytes + 1); }, |
| 2092 (e) { return e is RangeError; }); | 2092 (e) { return e is RangeError; }); |
| 2093 Expect.throws(() { new Float64List.view(array.asByteArray(), | 2093 Expect.throws(() { new Float64List.view(array.buffer, |
| 2094 0, array.lengthInBytes() + 1); }, | 2094 0, array.lengthInBytes + 1); }, |
| 2095 (e) { return e is RangeError; }); | 2095 (e) { return e is RangeError; }); |
| 2096 Expect.throws(() { new Float64List.view(array.asByteArray(), | 2096 Expect.throws(() { new Float64List.view(array.buffer, |
| 2097 array.lengthInBytes() - 1, 2); }, | 2097 array.lengthInBytes - 1, 2); }, |
| 2098 (e) { return e is RangeError; }); | 2098 (e) { return e is RangeError; }); |
| 2099 var empty = new Float64List.view(array.asByteArray(), | 2099 var empty = new Float64List.view(array.buffer, |
| 2100 array.lengthInBytes()); | 2100 array.lengthInBytes); |
| 2101 Expect.isTrue(empty is List<double>); | 2101 Expect.isTrue(empty is List<double>); |
| 2102 Expect.isTrue(empty is Float64List); | 2102 Expect.isTrue(empty is Float64List); |
| 2103 Expect.equals(0, empty.length); | 2103 Expect.equals(0, empty.length); |
| 2104 var whole = new Float64List.view(array.asByteArray()); | 2104 var whole = new Float64List.view(array.buffer); |
| 2105 Expect.isTrue(whole is List<double>); | 2105 Expect.isTrue(whole is List<double>); |
| 2106 Expect.isTrue(whole is Float64List); | 2106 Expect.isTrue(whole is Float64List); |
| 2107 Expect.equals(12, whole.length); | 2107 Expect.equals(12, whole.length); |
| 2108 var view = new Float64List.view(array.asByteArray(), 8, 10); | 2108 var view = new Float64List.view(array.buffer, 8, 10); |
| 2109 Expect.isTrue(view is List<double>); | 2109 Expect.isTrue(view is List<double>); |
| 2110 Expect.isTrue(view is Float64List); | 2110 Expect.isTrue(view is Float64List); |
| 2111 Expect.equals(10, view.length); | 2111 Expect.equals(10, view.length); |
| 2112 Expect.equals(8, view.bytesPerElement()); | 2112 Expect.equals(8, view.elementSizeInBytes); |
| 2113 Expect.equals(80, view.lengthInBytes()); | 2113 Expect.equals(80, view.lengthInBytes); |
| 2114 Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0, | 2114 Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0, |
| 2115 -1.0, -1.0, -1.0, -1.0, -1.0], | 2115 -1.0, -1.0, -1.0, -1.0, -1.0], |
| 2116 view); | 2116 view); |
| 2117 Expect.throws(() { view[-1] = 0.0; }, | 2117 Expect.throws(() { view[-1] = 0.0; }, |
| 2118 (e) { return e is RangeError; }); | 2118 (e) { return e is RangeError; }); |
| 2119 Expect.throws(() { return view[-1]; }, | 2119 Expect.throws(() { return view[-1]; }, |
| 2120 (e) { return e is RangeError; }); | 2120 (e) { return e is RangeError; }); |
| 2121 Expect.throws(() { view[10]; }, | 2121 Expect.throws(() { view[10]; }, |
| 2122 (e) { return e is RangeError; }); | 2122 (e) { return e is RangeError; }); |
| 2123 Expect.throws(() { view[10] = 0.0; }, | 2123 Expect.throws(() { view[10] = 0.0; }, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 testFloat32ListView(); | 2205 testFloat32ListView(); |
| 2206 testFloat64ListView(); | 2206 testFloat64ListView(); |
| 2207 } | 2207 } |
| 2208 } | 2208 } |
| 2209 | 2209 |
| 2210 main() { | 2210 main() { |
| 2211 for (var i=0; i<1000; i++) { | 2211 for (var i=0; i<1000; i++) { |
| 2212 OptimizedByteArrayTest.testMain(); | 2212 OptimizedByteArrayTest.testMain(); |
| 2213 } | 2213 } |
| 2214 } | 2214 } |
| OLD | NEW |