Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: runtime/tests/vm/dart/byte_array_test.dart

Issue 13863012: Refactor List.setRange function. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 Expect.listEquals(array, copy); 79 Expect.listEquals(array, copy);
80 var empty = array.sublist(array.length, array.length); 80 var empty = array.sublist(array.length, array.length);
81 Expect.equals(0, empty.length); 81 Expect.equals(0, empty.length);
82 empty = array.sublist(array.length); 82 empty = array.sublist(array.length);
83 Expect.equals(0, empty.length); 83 Expect.equals(0, empty.length);
84 84
85 var region = array.sublist(3, array.length - 3); 85 var region = array.sublist(3, array.length - 3);
86 Expect.isTrue(copy is Int8List); 86 Expect.isTrue(copy is Int8List);
87 Expect.equals(4, region.length); 87 Expect.equals(4, region.length);
88 Expect.listEquals([3, 4, 5, 6], region); 88 Expect.listEquals([3, 4, 5, 6], region);
89 array.setRange(3, 4, [-128, 0, 1, 127]); 89 array.setRange(3, 7, [-128, 0, 1, 127]);
90 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], 90 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9],
91 array); 91 array);
92 } 92 }
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 Expect.throws(() { new Int8List.transferable(-1); }, 96 Expect.throws(() { new Int8List.transferable(-1); },
97 (e) { return e is ArgumentError; }); 97 (e) { return e is ArgumentError; });
98 var array = new Int8List(10); 98 var array = new Int8List(10);
99 testInt8ListImpl(array); 99 testInt8ListImpl(array);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 Expect.listEquals(array, copy); 159 Expect.listEquals(array, copy);
160 var empty = array.sublist(array.length, array.length); 160 var empty = array.sublist(array.length, array.length);
161 Expect.equals(0, empty.length); 161 Expect.equals(0, empty.length);
162 empty = array.sublist(array.length); 162 empty = array.sublist(array.length);
163 Expect.equals(0, empty.length); 163 Expect.equals(0, empty.length);
164 164
165 var region = array.sublist(3, array.length - 3); 165 var region = array.sublist(3, array.length - 3);
166 Expect.isTrue(copy is Uint8List); 166 Expect.isTrue(copy is Uint8List);
167 Expect.equals(4, region.length); 167 Expect.equals(4, region.length);
168 Expect.listEquals([3, 4, 5, 6], region); 168 Expect.listEquals([3, 4, 5, 6], region);
169 array.setRange(3, 4, [257, 0, 1, 255]); 169 array.setRange(3, 7, [257, 0, 1, 255]);
170 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], 170 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9],
171 array); 171 array);
172 } 172 }
173 173
174 static testUint8List() { 174 static testUint8List() {
175 Expect.throws(() { new Uint8List(-1); }, 175 Expect.throws(() { new Uint8List(-1); },
176 (e) { return e is ArgumentError; }); 176 (e) { return e is ArgumentError; });
177 Expect.throws(() { new Uint8List.transferable(-1); }, 177 Expect.throws(() { new Uint8List.transferable(-1); },
178 (e) { return e is ArgumentError; }); 178 (e) { return e is ArgumentError; });
179 var array = new Uint8List(10); 179 var array = new Uint8List(10);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 Expect.listEquals(array, copy); 237 Expect.listEquals(array, copy);
238 var empty = array.sublist(array.length, array.length); 238 var empty = array.sublist(array.length, array.length);
239 Expect.equals(0, empty.length); 239 Expect.equals(0, empty.length);
240 empty = array.sublist(array.length); 240 empty = array.sublist(array.length);
241 Expect.equals(0, empty.length); 241 Expect.equals(0, empty.length);
242 242
243 var region = array.sublist(3, array.length - 3); 243 var region = array.sublist(3, array.length - 3);
244 Expect.isTrue(copy is Uint8ClampedList); 244 Expect.isTrue(copy is Uint8ClampedList);
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, [257, 0, 1, 255]); 247 array.setRange(3, 7, [257, 0, 1, 255]);
248 Expect.listEquals([0, 1, 2, 255, 0, 1, 255, 7, 8, 9], array); 248 Expect.listEquals([0, 1, 2, 255, 0, 1, 255, 7, 8, 9], array);
249 } 249 }
250 250
251 static testUint8ClampedList() { 251 static testUint8ClampedList() {
252 Expect.throws(() { new Uint8ClampedList(-1); }, 252 Expect.throws(() { new Uint8ClampedList(-1); },
253 (e) { return e is ArgumentError; }); 253 (e) { return e is ArgumentError; });
254 Expect.throws(() { new Uint8ClampedList.transferable(-1); }, 254 Expect.throws(() { new Uint8ClampedList.transferable(-1); },
255 (e) { return e is ArgumentError; }); 255 (e) { return e is ArgumentError; });
256 var array = new Uint8ClampedList(10); 256 var array = new Uint8ClampedList(10);
257 testUint8ClampedListImpl(array); 257 testUint8ClampedListImpl(array);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 Expect.listEquals(array, copy); 329 Expect.listEquals(array, copy);
330 var empty = array.sublist(array.length, array.length); 330 var empty = array.sublist(array.length, array.length);
331 Expect.equals(0, empty.length); 331 Expect.equals(0, empty.length);
332 empty = array.sublist(array.length); 332 empty = array.sublist(array.length);
333 Expect.equals(0, empty.length); 333 Expect.equals(0, empty.length);
334 334
335 var region = array.sublist(3, array.length - 3); 335 var region = array.sublist(3, array.length - 3);
336 Expect.isTrue(copy is Int16List); 336 Expect.isTrue(copy is Int16List);
337 Expect.equals(4, region.length); 337 Expect.equals(4, region.length);
338 Expect.listEquals([3, 4, 5, 6], region); 338 Expect.listEquals([3, 4, 5, 6], region);
339 array.setRange(3, 4, [-32768, 0, 1, 32767]); 339 array.setRange(3, 7, [-32768, 0, 1, 32767]);
340 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], 340 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9],
341 array); 341 array);
342 } 342 }
343 343
344 static testInt16List() { 344 static testInt16List() {
345 Expect.throws(() { new Int16List(-1); }, 345 Expect.throws(() { new Int16List(-1); },
346 (e) { return e is ArgumentError; }); 346 (e) { return e is ArgumentError; });
347 Expect.throws(() { new Int16List.transferable(-1); }, 347 Expect.throws(() { new Int16List.transferable(-1); },
348 (e) { return e is ArgumentError; }); 348 (e) { return e is ArgumentError; });
349 var array = new Int16List(10); 349 var array = new Int16List(10);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 Expect.listEquals(array, copy); 410 Expect.listEquals(array, copy);
411 var empty = array.sublist(array.length, array.length); 411 var empty = array.sublist(array.length, array.length);
412 Expect.equals(0, empty.length); 412 Expect.equals(0, empty.length);
413 empty = array.sublist(array.length); 413 empty = array.sublist(array.length);
414 Expect.equals(0, empty.length); 414 Expect.equals(0, empty.length);
415 415
416 var region = array.sublist(3, array.length - 3); 416 var region = array.sublist(3, array.length - 3);
417 Expect.isTrue(copy is Uint16List); 417 Expect.isTrue(copy is Uint16List);
418 Expect.equals(4, region.length); 418 Expect.equals(4, region.length);
419 Expect.listEquals([3, 4, 5, 6], region); 419 Expect.listEquals([3, 4, 5, 6], region);
420 array.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); 420 array.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]);
421 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], 421 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9],
422 array); 422 array);
423 } 423 }
424 424
425 static testUint16List() { 425 static testUint16List() {
426 Expect.throws(() { new Uint16List(-1); }, 426 Expect.throws(() { new Uint16List(-1); },
427 (e) { return e is ArgumentError; }); 427 (e) { return e is ArgumentError; });
428 Expect.throws(() { new Uint16List.transferable(-1); }, 428 Expect.throws(() { new Uint16List.transferable(-1); },
429 (e) { return e is ArgumentError; }); 429 (e) { return e is ArgumentError; });
430 var array = new Uint16List(10); 430 var array = new Uint16List(10);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 Expect.listEquals(array, copy); 509 Expect.listEquals(array, copy);
510 var empty = array.sublist(array.length, array.length); 510 var empty = array.sublist(array.length, array.length);
511 Expect.equals(0, empty.length); 511 Expect.equals(0, empty.length);
512 empty = array.sublist(array.length); 512 empty = array.sublist(array.length);
513 Expect.equals(0, empty.length); 513 Expect.equals(0, empty.length);
514 514
515 var region = array.sublist(3, array.length - 3); 515 var region = array.sublist(3, array.length - 3);
516 Expect.isTrue(copy is Int32List); 516 Expect.isTrue(copy is Int32List);
517 Expect.equals(4, region.length); 517 Expect.equals(4, region.length);
518 Expect.listEquals([3, 4, 5, 6], region); 518 Expect.listEquals([3, 4, 5, 6], region);
519 array.setRange(3, 4, [-0x80000000, 0, 1, 0x7FFFFFFF]); 519 array.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]);
520 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], 520 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9],
521 array); 521 array);
522 } 522 }
523 523
524 static testInt32List() { 524 static testInt32List() {
525 Expect.throws(() { new Int32List(-1); }, 525 Expect.throws(() { new Int32List(-1); },
526 (e) { return e is ArgumentError; }); 526 (e) { return e is ArgumentError; });
527 Expect.throws(() { new Int32List.transferable(-1); }, 527 Expect.throws(() { new Int32List.transferable(-1); },
528 (e) { return e is ArgumentError; }); 528 (e) { return e is ArgumentError; });
529 var array = new Int32List(10); 529 var array = new Int32List(10);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 Expect.listEquals(array, copy); 593 Expect.listEquals(array, copy);
594 var empty = array.sublist(array.length, array.length); 594 var empty = array.sublist(array.length, array.length);
595 Expect.equals(0, empty.length); 595 Expect.equals(0, empty.length);
596 empty = array.sublist(array.length); 596 empty = array.sublist(array.length);
597 Expect.equals(0, empty.length); 597 Expect.equals(0, empty.length);
598 598
599 var region = array.sublist(3, array.length - 3); 599 var region = array.sublist(3, array.length - 3);
600 Expect.isTrue(copy is Uint32List); 600 Expect.isTrue(copy is Uint32List);
601 Expect.equals(4, region.length); 601 Expect.equals(4, region.length);
602 Expect.listEquals([3, 4, 5, 6], region); 602 Expect.listEquals([3, 4, 5, 6], region);
603 array.setRange(3, 4, [0x100000001, 0, 1, 0xFFFFFFFF]); 603 array.setRange(3, 7, [0x100000001, 0, 1, 0xFFFFFFFF]);
604 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], 604 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9],
605 array); 605 array);
606 } 606 }
607 607
608 static testUint32List() { 608 static testUint32List() {
609 Expect.throws(() { new Uint32List(-1); }, 609 Expect.throws(() { new Uint32List(-1); },
610 (e) { return e is ArgumentError; }); 610 (e) { return e is ArgumentError; });
611 Expect.throws(() { new Uint32List(-1); }, 611 Expect.throws(() { new Uint32List(-1); },
612 (e) { return e is ArgumentError; }); 612 (e) { return e is ArgumentError; });
613 var array = new Uint32List(10); 613 var array = new Uint32List(10);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 Expect.listEquals(array, copy); 693 Expect.listEquals(array, copy);
694 var empty = array.sublist(array.length, array.length); 694 var empty = array.sublist(array.length, array.length);
695 Expect.equals(0, empty.length); 695 Expect.equals(0, empty.length);
696 empty = array.sublist(array.length); 696 empty = array.sublist(array.length);
697 Expect.equals(0, empty.length); 697 Expect.equals(0, empty.length);
698 698
699 var region = array.sublist(3, array.length - 3); 699 var region = array.sublist(3, array.length - 3);
700 Expect.isTrue(copy is Int64List); 700 Expect.isTrue(copy is Int64List);
701 Expect.equals(4, region.length); 701 Expect.equals(4, region.length);
702 Expect.listEquals([3, 4, 5, 6], region); 702 Expect.listEquals([3, 4, 5, 6], region);
703 array.setRange(3, 4, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); 703 array.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]);
704 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, 704 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0,
705 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], 705 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9],
706 array); 706 array);
707 } 707 }
708 708
709 static testInt64List() { 709 static testInt64List() {
710 Expect.throws(() { new Int64List(-1); }, 710 Expect.throws(() { new Int64List(-1); },
711 (e) { return e is ArgumentError; }); 711 (e) { return e is ArgumentError; });
712 Expect.throws(() { new Int64List.transferable(-1); }, 712 Expect.throws(() { new Int64List.transferable(-1); },
713 (e) { return e is ArgumentError; }); 713 (e) { return e is ArgumentError; });
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 Expect.listEquals(array, copy); 778 Expect.listEquals(array, copy);
779 var empty = array.sublist(array.length, array.length); 779 var empty = array.sublist(array.length, array.length);
780 Expect.equals(0, empty.length); 780 Expect.equals(0, empty.length);
781 empty = array.sublist(array.length); 781 empty = array.sublist(array.length);
782 Expect.equals(0, empty.length); 782 Expect.equals(0, empty.length);
783 783
784 var region = array.sublist(3, array.length - 3); 784 var region = array.sublist(3, array.length - 3);
785 Expect.isTrue(copy is Uint64List); 785 Expect.isTrue(copy is Uint64List);
786 Expect.equals(4, region.length); 786 Expect.equals(4, region.length);
787 Expect.listEquals([3, 4, 5, 6], region); 787 Expect.listEquals([3, 4, 5, 6], region);
788 array.setRange(3, 4, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); 788 array.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]);
789 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], 789 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9],
790 array); 790 array);
791 } 791 }
792 792
793 static testUint64List() { 793 static testUint64List() {
794 Expect.throws(() { new Uint64List(-1); }, 794 Expect.throws(() { new Uint64List(-1); },
795 (e) { return e is ArgumentError; }); 795 (e) { return e is ArgumentError; });
796 Expect.throws(() { new Uint64List.transferable(-1); }, 796 Expect.throws(() { new Uint64List.transferable(-1); },
797 (e) { return e is ArgumentError; }); 797 (e) { return e is ArgumentError; });
798 var array = new Uint64List(10); 798 var array = new Uint64List(10);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 Expect.listEquals(array, copy); 848 Expect.listEquals(array, copy);
849 var empty = array.sublist(array.length, array.length); 849 var empty = array.sublist(array.length, array.length);
850 Expect.equals(0, empty.length); 850 Expect.equals(0, empty.length);
851 empty = array.sublist(array.length); 851 empty = array.sublist(array.length);
852 Expect.equals(0, empty.length); 852 Expect.equals(0, empty.length);
853 853
854 var region = array.sublist(3, array.length - 3); 854 var region = array.sublist(3, array.length - 3);
855 Expect.isTrue(copy is Float32List); 855 Expect.isTrue(copy is Float32List);
856 Expect.equals(4, region.length); 856 Expect.equals(4, region.length);
857 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); 857 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region);
858 array.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); 858 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]);
859 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, 859 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0,
860 1.0, double.INFINITY, 7.0, 8.0, 9.0], 860 1.0, double.INFINITY, 7.0, 8.0, 9.0],
861 array); 861 array);
862 } 862 }
863 863
864 static testFloat32List() { 864 static testFloat32List() {
865 Expect.throws(() { new Float32List(-1); }, 865 Expect.throws(() { new Float32List(-1); },
866 (e) { return e is ArgumentError; }); 866 (e) { return e is ArgumentError; });
867 Expect.throws(() { new Float32List.transferable(-1); }, 867 Expect.throws(() { new Float32List.transferable(-1); },
868 (e) { return e is ArgumentError; }); 868 (e) { return e is ArgumentError; });
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 Expect.listEquals(array, copy); 919 Expect.listEquals(array, copy);
920 var empty = array.sublist(array.length, array.length); 920 var empty = array.sublist(array.length, array.length);
921 Expect.equals(0, empty.length); 921 Expect.equals(0, empty.length);
922 empty = array.sublist(array.length); 922 empty = array.sublist(array.length);
923 Expect.equals(0, empty.length); 923 Expect.equals(0, empty.length);
924 924
925 var region = array.sublist(3, array.length - 3); 925 var region = array.sublist(3, array.length - 3);
926 Expect.isTrue(copy is Float64List); 926 Expect.isTrue(copy is Float64List);
927 Expect.equals(4, region.length); 927 Expect.equals(4, region.length);
928 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); 928 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region);
929 array.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); 929 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]);
930 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, 930 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0,
931 1.0, double.INFINITY, 7.0, 8.0, 9.0], 931 1.0, double.INFINITY, 7.0, 8.0, 9.0],
932 array); 932 array);
933 } 933 }
934 934
935 static testFloat64List() { 935 static testFloat64List() {
936 Expect.throws(() { new Float64List(-1); }, 936 Expect.throws(() { new Float64List(-1); },
937 (e) { return e is ArgumentError; }); 937 (e) { return e is ArgumentError; });
938 var array = new Float64List(10); 938 var array = new Float64List(10);
939 testFloat64ListImpl(array); 939 testFloat64ListImpl(array);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 } 1196 }
1197 var copy = view.sublist(0, view.length); 1197 var copy = view.sublist(0, view.length);
1198 Expect.isFalse(copy === view); 1198 Expect.isFalse(copy === view);
1199 Expect.isTrue(copy is Int8List); 1199 Expect.isTrue(copy is Int8List);
1200 Expect.equals(10, copy.length); 1200 Expect.equals(10, copy.length);
1201 Expect.listEquals(view, copy); 1201 Expect.listEquals(view, copy);
1202 var region = view.sublist(3, view.length - 3); 1202 var region = view.sublist(3, view.length - 3);
1203 Expect.isTrue(copy is Int8List); 1203 Expect.isTrue(copy is Int8List);
1204 Expect.equals(4, region.length); 1204 Expect.equals(4, region.length);
1205 Expect.listEquals([3, 4, 5, 6], region); 1205 Expect.listEquals([3, 4, 5, 6], region);
1206 view.setRange(3, 4, [-128, 0, 1, 127]); 1206 view.setRange(3, 7, [-128, 0, 1, 127]);
1207 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], 1207 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9],
1208 view); 1208 view);
1209 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF], 1209 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF],
1210 array); 1210 array);
1211 } 1211 }
1212 static testInt8ListView() { 1212 static testInt8ListView() {
1213 var array = new Uint8List(12); 1213 var array = new Uint8List(12);
1214 testInt8ListViewImpl(array); 1214 testInt8ListViewImpl(array);
1215 array = new Uint8List.transferable(12); 1215 array = new Uint8List.transferable(12);
1216 testInt8ListViewImpl(array); 1216 testInt8ListViewImpl(array);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 } 1309 }
1310 var copy = view.sublist(0, view.length); 1310 var copy = view.sublist(0, view.length);
1311 Expect.isFalse(copy === view); 1311 Expect.isFalse(copy === view);
1312 Expect.isTrue(copy is Uint8List); 1312 Expect.isTrue(copy is Uint8List);
1313 Expect.equals(10, copy.length); 1313 Expect.equals(10, copy.length);
1314 Expect.listEquals(view, copy); 1314 Expect.listEquals(view, copy);
1315 var region = view.sublist(3, view.length - 3); 1315 var region = view.sublist(3, view.length - 3);
1316 Expect.isTrue(copy is Uint8List); 1316 Expect.isTrue(copy is Uint8List);
1317 Expect.equals(4, region.length); 1317 Expect.equals(4, region.length);
1318 Expect.listEquals([3, 4, 5, 6], region); 1318 Expect.listEquals([3, 4, 5, 6], region);
1319 view.setRange(3, 4, [257, 0, 1, 255]); 1319 view.setRange(3, 7, [257, 0, 1, 255]);
1320 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], 1320 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9],
1321 view); 1321 view);
1322 } 1322 }
1323 1323
1324 static testUint8ListView() { 1324 static testUint8ListView() {
1325 var array = new Int8List(12); 1325 var array = new Int8List(12);
1326 testUint8ListViewImpl(array); 1326 testUint8ListViewImpl(array);
1327 array = new Int8List.transferable(12); 1327 array = new Int8List.transferable(12);
1328 testUint8ListViewImpl(array); 1328 testUint8ListViewImpl(array);
1329 } 1329 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 } 1443 }
1444 var copy = view.sublist(0, view.length); 1444 var copy = view.sublist(0, view.length);
1445 Expect.isFalse(copy === view); 1445 Expect.isFalse(copy === view);
1446 Expect.isTrue(copy is Int16List); 1446 Expect.isTrue(copy is Int16List);
1447 Expect.equals(10, copy.length); 1447 Expect.equals(10, copy.length);
1448 Expect.listEquals(view, copy); 1448 Expect.listEquals(view, copy);
1449 var region = view.sublist(3, view.length - 3); 1449 var region = view.sublist(3, view.length - 3);
1450 Expect.isTrue(copy is Int16List); 1450 Expect.isTrue(copy is Int16List);
1451 Expect.equals(4, region.length); 1451 Expect.equals(4, region.length);
1452 Expect.listEquals([3, 4, 5, 6], region); 1452 Expect.listEquals([3, 4, 5, 6], region);
1453 view.setRange(3, 4, [-32768, 0, 1, 32767]); 1453 view.setRange(3, 7, [-32768, 0, 1, 32767]);
1454 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], 1454 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9],
1455 view); 1455 view);
1456 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 1456 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
1457 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F, 1457 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F,
1458 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], 1458 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF],
1459 array); 1459 array);
1460 } 1460 }
1461 1461
1462 static testInt16ListView() { 1462 static testInt16ListView() {
1463 var array = new Uint8List(24); 1463 var array = new Uint8List(24);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 } 1560 }
1561 var copy = view.sublist(0, view.length); 1561 var copy = view.sublist(0, view.length);
1562 Expect.isFalse(copy === view); 1562 Expect.isFalse(copy === view);
1563 Expect.isTrue(copy is Uint16List); 1563 Expect.isTrue(copy is Uint16List);
1564 Expect.equals(10, copy.length); 1564 Expect.equals(10, copy.length);
1565 Expect.listEquals(view, copy); 1565 Expect.listEquals(view, copy);
1566 var region = view.sublist(3, view.length - 3); 1566 var region = view.sublist(3, view.length - 3);
1567 Expect.isTrue(copy is Uint16List); 1567 Expect.isTrue(copy is Uint16List);
1568 Expect.equals(4, region.length); 1568 Expect.equals(4, region.length);
1569 Expect.listEquals([3, 4, 5, 6], region); 1569 Expect.listEquals([3, 4, 5, 6], region);
1570 view.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); 1570 view.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]);
1571 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], 1571 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9],
1572 view); 1572 view);
1573 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, 1573 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0,
1574 1, 0, 0, 0, 1, 0, -1, -1, 1574 1, 0, 0, 0, 1, 0, -1, -1,
1575 7, 0, 8, 0, 9, 0, -1, -1], 1575 7, 0, 8, 0, 9, 0, -1, -1],
1576 array); 1576 array);
1577 } 1577 }
1578 1578
1579 static testUint16ListView() { 1579 static testUint16ListView() {
1580 var array = new Int8List(24); 1580 var array = new Int8List(24);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 } 1720 }
1721 var copy = view.sublist(0, view.length); 1721 var copy = view.sublist(0, view.length);
1722 Expect.isFalse(copy === view); 1722 Expect.isFalse(copy === view);
1723 Expect.isTrue(copy is Int32List); 1723 Expect.isTrue(copy is Int32List);
1724 Expect.equals(10, copy.length); 1724 Expect.equals(10, copy.length);
1725 Expect.listEquals(view, copy); 1725 Expect.listEquals(view, copy);
1726 var region = view.sublist(3, view.length - 3); 1726 var region = view.sublist(3, view.length - 3);
1727 Expect.isTrue(copy is Int32List); 1727 Expect.isTrue(copy is Int32List);
1728 Expect.equals(4, region.length); 1728 Expect.equals(4, region.length);
1729 Expect.listEquals([3, 4, 5, 6], region); 1729 Expect.listEquals([3, 4, 5, 6], region);
1730 view.setRange(3, 4, [-0x80000000, 0, 1, 0x7FFFFFFF]); 1730 view.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]);
1731 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], 1731 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9],
1732 view); 1732 view);
1733 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 1733 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
1734 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 1734 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1735 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 1735 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
1736 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, 1736 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F,
1737 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 1737 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
1738 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], 1738 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF],
1739 array); 1739 array);
1740 } 1740 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 } 1847 }
1848 var copy = view.sublist(0, view.length); 1848 var copy = view.sublist(0, view.length);
1849 Expect.isFalse(copy === view); 1849 Expect.isFalse(copy === view);
1850 Expect.isTrue(copy is Uint32List); 1850 Expect.isTrue(copy is Uint32List);
1851 Expect.equals(10, copy.length); 1851 Expect.equals(10, copy.length);
1852 Expect.listEquals(view, copy); 1852 Expect.listEquals(view, copy);
1853 var region = view.sublist(3, view.length - 3); 1853 var region = view.sublist(3, view.length - 3);
1854 Expect.isTrue(copy is Uint32List); 1854 Expect.isTrue(copy is Uint32List);
1855 Expect.equals(4, region.length); 1855 Expect.equals(4, region.length);
1856 Expect.listEquals([3, 4, 5, 6], region); 1856 Expect.listEquals([3, 4, 5, 6], region);
1857 view.setRange(3, 4, [0x100000001, 0, 1, 0xFFFFFFFF]); 1857 view.setRange(3, 7, [0x100000001, 0, 1, 0xFFFFFFFF]);
1858 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], 1858 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9],
1859 view); 1859 view);
1860 Expect.listEquals([-1, -1, -1, -1, 0, 0, 0, 0, 1860 Expect.listEquals([-1, -1, -1, -1, 0, 0, 0, 0,
1861 1, 0, 0, 0, 2, 0, 0, 0, 1861 1, 0, 0, 0, 2, 0, 0, 0,
1862 1, 0, 0, 0, 0, 0, 0, 0, 1862 1, 0, 0, 0, 0, 0, 0, 0,
1863 1, 0, 0, 0, -1, -1, -1, -1, 1863 1, 0, 0, 0, -1, -1, -1, -1,
1864 7, 0, 0, 0, 8, 0, 0, 0, 1864 7, 0, 0, 0, 8, 0, 0, 0,
1865 9, 0, 0, 0, -1, -1, -1, -1], 1865 9, 0, 0, 0, -1, -1, -1, -1],
1866 array); 1866 array);
1867 } 1867 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 } 2039 }
2040 var copy = view.sublist(0, view.length); 2040 var copy = view.sublist(0, view.length);
2041 Expect.isFalse(copy === view); 2041 Expect.isFalse(copy === view);
2042 Expect.isTrue(copy is Int64List); 2042 Expect.isTrue(copy is Int64List);
2043 Expect.equals(10, copy.length); 2043 Expect.equals(10, copy.length);
2044 Expect.listEquals(view, copy); 2044 Expect.listEquals(view, copy);
2045 var region = view.sublist(3, view.length - 3); 2045 var region = view.sublist(3, view.length - 3);
2046 Expect.isTrue(copy is Int64List); 2046 Expect.isTrue(copy is Int64List);
2047 Expect.equals(4, region.length); 2047 Expect.equals(4, region.length);
2048 Expect.listEquals([3, 4, 5, 6], region); 2048 Expect.listEquals([3, 4, 5, 6], region);
2049 view.setRange(3, 4, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); 2049 view.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]);
2050 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, 2050 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0,
2051 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], 2051 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9],
2052 view); 2052 view);
2053 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 2053 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
2054 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2054 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2055 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2055 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2056 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2056 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2057 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 2057 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
2058 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2058 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2059 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2059 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2201 } 2201 }
2202 var copy = view.sublist(0, view.length); 2202 var copy = view.sublist(0, view.length);
2203 Expect.isFalse(copy === view); 2203 Expect.isFalse(copy === view);
2204 Expect.isTrue(copy is Uint64List); 2204 Expect.isTrue(copy is Uint64List);
2205 Expect.equals(10, copy.length); 2205 Expect.equals(10, copy.length);
2206 Expect.listEquals(view, copy); 2206 Expect.listEquals(view, copy);
2207 var region = view.sublist(3, view.length - 3); 2207 var region = view.sublist(3, view.length - 3);
2208 Expect.isTrue(copy is Uint64List); 2208 Expect.isTrue(copy is Uint64List);
2209 Expect.equals(4, region.length); 2209 Expect.equals(4, region.length);
2210 Expect.listEquals([3, 4, 5, 6], region); 2210 Expect.listEquals([3, 4, 5, 6], region);
2211 view.setRange(3, 4, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); 2211 view.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]);
2212 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], 2212 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9],
2213 view); 2213 view);
2214 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, 2214 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1,
2215 0, 0, 0, 0, 0, 0, 0, 0, 2215 0, 0, 0, 0, 0, 0, 0, 0,
2216 1, 0, 0, 0, 0, 0, 0, 0, 2216 1, 0, 0, 0, 0, 0, 0, 0,
2217 2, 0, 0, 0, 0, 0, 0, 0, 2217 2, 0, 0, 0, 0, 0, 0, 0,
2218 1, 0, 0, 0, 0, 0, 0, 0, 2218 1, 0, 0, 0, 0, 0, 0, 0,
2219 0, 0, 0, 0, 0, 0, 0, 0, 2219 0, 0, 0, 0, 0, 0, 0, 0,
2220 1, 0, 0, 0, 0, 0, 0, 0, 2220 1, 0, 0, 0, 0, 0, 0, 0,
2221 -1, -1, -1, -1, -1, -1, -1, -1, 2221 -1, -1, -1, -1, -1, -1, -1, -1,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2313 } 2313 }
2314 var copy = view.sublist(0, view.length); 2314 var copy = view.sublist(0, view.length);
2315 Expect.isFalse(copy === view); 2315 Expect.isFalse(copy === view);
2316 Expect.isTrue(copy is Float32List); 2316 Expect.isTrue(copy is Float32List);
2317 Expect.equals(10, copy.length); 2317 Expect.equals(10, copy.length);
2318 Expect.listEquals(view, copy); 2318 Expect.listEquals(view, copy);
2319 var region = view.sublist(3, view.length - 3); 2319 var region = view.sublist(3, view.length - 3);
2320 Expect.isTrue(copy is Float32List); 2320 Expect.isTrue(copy is Float32List);
2321 Expect.equals(4, region.length); 2321 Expect.equals(4, region.length);
2322 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); 2322 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region);
2323 view.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); 2323 view.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]);
2324 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, 2324 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0,
2325 1.0, double.INFINITY, 7.0, 8.0, 9.0], 2325 1.0, double.INFINITY, 7.0, 8.0, 9.0],
2326 view); 2326 view);
2327 Expect.listEquals([0xBF800000, 0x00000000, 2327 Expect.listEquals([0xBF800000, 0x00000000,
2328 0x3F800000, 0x40000000, 2328 0x3F800000, 0x40000000,
2329 0xFF800000, 0x00000000, 2329 0xFF800000, 0x00000000,
2330 0x3F800000, 0x7F800000, 2330 0x3F800000, 0x7F800000,
2331 0x40E00000, 0x41000000, 2331 0x40E00000, 0x41000000,
2332 0x41100000, 0xBF800000], 2332 0x41100000, 0xBF800000],
2333 array); 2333 array);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2420 } 2420 }
2421 var copy = view.sublist(0, view.length); 2421 var copy = view.sublist(0, view.length);
2422 Expect.isFalse(copy === view); 2422 Expect.isFalse(copy === view);
2423 Expect.isTrue(copy is Float64List); 2423 Expect.isTrue(copy is Float64List);
2424 Expect.equals(10, copy.length); 2424 Expect.equals(10, copy.length);
2425 Expect.listEquals(view, copy); 2425 Expect.listEquals(view, copy);
2426 var region = view.sublist(3, view.length - 3); 2426 var region = view.sublist(3, view.length - 3);
2427 Expect.isTrue(copy is Float64List); 2427 Expect.isTrue(copy is Float64List);
2428 Expect.equals(4, region.length); 2428 Expect.equals(4, region.length);
2429 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); 2429 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region);
2430 view.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); 2430 view.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]);
2431 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, 2431 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0,
2432 1.0, double.INFINITY, 7.0, 8.0, 9.0], 2432 1.0, double.INFINITY, 7.0, 8.0, 9.0],
2433 view); 2433 view);
2434 Expect.listEquals([0xBFF0000000000000, 0x0000000000000000, 2434 Expect.listEquals([0xBFF0000000000000, 0x0000000000000000,
2435 0x3FF0000000000000, 0x4000000000000000, 2435 0x3FF0000000000000, 0x4000000000000000,
2436 0xFFF0000000000000, 0x0000000000000000, 2436 0xFFF0000000000000, 0x0000000000000000,
2437 0x3FF0000000000000, 0x7FF0000000000000, 2437 0x3FF0000000000000, 0x7FF0000000000000,
2438 0x401C000000000000, 0x4020000000000000, 2438 0x401C000000000000, 0x4020000000000000,
2439 0x4022000000000000, 0xBFF0000000000000], 2439 0x4022000000000000, 0xBFF0000000000000],
2440 array); 2440 array);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 2473
2474 testByteList(); 2474 testByteList();
2475 } 2475 }
2476 } 2476 }
2477 2477
2478 main() { 2478 main() {
2479 for (var i=0; i<1000; i++) { 2479 for (var i=0; i<1000; i++) {
2480 ByteArrayTest.testMain(); 2480 ByteArrayTest.testMain();
2481 } 2481 }
2482 } 2482 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698