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 "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
9 import 'dart:typeddata'; | 9 import 'dart:typeddata'; |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 Expect.isFalse(copy === array); | 78 Expect.isFalse(copy === array); |
79 Expect.isTrue(copy is Int8List); | 79 Expect.isTrue(copy is Int8List); |
80 Expect.equals(10, copy.length); | 80 Expect.equals(10, copy.length); |
81 Expect.listEquals(array, copy); | 81 Expect.listEquals(array, copy); |
82 var empty = array.sublist(array.length, array.length); | 82 var empty = array.sublist(array.length, array.length); |
83 Expect.equals(0, empty.length); | 83 Expect.equals(0, empty.length); |
84 var region = array.sublist(3, array.length - 3); | 84 var region = array.sublist(3, array.length - 3); |
85 Expect.isTrue(copy is Int8List); | 85 Expect.isTrue(copy is Int8List); |
86 Expect.equals(4, region.length); | 86 Expect.equals(4, region.length); |
87 Expect.listEquals([3, 4, 5, 6], region); | 87 Expect.listEquals([3, 4, 5, 6], region); |
88 array.setRange(3, 4, [-128, 0, 1, 127]); | 88 array.setRange(3, 7, [-128, 0, 1, 127]); |
89 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], | 89 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], |
90 array); | 90 array); |
91 } | 91 } |
92 static testInt8List() { | 92 static testInt8List() { |
93 Expect.throws(() { new Int8List(-1); }, | 93 Expect.throws(() { new Int8List(-1); }, |
94 (e) { return e is ArgumentError; }); | 94 (e) { return e is ArgumentError; }); |
95 var array = new Int8List(10); | 95 var array = new Int8List(10); |
96 testInt8ListImpl(array); | 96 testInt8ListImpl(array); |
97 } | 97 } |
98 | 98 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 Expect.isFalse(copy === array); | 151 Expect.isFalse(copy === array); |
152 Expect.isTrue(copy is Uint8List); | 152 Expect.isTrue(copy is Uint8List); |
153 Expect.equals(10, copy.length); | 153 Expect.equals(10, copy.length); |
154 Expect.listEquals(array, copy); | 154 Expect.listEquals(array, copy); |
155 var empty = array.sublist(array.length, array.length); | 155 var empty = array.sublist(array.length, array.length); |
156 Expect.equals(0, empty.length); | 156 Expect.equals(0, empty.length); |
157 var region = array.sublist(3, array.length - 3); | 157 var region = array.sublist(3, array.length - 3); |
158 Expect.isTrue(copy is Uint8List); | 158 Expect.isTrue(copy is Uint8List); |
159 Expect.equals(4, region.length); | 159 Expect.equals(4, region.length); |
160 Expect.listEquals([3, 4, 5, 6], region); | 160 Expect.listEquals([3, 4, 5, 6], region); |
161 array.setRange(3, 4, [257, 0, 1, 255]); | 161 array.setRange(3, 7, [257, 0, 1, 255]); |
162 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], | 162 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], |
163 array); | 163 array); |
164 } | 164 } |
165 | 165 |
166 static testUint8List() { | 166 static testUint8List() { |
167 Expect.throws(() { new Uint8List(-1); }, | 167 Expect.throws(() { new Uint8List(-1); }, |
168 (e) { return e is ArgumentError; }); | 168 (e) { return e is ArgumentError; }); |
169 var array = new Uint8List(10); | 169 var array = new Uint8List(10); |
170 testUint8ListImpl(array); | 170 testUint8ListImpl(array); |
171 } | 171 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 Expect.isFalse(copy === array); | 237 Expect.isFalse(copy === array); |
238 Expect.isTrue(copy is Int16List); | 238 Expect.isTrue(copy is Int16List); |
239 Expect.equals(10, copy.length); | 239 Expect.equals(10, copy.length); |
240 Expect.listEquals(array, copy); | 240 Expect.listEquals(array, copy); |
241 var empty = array.sublist(array.length, array.length); | 241 var empty = array.sublist(array.length, array.length); |
242 Expect.equals(0, empty.length); | 242 Expect.equals(0, empty.length); |
243 var region = array.sublist(3, array.length - 3); | 243 var region = array.sublist(3, array.length - 3); |
244 Expect.isTrue(copy is Int16List); | 244 Expect.isTrue(copy is Int16List); |
245 Expect.equals(4, region.length); | 245 Expect.equals(4, region.length); |
246 Expect.listEquals([3, 4, 5, 6], region); | 246 Expect.listEquals([3, 4, 5, 6], region); |
247 array.setRange(3, 4, [-32768, 0, 1, 32767]); | 247 array.setRange(3, 7, [-32768, 0, 1, 32767]); |
248 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], | 248 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], |
249 array); | 249 array); |
250 } | 250 } |
251 | 251 |
252 static testInt16List() { | 252 static testInt16List() { |
253 Expect.throws(() { new Int16List(-1); }, | 253 Expect.throws(() { new Int16List(-1); }, |
254 (e) { return e is ArgumentError; }); | 254 (e) { return e is ArgumentError; }); |
255 var array = new Int16List(10); | 255 var array = new Int16List(10); |
256 testInt16ListImpl(array); | 256 testInt16ListImpl(array); |
257 } | 257 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 Expect.isFalse(copy === array); | 311 Expect.isFalse(copy === array); |
312 Expect.isTrue(copy is Uint16List); | 312 Expect.isTrue(copy is Uint16List); |
313 Expect.equals(10, copy.length); | 313 Expect.equals(10, copy.length); |
314 Expect.listEquals(array, copy); | 314 Expect.listEquals(array, copy); |
315 var empty = array.sublist(array.length, array.length); | 315 var empty = array.sublist(array.length, array.length); |
316 Expect.equals(0, empty.length); | 316 Expect.equals(0, empty.length); |
317 var region = array.sublist(3, array.length - 3); | 317 var region = array.sublist(3, array.length - 3); |
318 Expect.isTrue(copy is Uint16List); | 318 Expect.isTrue(copy is Uint16List); |
319 Expect.equals(4, region.length); | 319 Expect.equals(4, region.length); |
320 Expect.listEquals([3, 4, 5, 6], region); | 320 Expect.listEquals([3, 4, 5, 6], region); |
321 array.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); | 321 array.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]); |
322 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], | 322 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], |
323 array); | 323 array); |
324 } | 324 } |
325 | 325 |
326 static testUint16List() { | 326 static testUint16List() { |
327 Expect.throws(() { new Uint16List(-1); }, | 327 Expect.throws(() { new Uint16List(-1); }, |
328 (e) { return e is ArgumentError; }); | 328 (e) { return e is ArgumentError; }); |
329 var array = new Uint16List(10); | 329 var array = new Uint16List(10); |
330 testUint16ListImpl(array); | 330 testUint16ListImpl(array); |
331 } | 331 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 Expect.isFalse(copy === array); | 403 Expect.isFalse(copy === array); |
404 Expect.isTrue(copy is Int32List); | 404 Expect.isTrue(copy is Int32List); |
405 Expect.equals(10, copy.length); | 405 Expect.equals(10, copy.length); |
406 Expect.listEquals(array, copy); | 406 Expect.listEquals(array, copy); |
407 var empty = array.sublist(array.length, array.length); | 407 var empty = array.sublist(array.length, array.length); |
408 Expect.equals(0, empty.length); | 408 Expect.equals(0, empty.length); |
409 var region = array.sublist(3, array.length - 3); | 409 var region = array.sublist(3, array.length - 3); |
410 Expect.isTrue(copy is Int32List); | 410 Expect.isTrue(copy is Int32List); |
411 Expect.equals(4, region.length); | 411 Expect.equals(4, region.length); |
412 Expect.listEquals([3, 4, 5, 6], region); | 412 Expect.listEquals([3, 4, 5, 6], region); |
413 array.setRange(3, 4, [-0x80000000, 0, 1, 0x7FFFFFFF]); | 413 array.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]); |
414 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], | 414 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], |
415 array); | 415 array); |
416 } | 416 } |
417 | 417 |
418 static testInt32List() { | 418 static testInt32List() { |
419 Expect.throws(() { new Int32List(-1); }, | 419 Expect.throws(() { new Int32List(-1); }, |
420 (e) { return e is ArgumentError; }); | 420 (e) { return e is ArgumentError; }); |
421 var array = new Int32List(10); | 421 var array = new Int32List(10); |
422 testInt32ListImpl(array); | 422 testInt32ListImpl(array); |
423 } | 423 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 Expect.isFalse(copy === array); | 480 Expect.isFalse(copy === array); |
481 Expect.isTrue(copy is Uint32List); | 481 Expect.isTrue(copy is Uint32List); |
482 Expect.equals(10, copy.length); | 482 Expect.equals(10, copy.length); |
483 Expect.listEquals(array, copy); | 483 Expect.listEquals(array, copy); |
484 var empty = array.sublist(array.length, array.length); | 484 var empty = array.sublist(array.length, array.length); |
485 Expect.equals(0, empty.length); | 485 Expect.equals(0, empty.length); |
486 var region = array.sublist(3, array.length - 3); | 486 var region = array.sublist(3, array.length - 3); |
487 Expect.isTrue(copy is Uint32List); | 487 Expect.isTrue(copy is Uint32List); |
488 Expect.equals(4, region.length); | 488 Expect.equals(4, region.length); |
489 Expect.listEquals([3, 4, 5, 6], region); | 489 Expect.listEquals([3, 4, 5, 6], region); |
490 array.setRange(3, 4, [0x100000001, 0, 1, 0xFFFFFFFF]); | 490 array.setRange(3, 7, [0x100000001, 0, 1, 0xFFFFFFFF]); |
491 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], | 491 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], |
492 array); | 492 array); |
493 } | 493 } |
494 | 494 |
495 static testUint32List() { | 495 static testUint32List() { |
496 Expect.throws(() { new Uint32List(-1); }, | 496 Expect.throws(() { new Uint32List(-1); }, |
497 (e) { return e is ArgumentError; }); | 497 (e) { return e is ArgumentError; }); |
498 Expect.throws(() { new Uint32List(-1); }, | 498 Expect.throws(() { new Uint32List(-1); }, |
499 (e) { return e is ArgumentError; }); | 499 (e) { return e is ArgumentError; }); |
500 var array = new Uint32List(10); | 500 var array = new Uint32List(10); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 Expect.isFalse(copy === array); | 575 Expect.isFalse(copy === array); |
576 Expect.isTrue(copy is Int64List); | 576 Expect.isTrue(copy is Int64List); |
577 Expect.equals(10, copy.length); | 577 Expect.equals(10, copy.length); |
578 Expect.listEquals(array, copy); | 578 Expect.listEquals(array, copy); |
579 var empty = array.sublist(array.length, array.length); | 579 var empty = array.sublist(array.length, array.length); |
580 Expect.equals(0, empty.length); | 580 Expect.equals(0, empty.length); |
581 var region = array.sublist(3, array.length - 3); | 581 var region = array.sublist(3, array.length - 3); |
582 Expect.isTrue(copy is Int64List); | 582 Expect.isTrue(copy is Int64List); |
583 Expect.equals(4, region.length); | 583 Expect.equals(4, region.length); |
584 Expect.listEquals([3, 4, 5, 6], region); | 584 Expect.listEquals([3, 4, 5, 6], region); |
585 array.setRange(3, 4, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); | 585 array.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); |
586 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, | 586 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, |
587 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], | 587 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], |
588 array); | 588 array); |
589 } | 589 } |
590 | 590 |
591 static testInt64List() { | 591 static testInt64List() { |
592 Expect.throws(() { new Int64List(-1); }, | 592 Expect.throws(() { new Int64List(-1); }, |
593 (e) { return e is ArgumentError; }); | 593 (e) { return e is ArgumentError; }); |
594 var array = new Int64List(10); | 594 var array = new Int64List(10); |
595 testInt64ListImpl(array); | 595 testInt64ListImpl(array); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 Expect.isFalse(copy === array); | 653 Expect.isFalse(copy === array); |
654 Expect.isTrue(copy is Uint64List); | 654 Expect.isTrue(copy is Uint64List); |
655 Expect.equals(10, copy.length); | 655 Expect.equals(10, copy.length); |
656 Expect.listEquals(array, copy); | 656 Expect.listEquals(array, copy); |
657 var empty = array.sublist(array.length, array.length); | 657 var empty = array.sublist(array.length, array.length); |
658 Expect.equals(0, empty.length); | 658 Expect.equals(0, empty.length); |
659 var region = array.sublist(3, array.length - 3); | 659 var region = array.sublist(3, array.length - 3); |
660 Expect.isTrue(copy is Uint64List); | 660 Expect.isTrue(copy is Uint64List); |
661 Expect.equals(4, region.length); | 661 Expect.equals(4, region.length); |
662 Expect.listEquals([3, 4, 5, 6], region); | 662 Expect.listEquals([3, 4, 5, 6], region); |
663 array.setRange(3, 4, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); | 663 array.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); |
664 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], | 664 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], |
665 array); | 665 array); |
666 } | 666 } |
667 | 667 |
668 static testUint64List() { | 668 static testUint64List() { |
669 Expect.throws(() { new Uint64List(-1); }, | 669 Expect.throws(() { new Uint64List(-1); }, |
670 (e) { return e is ArgumentError; }); | 670 (e) { return e is ArgumentError; }); |
671 var array = new Uint64List(10); | 671 var array = new Uint64List(10); |
672 testUint64ListImpl(array); | 672 testUint64ListImpl(array); |
673 } | 673 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 Expect.isFalse(copy === array); | 716 Expect.isFalse(copy === array); |
717 Expect.isTrue(copy is Float32List); | 717 Expect.isTrue(copy is Float32List); |
718 Expect.equals(10, copy.length); | 718 Expect.equals(10, copy.length); |
719 Expect.listEquals(array, copy); | 719 Expect.listEquals(array, copy); |
720 var empty = array.sublist(array.length, array.length); | 720 var empty = array.sublist(array.length, array.length); |
721 Expect.equals(0, empty.length); | 721 Expect.equals(0, empty.length); |
722 var region = array.sublist(3, array.length - 3); | 722 var region = array.sublist(3, array.length - 3); |
723 Expect.isTrue(copy is Float32List); | 723 Expect.isTrue(copy is Float32List); |
724 Expect.equals(4, region.length); | 724 Expect.equals(4, region.length); |
725 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 725 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
726 array.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 726 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
727 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 727 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
728 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 728 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
729 array); | 729 array); |
730 } | 730 } |
731 | 731 |
732 static testFloat32List() { | 732 static testFloat32List() { |
733 Expect.throws(() { new Float32List(-1); }, | 733 Expect.throws(() { new Float32List(-1); }, |
734 (e) { return e is ArgumentError; }); | 734 (e) { return e is ArgumentError; }); |
735 var array = new Float32List(10); | 735 var array = new Float32List(10); |
736 testFloat32ListImpl(array); | 736 testFloat32ListImpl(array); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 Expect.isFalse(copy === array); | 780 Expect.isFalse(copy === array); |
781 Expect.isTrue(copy is Float64List); | 781 Expect.isTrue(copy is Float64List); |
782 Expect.equals(10, copy.length); | 782 Expect.equals(10, copy.length); |
783 Expect.listEquals(array, copy); | 783 Expect.listEquals(array, copy); |
784 var empty = array.sublist(array.length, array.length); | 784 var empty = array.sublist(array.length, array.length); |
785 Expect.equals(0, empty.length); | 785 Expect.equals(0, empty.length); |
786 var region = array.sublist(3, array.length - 3); | 786 var region = array.sublist(3, array.length - 3); |
787 Expect.isTrue(copy is Float64List); | 787 Expect.isTrue(copy is Float64List); |
788 Expect.equals(4, region.length); | 788 Expect.equals(4, region.length); |
789 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 789 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
790 array.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 790 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
791 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 791 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
792 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 792 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
793 array); | 793 array); |
794 } | 794 } |
795 | 795 |
796 static testFloat64List() { | 796 static testFloat64List() { |
797 Expect.throws(() { new Float64List(-1); }, | 797 Expect.throws(() { new Float64List(-1); }, |
798 (e) { return e is ArgumentError; }); | 798 (e) { return e is ArgumentError; }); |
799 var array = new Float64List(10); | 799 var array = new Float64List(10); |
800 testFloat64ListImpl(array); | 800 testFloat64ListImpl(array); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 } | 910 } |
911 var copy = view.sublist(0, view.length); | 911 var copy = view.sublist(0, view.length); |
912 Expect.isFalse(copy === view); | 912 Expect.isFalse(copy === view); |
913 Expect.isTrue(copy is Int8List); | 913 Expect.isTrue(copy is Int8List); |
914 Expect.equals(10, copy.length); | 914 Expect.equals(10, copy.length); |
915 Expect.listEquals(view, copy); | 915 Expect.listEquals(view, copy); |
916 var region = view.sublist(3, view.length - 3); | 916 var region = view.sublist(3, view.length - 3); |
917 Expect.isTrue(copy is Int8List); | 917 Expect.isTrue(copy is Int8List); |
918 Expect.equals(4, region.length); | 918 Expect.equals(4, region.length); |
919 Expect.listEquals([3, 4, 5, 6], region); | 919 Expect.listEquals([3, 4, 5, 6], region); |
920 view.setRange(3, 4, [-128, 0, 1, 127]); | 920 view.setRange(3, 7, [-128, 0, 1, 127]); |
921 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], | 921 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], |
922 view); | 922 view); |
923 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF], | 923 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF], |
924 array); | 924 array); |
925 } | 925 } |
926 static testInt8ListView() { | 926 static testInt8ListView() { |
927 var array = new Uint8List(12); | 927 var array = new Uint8List(12); |
928 testInt8ListViewImpl(array); | 928 testInt8ListViewImpl(array); |
929 } | 929 } |
930 | 930 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 } | 1021 } |
1022 var copy = view.sublist(0, view.length); | 1022 var copy = view.sublist(0, view.length); |
1023 Expect.isFalse(copy === view); | 1023 Expect.isFalse(copy === view); |
1024 Expect.isTrue(copy is Uint8List); | 1024 Expect.isTrue(copy is Uint8List); |
1025 Expect.equals(10, copy.length); | 1025 Expect.equals(10, copy.length); |
1026 Expect.listEquals(view, copy); | 1026 Expect.listEquals(view, copy); |
1027 var region = view.sublist(3, view.length - 3); | 1027 var region = view.sublist(3, view.length - 3); |
1028 Expect.isTrue(copy is Uint8List); | 1028 Expect.isTrue(copy is Uint8List); |
1029 Expect.equals(4, region.length); | 1029 Expect.equals(4, region.length); |
1030 Expect.listEquals([3, 4, 5, 6], region); | 1030 Expect.listEquals([3, 4, 5, 6], region); |
1031 view.setRange(3, 4, [257, 0, 1, 255]); | 1031 view.setRange(3, 7, [257, 0, 1, 255]); |
1032 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], | 1032 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], |
1033 view); | 1033 view); |
1034 } | 1034 } |
1035 | 1035 |
1036 static testUint8ListView() { | 1036 static testUint8ListView() { |
1037 var array = new Int8List(12); | 1037 var array = new Int8List(12); |
1038 testUint8ListViewImpl(array); | 1038 testUint8ListViewImpl(array); |
1039 } | 1039 } |
1040 | 1040 |
1041 static testInt16ListViewImpl(var array) { | 1041 static testInt16ListViewImpl(var array) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 } | 1153 } |
1154 var copy = view.sublist(0, view.length); | 1154 var copy = view.sublist(0, view.length); |
1155 Expect.isFalse(copy === view); | 1155 Expect.isFalse(copy === view); |
1156 Expect.isTrue(copy is Int16List); | 1156 Expect.isTrue(copy is Int16List); |
1157 Expect.equals(10, copy.length); | 1157 Expect.equals(10, copy.length); |
1158 Expect.listEquals(view, copy); | 1158 Expect.listEquals(view, copy); |
1159 var region = view.sublist(3, view.length - 3); | 1159 var region = view.sublist(3, view.length - 3); |
1160 Expect.isTrue(copy is Int16List); | 1160 Expect.isTrue(copy is Int16List); |
1161 Expect.equals(4, region.length); | 1161 Expect.equals(4, region.length); |
1162 Expect.listEquals([3, 4, 5, 6], region); | 1162 Expect.listEquals([3, 4, 5, 6], region); |
1163 view.setRange(3, 4, [-32768, 0, 1, 32767]); | 1163 view.setRange(3, 7, [-32768, 0, 1, 32767]); |
1164 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], | 1164 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], |
1165 view); | 1165 view); |
1166 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, | 1166 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, |
1167 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F, | 1167 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F, |
1168 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], | 1168 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], |
1169 array); | 1169 array); |
1170 } | 1170 } |
1171 | 1171 |
1172 static testInt16ListView() { | 1172 static testInt16ListView() { |
1173 var array = new Uint8List(24); | 1173 var array = new Uint8List(24); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 } | 1268 } |
1269 var copy = view.sublist(0, view.length); | 1269 var copy = view.sublist(0, view.length); |
1270 Expect.isFalse(copy === view); | 1270 Expect.isFalse(copy === view); |
1271 Expect.isTrue(copy is Uint16List); | 1271 Expect.isTrue(copy is Uint16List); |
1272 Expect.equals(10, copy.length); | 1272 Expect.equals(10, copy.length); |
1273 Expect.listEquals(view, copy); | 1273 Expect.listEquals(view, copy); |
1274 var region = view.sublist(3, view.length - 3); | 1274 var region = view.sublist(3, view.length - 3); |
1275 Expect.isTrue(copy is Uint16List); | 1275 Expect.isTrue(copy is Uint16List); |
1276 Expect.equals(4, region.length); | 1276 Expect.equals(4, region.length); |
1277 Expect.listEquals([3, 4, 5, 6], region); | 1277 Expect.listEquals([3, 4, 5, 6], region); |
1278 view.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); | 1278 view.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]); |
1279 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], | 1279 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], |
1280 view); | 1280 view); |
1281 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, | 1281 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, |
1282 1, 0, 0, 0, 1, 0, -1, -1, | 1282 1, 0, 0, 0, 1, 0, -1, -1, |
1283 7, 0, 8, 0, 9, 0, -1, -1], | 1283 7, 0, 8, 0, 9, 0, -1, -1], |
1284 array); | 1284 array); |
1285 } | 1285 } |
1286 | 1286 |
1287 static testUint16ListView() { | 1287 static testUint16ListView() { |
1288 var array = new Int8List(24); | 1288 var array = new Int8List(24); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 } | 1426 } |
1427 var copy = view.sublist(0, view.length); | 1427 var copy = view.sublist(0, view.length); |
1428 Expect.isFalse(copy === view); | 1428 Expect.isFalse(copy === view); |
1429 Expect.isTrue(copy is Int32List); | 1429 Expect.isTrue(copy is Int32List); |
1430 Expect.equals(10, copy.length); | 1430 Expect.equals(10, copy.length); |
1431 Expect.listEquals(view, copy); | 1431 Expect.listEquals(view, copy); |
1432 var region = view.sublist(3, view.length - 3); | 1432 var region = view.sublist(3, view.length - 3); |
1433 Expect.isTrue(copy is Int32List); | 1433 Expect.isTrue(copy is Int32List); |
1434 Expect.equals(4, region.length); | 1434 Expect.equals(4, region.length); |
1435 Expect.listEquals([3, 4, 5, 6], region); | 1435 Expect.listEquals([3, 4, 5, 6], region); |
1436 view.setRange(3, 4, [-0x80000000, 0, 1, 0x7FFFFFFF]); | 1436 view.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]); |
1437 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], | 1437 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], |
1438 view); | 1438 view); |
1439 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, | 1439 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, |
1440 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, | 1440 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
1441 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, | 1441 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, |
1442 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, | 1442 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, |
1443 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, | 1443 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, |
1444 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], | 1444 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], |
1445 array); | 1445 array); |
1446 } | 1446 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 } | 1553 } |
1554 var copy = view.sublist(0, view.length); | 1554 var copy = view.sublist(0, view.length); |
1555 Expect.isFalse(copy === view); | 1555 Expect.isFalse(copy === view); |
1556 Expect.isTrue(copy is Uint32List); | 1556 Expect.isTrue(copy is Uint32List); |
1557 Expect.equals(10, copy.length); | 1557 Expect.equals(10, copy.length); |
1558 Expect.listEquals(view, copy); | 1558 Expect.listEquals(view, copy); |
1559 var region = view.sublist(3, view.length - 3); | 1559 var region = view.sublist(3, view.length - 3); |
1560 Expect.isTrue(copy is Uint32List); | 1560 Expect.isTrue(copy is Uint32List); |
1561 Expect.equals(4, region.length); | 1561 Expect.equals(4, region.length); |
1562 Expect.listEquals([3, 4, 5, 6], region); | 1562 Expect.listEquals([3, 4, 5, 6], region); |
1563 view.setRange(3, 4, [0x100000001, 0, 1, 0xFFFFFFFF]); | 1563 view.setRange(3, 7, [0x100000001, 0, 1, 0xFFFFFFFF]); |
1564 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], | 1564 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], |
1565 view); | 1565 view); |
1566 Expect.listEquals([-1, -1, -1, -1, 0, 0, 0, 0, | 1566 Expect.listEquals([-1, -1, -1, -1, 0, 0, 0, 0, |
1567 1, 0, 0, 0, 2, 0, 0, 0, | 1567 1, 0, 0, 0, 2, 0, 0, 0, |
1568 1, 0, 0, 0, 0, 0, 0, 0, | 1568 1, 0, 0, 0, 0, 0, 0, 0, |
1569 1, 0, 0, 0, -1, -1, -1, -1, | 1569 1, 0, 0, 0, -1, -1, -1, -1, |
1570 7, 0, 0, 0, 8, 0, 0, 0, | 1570 7, 0, 0, 0, 8, 0, 0, 0, |
1571 9, 0, 0, 0, -1, -1, -1, -1], | 1571 9, 0, 0, 0, -1, -1, -1, -1], |
1572 array); | 1572 array); |
1573 } | 1573 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 } | 1743 } |
1744 var copy = view.sublist(0, view.length); | 1744 var copy = view.sublist(0, view.length); |
1745 Expect.isFalse(copy === view); | 1745 Expect.isFalse(copy === view); |
1746 Expect.isTrue(copy is Int64List); | 1746 Expect.isTrue(copy is Int64List); |
1747 Expect.equals(10, copy.length); | 1747 Expect.equals(10, copy.length); |
1748 Expect.listEquals(view, copy); | 1748 Expect.listEquals(view, copy); |
1749 var region = view.sublist(3, view.length - 3); | 1749 var region = view.sublist(3, view.length - 3); |
1750 Expect.isTrue(copy is Int64List); | 1750 Expect.isTrue(copy is Int64List); |
1751 Expect.equals(4, region.length); | 1751 Expect.equals(4, region.length); |
1752 Expect.listEquals([3, 4, 5, 6], region); | 1752 Expect.listEquals([3, 4, 5, 6], region); |
1753 view.setRange(3, 4, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); | 1753 view.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); |
1754 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, | 1754 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, |
1755 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], | 1755 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], |
1756 view); | 1756 view); |
1757 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 1757 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
1758 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1758 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
1759 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1759 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
1760 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1760 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
1761 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 1761 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
1762 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1762 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
1763 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 1763 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 } | 1903 } |
1904 var copy = view.sublist(0, view.length); | 1904 var copy = view.sublist(0, view.length); |
1905 Expect.isFalse(copy === view); | 1905 Expect.isFalse(copy === view); |
1906 Expect.isTrue(copy is Uint64List); | 1906 Expect.isTrue(copy is Uint64List); |
1907 Expect.equals(10, copy.length); | 1907 Expect.equals(10, copy.length); |
1908 Expect.listEquals(view, copy); | 1908 Expect.listEquals(view, copy); |
1909 var region = view.sublist(3, view.length - 3); | 1909 var region = view.sublist(3, view.length - 3); |
1910 Expect.isTrue(copy is Uint64List); | 1910 Expect.isTrue(copy is Uint64List); |
1911 Expect.equals(4, region.length); | 1911 Expect.equals(4, region.length); |
1912 Expect.listEquals([3, 4, 5, 6], region); | 1912 Expect.listEquals([3, 4, 5, 6], region); |
1913 view.setRange(3, 4, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); | 1913 view.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); |
1914 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], | 1914 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], |
1915 view); | 1915 view); |
1916 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, | 1916 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, |
1917 0, 0, 0, 0, 0, 0, 0, 0, | 1917 0, 0, 0, 0, 0, 0, 0, 0, |
1918 1, 0, 0, 0, 0, 0, 0, 0, | 1918 1, 0, 0, 0, 0, 0, 0, 0, |
1919 2, 0, 0, 0, 0, 0, 0, 0, | 1919 2, 0, 0, 0, 0, 0, 0, 0, |
1920 1, 0, 0, 0, 0, 0, 0, 0, | 1920 1, 0, 0, 0, 0, 0, 0, 0, |
1921 0, 0, 0, 0, 0, 0, 0, 0, | 1921 0, 0, 0, 0, 0, 0, 0, 0, |
1922 1, 0, 0, 0, 0, 0, 0, 0, | 1922 1, 0, 0, 0, 0, 0, 0, 0, |
1923 -1, -1, -1, -1, -1, -1, -1, -1, | 1923 -1, -1, -1, -1, -1, -1, -1, -1, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2013 } | 2013 } |
2014 var copy = view.sublist(0, view.length); | 2014 var copy = view.sublist(0, view.length); |
2015 Expect.isFalse(copy === view); | 2015 Expect.isFalse(copy === view); |
2016 Expect.isTrue(copy is Float32List); | 2016 Expect.isTrue(copy is Float32List); |
2017 Expect.equals(10, copy.length); | 2017 Expect.equals(10, copy.length); |
2018 Expect.listEquals(view, copy); | 2018 Expect.listEquals(view, copy); |
2019 var region = view.sublist(3, view.length - 3); | 2019 var region = view.sublist(3, view.length - 3); |
2020 Expect.isTrue(copy is Float32List); | 2020 Expect.isTrue(copy is Float32List); |
2021 Expect.equals(4, region.length); | 2021 Expect.equals(4, region.length); |
2022 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 2022 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
2023 view.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 2023 view.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
2024 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 2024 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
2025 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 2025 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
2026 view); | 2026 view); |
2027 Expect.listEquals([0xBF800000, 0x00000000, | 2027 Expect.listEquals([0xBF800000, 0x00000000, |
2028 0x3F800000, 0x40000000, | 2028 0x3F800000, 0x40000000, |
2029 0xFF800000, 0x00000000, | 2029 0xFF800000, 0x00000000, |
2030 0x3F800000, 0x7F800000, | 2030 0x3F800000, 0x7F800000, |
2031 0x40E00000, 0x41000000, | 2031 0x40E00000, 0x41000000, |
2032 0x41100000, 0xBF800000], | 2032 0x41100000, 0xBF800000], |
2033 array); | 2033 array); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2118 } | 2118 } |
2119 var copy = view.sublist(0, view.length); | 2119 var copy = view.sublist(0, view.length); |
2120 Expect.isFalse(copy === view); | 2120 Expect.isFalse(copy === view); |
2121 Expect.isTrue(copy is Float64List); | 2121 Expect.isTrue(copy is Float64List); |
2122 Expect.equals(10, copy.length); | 2122 Expect.equals(10, copy.length); |
2123 Expect.listEquals(view, copy); | 2123 Expect.listEquals(view, copy); |
2124 var region = view.sublist(3, view.length - 3); | 2124 var region = view.sublist(3, view.length - 3); |
2125 Expect.isTrue(copy is Float64List); | 2125 Expect.isTrue(copy is Float64List); |
2126 Expect.equals(4, region.length); | 2126 Expect.equals(4, region.length); |
2127 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 2127 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
2128 view.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 2128 view.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
2129 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 2129 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
2130 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 2130 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
2131 view); | 2131 view); |
2132 Expect.listEquals([0xBFF0000000000000, 0x0000000000000000, | 2132 Expect.listEquals([0xBFF0000000000000, 0x0000000000000000, |
2133 0x3FF0000000000000, 0x4000000000000000, | 2133 0x3FF0000000000000, 0x4000000000000000, |
2134 0xFFF0000000000000, 0x0000000000000000, | 2134 0xFFF0000000000000, 0x0000000000000000, |
2135 0x3FF0000000000000, 0x7FF0000000000000, | 2135 0x3FF0000000000000, 0x7FF0000000000000, |
2136 0x401C000000000000, 0x4020000000000000, | 2136 0x401C000000000000, 0x4020000000000000, |
2137 0x4022000000000000, 0xBFF0000000000000], | 2137 0x4022000000000000, 0xBFF0000000000000], |
2138 array); | 2138 array); |
(...skipping 27 matching lines...) Expand all Loading... |
2166 testFloat32ListView(); | 2166 testFloat32ListView(); |
2167 testFloat64ListView(); | 2167 testFloat64ListView(); |
2168 } | 2168 } |
2169 } | 2169 } |
2170 | 2170 |
2171 main() { | 2171 main() { |
2172 for (var i=0; i<1000; i++) { | 2172 for (var i=0; i<1000; i++) { |
2173 OptimizedByteArrayTest.testMain(); | 2173 OptimizedByteArrayTest.testMain(); |
2174 } | 2174 } |
2175 } | 2175 } |
OLD | NEW |