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

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

Issue 14119004: Remove typeddata transferable constructors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « runtime/lib/typeddata.dart ('k') | tests/lib/typeddata/float32x4_list_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 Expect.isTrue(copy is Int8List); 84 Expect.isTrue(copy is Int8List);
85 Expect.equals(4, region.length); 85 Expect.equals(4, region.length);
86 Expect.listEquals([3, 4, 5, 6], region); 86 Expect.listEquals([3, 4, 5, 6], region);
87 array.setRange(3, 7, [-128, 0, 1, 127]); 87 array.setRange(3, 7, [-128, 0, 1, 127]);
88 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], 88 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9],
89 array); 89 array);
90 } 90 }
91 static testInt8List() { 91 static testInt8List() {
92 Expect.throws(() { new Int8List(-1); }, 92 Expect.throws(() { new Int8List(-1); },
93 (e) { return e is ArgumentError; }); 93 (e) { return e is ArgumentError; });
94 Expect.throws(() { new Int8List.transferable(-1); },
95 (e) { return e is ArgumentError; });
96 var array = new Int8List(10); 94 var array = new Int8List(10);
97 testInt8ListImpl(array); 95 testInt8ListImpl(array);
98 array = new Int8List.transferable(10);
99 testInt8ListImpl(array);
100 } 96 }
101 97
102 static testUint8ListImpl(Uint8List array) { 98 static testUint8ListImpl(Uint8List array) {
103 Expect.isTrue(array is List<int>); 99 Expect.isTrue(array is List<int>);
104 Expect.equals(10, array.length); 100 Expect.equals(10, array.length);
105 Expect.equals(1, array.elementSizeInBytes); 101 Expect.equals(1, array.elementSizeInBytes);
106 Expect.equals(10, array.lengthInBytes); 102 Expect.equals(10, array.lengthInBytes);
107 Expect.listEquals([0, 0, 0, 0, 0, 103 Expect.listEquals([0, 0, 0, 0, 0,
108 0, 0, 0, 0, 0], 104 0, 0, 0, 0, 0],
109 array); 105 array);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 Expect.equals(4, region.length); 159 Expect.equals(4, region.length);
164 Expect.listEquals([3, 4, 5, 6], region); 160 Expect.listEquals([3, 4, 5, 6], region);
165 array.setRange(3, 7, [257, 0, 1, 255]); 161 array.setRange(3, 7, [257, 0, 1, 255]);
166 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],
167 array); 163 array);
168 } 164 }
169 165
170 static testUint8List() { 166 static testUint8List() {
171 Expect.throws(() { new Uint8List(-1); }, 167 Expect.throws(() { new Uint8List(-1); },
172 (e) { return e is ArgumentError; }); 168 (e) { return e is ArgumentError; });
173 Expect.throws(() { new Uint8List.transferable(-1); },
174 (e) { return e is ArgumentError; });
175 var array = new Uint8List(10); 169 var array = new Uint8List(10);
176 testUint8ListImpl(array); 170 testUint8ListImpl(array);
177 array = new Uint8List.transferable(10);
178 testUint8ListImpl(array);
179 } 171 }
180 172
181 static testUint8ClampedListImpl(Uint8ClampedList array) { 173 static testUint8ClampedListImpl(Uint8ClampedList array) {
182 Expect.isTrue(array is List<int>); 174 Expect.isTrue(array is List<int>);
183 Expect.equals(10, array.length); 175 Expect.equals(10, array.length);
184 Expect.equals(1, array.elementSizeInBytes); 176 Expect.equals(1, array.elementSizeInBytes);
185 Expect.equals(10, array.lengthInBytes); 177 Expect.equals(10, array.lengthInBytes);
186 Expect.listEquals([0, 0, 0, 0, 0, 178 Expect.listEquals([0, 0, 0, 0, 0,
187 0, 0, 0, 0, 0], 179 0, 0, 0, 0, 0],
188 array); 180 array);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 Expect.isTrue(copy is Uint8ClampedList); 230 Expect.isTrue(copy is Uint8ClampedList);
239 Expect.equals(4, region.length); 231 Expect.equals(4, region.length);
240 Expect.listEquals([3, 4, 5, 6], region); 232 Expect.listEquals([3, 4, 5, 6], region);
241 array.setRange(3, 7, [257, 0, 1, 255]); 233 array.setRange(3, 7, [257, 0, 1, 255]);
242 Expect.listEquals([0, 1, 2, 255, 0, 1, 255, 7, 8, 9], array); 234 Expect.listEquals([0, 1, 2, 255, 0, 1, 255, 7, 8, 9], array);
243 } 235 }
244 236
245 static testUint8ClampedList() { 237 static testUint8ClampedList() {
246 Expect.throws(() { new Uint8ClampedList(-1); }, 238 Expect.throws(() { new Uint8ClampedList(-1); },
247 (e) { return e is ArgumentError; }); 239 (e) { return e is ArgumentError; });
248 Expect.throws(() { new Uint8ClampedList.transferable(-1); },
249 (e) { return e is ArgumentError; });
250 var array = new Uint8ClampedList(10); 240 var array = new Uint8ClampedList(10);
251 testUint8ClampedListImpl(array); 241 testUint8ClampedListImpl(array);
252 array = new Uint8ClampedList.transferable(10);
253 testUint8ClampedListImpl(array);
254 } 242 }
255 243
256 static testInt16ListImpl(Int16List array) { 244 static testInt16ListImpl(Int16List array) {
257 Expect.isTrue(array is List<int>); 245 Expect.isTrue(array is List<int>);
258 Expect.equals(10, array.length); 246 Expect.equals(10, array.length);
259 Expect.equals(2, array.elementSizeInBytes); 247 Expect.equals(2, array.elementSizeInBytes);
260 Expect.equals(20, array.lengthInBytes); 248 Expect.equals(20, array.lengthInBytes);
261 Expect.listEquals([0, 0, 0, 0, 0, 249 Expect.listEquals([0, 0, 0, 0, 0,
262 0, 0, 0, 0, 0], 250 0, 0, 0, 0, 0],
263 array); 251 array);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 Expect.equals(4, region.length); 317 Expect.equals(4, region.length);
330 Expect.listEquals([3, 4, 5, 6], region); 318 Expect.listEquals([3, 4, 5, 6], region);
331 array.setRange(3, 7, [-32768, 0, 1, 32767]); 319 array.setRange(3, 7, [-32768, 0, 1, 32767]);
332 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], 320 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9],
333 array); 321 array);
334 } 322 }
335 323
336 static testInt16List() { 324 static testInt16List() {
337 Expect.throws(() { new Int16List(-1); }, 325 Expect.throws(() { new Int16List(-1); },
338 (e) { return e is ArgumentError; }); 326 (e) { return e is ArgumentError; });
339 Expect.throws(() { new Int16List.transferable(-1); },
340 (e) { return e is ArgumentError; });
341 var array = new Int16List(10); 327 var array = new Int16List(10);
342 testInt16ListImpl(array); 328 testInt16ListImpl(array);
343 array = new Int16List.transferable(10);
344 testInt16ListImpl(array);
345 } 329 }
346 330
347 static testUint16ListImpl(Uint16List array) { 331 static testUint16ListImpl(Uint16List array) {
348 Expect.isTrue(array is List<int>); 332 Expect.isTrue(array is List<int>);
349 Expect.equals(10, array.length); 333 Expect.equals(10, array.length);
350 Expect.equals(2, array.elementSizeInBytes); 334 Expect.equals(2, array.elementSizeInBytes);
351 Expect.equals(20, array.lengthInBytes); 335 Expect.equals(20, array.lengthInBytes);
352 Expect.listEquals([0, 0, 0, 0, 0, 336 Expect.listEquals([0, 0, 0, 0, 0,
353 0, 0, 0, 0, 0], 337 0, 0, 0, 0, 0],
354 array); 338 array);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 Expect.equals(4, region.length); 392 Expect.equals(4, region.length);
409 Expect.listEquals([3, 4, 5, 6], region); 393 Expect.listEquals([3, 4, 5, 6], region);
410 array.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]); 394 array.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]);
411 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], 395 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9],
412 array); 396 array);
413 } 397 }
414 398
415 static testUint16List() { 399 static testUint16List() {
416 Expect.throws(() { new Uint16List(-1); }, 400 Expect.throws(() { new Uint16List(-1); },
417 (e) { return e is ArgumentError; }); 401 (e) { return e is ArgumentError; });
418 Expect.throws(() { new Uint16List.transferable(-1); },
419 (e) { return e is ArgumentError; });
420 var array = new Uint16List(10); 402 var array = new Uint16List(10);
421 testUint16ListImpl(array); 403 testUint16ListImpl(array);
422 array = new Uint16List.transferable(10);
423 testUint16ListImpl(array);
424 } 404 }
425 405
426 static testInt32ListImpl(Int32List array) { 406 static testInt32ListImpl(Int32List array) {
427 Expect.isTrue(array is List<int>); 407 Expect.isTrue(array is List<int>);
428 Expect.equals(10, array.length); 408 Expect.equals(10, array.length);
429 Expect.equals(4, array.elementSizeInBytes); 409 Expect.equals(4, array.elementSizeInBytes);
430 Expect.equals(40, array.lengthInBytes); 410 Expect.equals(40, array.lengthInBytes);
431 Expect.listEquals([0, 0, 0, 0, 0, 411 Expect.listEquals([0, 0, 0, 0, 0,
432 0, 0, 0, 0, 0], 412 0, 0, 0, 0, 0],
433 array); 413 array);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 Expect.equals(4, region.length); 485 Expect.equals(4, region.length);
506 Expect.listEquals([3, 4, 5, 6], region); 486 Expect.listEquals([3, 4, 5, 6], region);
507 array.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]); 487 array.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]);
508 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], 488 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9],
509 array); 489 array);
510 } 490 }
511 491
512 static testInt32List() { 492 static testInt32List() {
513 Expect.throws(() { new Int32List(-1); }, 493 Expect.throws(() { new Int32List(-1); },
514 (e) { return e is ArgumentError; }); 494 (e) { return e is ArgumentError; });
515 Expect.throws(() { new Int32List.transferable(-1); },
516 (e) { return e is ArgumentError; });
517 var array = new Int32List(10); 495 var array = new Int32List(10);
518 testInt32ListImpl(array); 496 testInt32ListImpl(array);
519 array = new Int32List.transferable(10);
520 testInt32ListImpl(array);
521 } 497 }
522 498
523 static testUint32ListImpl(Uint32List array) { 499 static testUint32ListImpl(Uint32List array) {
524 Expect.isTrue(array is List<int>); 500 Expect.isTrue(array is List<int>);
525 Expect.equals(10, array.length); 501 Expect.equals(10, array.length);
526 Expect.equals(4, array.elementSizeInBytes); 502 Expect.equals(4, array.elementSizeInBytes);
527 Expect.equals(40, array.lengthInBytes); 503 Expect.equals(40, array.lengthInBytes);
528 Expect.listEquals([0, 0, 0, 0, 0, 504 Expect.listEquals([0, 0, 0, 0, 0,
529 0, 0, 0, 0, 0], 505 0, 0, 0, 0, 0],
530 array); 506 array);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 array); 567 array);
592 } 568 }
593 569
594 static testUint32List() { 570 static testUint32List() {
595 Expect.throws(() { new Uint32List(-1); }, 571 Expect.throws(() { new Uint32List(-1); },
596 (e) { return e is ArgumentError; }); 572 (e) { return e is ArgumentError; });
597 Expect.throws(() { new Uint32List(-1); }, 573 Expect.throws(() { new Uint32List(-1); },
598 (e) { return e is ArgumentError; }); 574 (e) { return e is ArgumentError; });
599 var array = new Uint32List(10); 575 var array = new Uint32List(10);
600 testUint32ListImpl(array); 576 testUint32ListImpl(array);
601 array = new Uint32List.transferable(10);
602 testUint32ListImpl(array);
603 577
604 } 578 }
605 579
606 static testInt64ListImpl(Int64List array) { 580 static testInt64ListImpl(Int64List array) {
607 Expect.isTrue(array is List<int>); 581 Expect.isTrue(array is List<int>);
608 Expect.equals(10, array.length); 582 Expect.equals(10, array.length);
609 Expect.equals(8, array.elementSizeInBytes); 583 Expect.equals(8, array.elementSizeInBytes);
610 Expect.equals(80, array.lengthInBytes); 584 Expect.equals(80, array.lengthInBytes);
611 Expect.listEquals([0, 0, 0, 0, 0, 585 Expect.listEquals([0, 0, 0, 0, 0,
612 0, 0, 0, 0, 0], 586 0, 0, 0, 0, 0],
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 Expect.listEquals([3, 4, 5, 6], region); 660 Expect.listEquals([3, 4, 5, 6], region);
687 array.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); 661 array.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]);
688 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, 662 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0,
689 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], 663 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9],
690 array); 664 array);
691 } 665 }
692 666
693 static testInt64List() { 667 static testInt64List() {
694 Expect.throws(() { new Int64List(-1); }, 668 Expect.throws(() { new Int64List(-1); },
695 (e) { return e is ArgumentError; }); 669 (e) { return e is ArgumentError; });
696 Expect.throws(() { new Int64List.transferable(-1); },
697 (e) { return e is ArgumentError; });
698 var array = new Int64List(10); 670 var array = new Int64List(10);
699 testInt64ListImpl(array); 671 testInt64ListImpl(array);
700 array = new Int64List.transferable(10);
701 testInt64ListImpl(array);
702 } 672 }
703 673
704 static testUint64ListImpl(Uint64List array) { 674 static testUint64ListImpl(Uint64List array) {
705 Expect.isTrue(array is List<int>); 675 Expect.isTrue(array is List<int>);
706 Expect.equals(10, array.length); 676 Expect.equals(10, array.length);
707 Expect.equals(8, array.elementSizeInBytes); 677 Expect.equals(8, array.elementSizeInBytes);
708 Expect.equals(80, array.lengthInBytes); 678 Expect.equals(80, array.lengthInBytes);
709 Expect.listEquals([0, 0, 0, 0, 0, 679 Expect.listEquals([0, 0, 0, 0, 0,
710 0, 0, 0, 0, 0], 680 0, 0, 0, 0, 0],
711 array); 681 array);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 Expect.equals(4, region.length); 738 Expect.equals(4, region.length);
769 Expect.listEquals([3, 4, 5, 6], region); 739 Expect.listEquals([3, 4, 5, 6], region);
770 array.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); 740 array.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]);
771 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], 741 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9],
772 array); 742 array);
773 } 743 }
774 744
775 static testUint64List() { 745 static testUint64List() {
776 Expect.throws(() { new Uint64List(-1); }, 746 Expect.throws(() { new Uint64List(-1); },
777 (e) { return e is ArgumentError; }); 747 (e) { return e is ArgumentError; });
778 Expect.throws(() { new Uint64List.transferable(-1); },
779 (e) { return e is ArgumentError; });
780 var array = new Uint64List(10); 748 var array = new Uint64List(10);
781 testUint64ListImpl(array); 749 testUint64ListImpl(array);
782 array = new Uint64List.transferable(10);
783 testUint64ListImpl(array);
784 } 750 }
785 751
786 static testFloat32ListImpl(Float32List array) { 752 static testFloat32ListImpl(Float32List array) {
787 Expect.isTrue(array is List<double>); 753 Expect.isTrue(array is List<double>);
788 Expect.equals(10, array.length); 754 Expect.equals(10, array.length);
789 Expect.equals(4, array.elementSizeInBytes); 755 Expect.equals(4, array.elementSizeInBytes);
790 Expect.equals(40, array.lengthInBytes); 756 Expect.equals(40, array.lengthInBytes);
791 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, 757 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0,
792 0.0, 0.0, 0.0, 0.0, 0.0], 758 0.0, 0.0, 0.0, 0.0, 0.0],
793 array); 759 array);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); 803 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region);
838 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); 804 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]);
839 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, 805 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0,
840 1.0, double.INFINITY, 7.0, 8.0, 9.0], 806 1.0, double.INFINITY, 7.0, 8.0, 9.0],
841 array); 807 array);
842 } 808 }
843 809
844 static testFloat32List() { 810 static testFloat32List() {
845 Expect.throws(() { new Float32List(-1); }, 811 Expect.throws(() { new Float32List(-1); },
846 (e) { return e is ArgumentError; }); 812 (e) { return e is ArgumentError; });
847 Expect.throws(() { new Float32List.transferable(-1); },
848 (e) { return e is ArgumentError; });
849 var array = new Float32List(10); 813 var array = new Float32List(10);
850 testFloat32ListImpl(array); 814 testFloat32ListImpl(array);
851 array = new Float32List.transferable(10);
852 testFloat32ListImpl(array);
853 } 815 }
854 816
855 static testFloat64ListImpl(Float64List array) { 817 static testFloat64ListImpl(Float64List array) {
856 Expect.isTrue(array is List<double>); 818 Expect.isTrue(array is List<double>);
857 Expect.equals(10, array.length); 819 Expect.equals(10, array.length);
858 Expect.equals(8, array.elementSizeInBytes); 820 Expect.equals(8, array.elementSizeInBytes);
859 Expect.equals(80, array.lengthInBytes); 821 Expect.equals(80, array.lengthInBytes);
860 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, 822 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0,
861 0.0, 0.0, 0.0, 0.0, 0.0], 823 0.0, 0.0, 0.0, 0.0, 0.0],
862 array); 824 array);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, 870 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0,
909 1.0, double.INFINITY, 7.0, 8.0, 9.0], 871 1.0, double.INFINITY, 7.0, 8.0, 9.0],
910 array); 872 array);
911 } 873 }
912 874
913 static testFloat64List() { 875 static testFloat64List() {
914 Expect.throws(() { new Float64List(-1); }, 876 Expect.throws(() { new Float64List(-1); },
915 (e) { return e is ArgumentError; }); 877 (e) { return e is ArgumentError; });
916 var array = new Float64List(10); 878 var array = new Float64List(10);
917 testFloat64ListImpl(array); 879 testFloat64ListImpl(array);
918 array = new Float64List.transferable(10);
919 testFloat64ListImpl(array);
920 } 880 }
921 881
922 static testByteList() { 882 static testByteList() {
923 var array = new Uint8List(8); 883 var array = new Uint8List(8);
924 Expect.equals(8, array.length); 884 Expect.equals(8, array.length);
925 Expect.equals(8, array.lengthInBytes); 885 Expect.equals(8, array.lengthInBytes);
926 var byte_array = new ByteData.view(array.buffer); 886 var byte_array = new ByteData.view(array.buffer);
927 Expect.equals(8, byte_array.lengthInBytes); 887 Expect.equals(8, byte_array.lengthInBytes);
928 Expect.throws(() { byte_array.getInt8(-1); }, 888 Expect.throws(() { byte_array.getInt8(-1); },
929 (e) { return e is RangeError; }); 889 (e) { return e is RangeError; });
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 Expect.listEquals([3, 4, 5, 6], region); 1141 Expect.listEquals([3, 4, 5, 6], region);
1182 view.setRange(3, 7, [-128, 0, 1, 127]); 1142 view.setRange(3, 7, [-128, 0, 1, 127]);
1183 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], 1143 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9],
1184 view); 1144 view);
1185 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF], 1145 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF],
1186 array); 1146 array);
1187 } 1147 }
1188 static testInt8ListView() { 1148 static testInt8ListView() {
1189 var array = new Uint8List(12); 1149 var array = new Uint8List(12);
1190 testInt8ListViewImpl(array); 1150 testInt8ListViewImpl(array);
1191 array = new Uint8List.transferable(12);
1192 testInt8ListViewImpl(array);
1193 } 1151 }
1194 1152
1195 static testUint8ListViewImpl(var array) { 1153 static testUint8ListViewImpl(var array) {
1196 Expect.isTrue(array is List<int>); 1154 Expect.isTrue(array is List<int>);
1197 Expect.equals(12, array.length); 1155 Expect.equals(12, array.length);
1198 Expect.equals(1, array.elementSizeInBytes); 1156 Expect.equals(1, array.elementSizeInBytes);
1199 Expect.equals(12, array.lengthInBytes); 1157 Expect.equals(12, array.lengthInBytes);
1200 for (int i = 0; i < array.length; ++i) { 1158 for (int i = 0; i < array.length; ++i) {
1201 array[i] = -1; 1159 array[i] = -1;
1202 } 1160 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 Expect.equals(4, region.length); 1249 Expect.equals(4, region.length);
1292 Expect.listEquals([3, 4, 5, 6], region); 1250 Expect.listEquals([3, 4, 5, 6], region);
1293 view.setRange(3, 7, [257, 0, 1, 255]); 1251 view.setRange(3, 7, [257, 0, 1, 255]);
1294 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], 1252 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9],
1295 view); 1253 view);
1296 } 1254 }
1297 1255
1298 static testUint8ListView() { 1256 static testUint8ListView() {
1299 var array = new Int8List(12); 1257 var array = new Int8List(12);
1300 testUint8ListViewImpl(array); 1258 testUint8ListViewImpl(array);
1301 array = new Int8List.transferable(12);
1302 testUint8ListViewImpl(array);
1303 } 1259 }
1304 1260
1305 static testInt16ListViewImpl(var array) { 1261 static testInt16ListViewImpl(var array) {
1306 Expect.equals(24, array.length); 1262 Expect.equals(24, array.length);
1307 Expect.equals(1, array.elementSizeInBytes); 1263 Expect.equals(1, array.elementSizeInBytes);
1308 Expect.equals(24, array.lengthInBytes); 1264 Expect.equals(24, array.lengthInBytes);
1309 for (int i = 0; i < array.length; ++i) { 1265 for (int i = 0; i < array.length; ++i) {
1310 array[i] = 0xFF; 1266 array[i] = 0xFF;
1311 } 1267 }
1312 Expect.throws(() { new Int16List.view(array.buffer, -1); }, 1268 Expect.throws(() { new Int16List.view(array.buffer, -1); },
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 view); 1383 view);
1428 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 1384 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
1429 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F, 1385 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F,
1430 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], 1386 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF],
1431 array); 1387 array);
1432 } 1388 }
1433 1389
1434 static testInt16ListView() { 1390 static testInt16ListView() {
1435 var array = new Uint8List(24); 1391 var array = new Uint8List(24);
1436 testInt16ListViewImpl(array); 1392 testInt16ListViewImpl(array);
1437 array = new Uint8List.transferable(24);
1438 testInt16ListViewImpl(array);
1439 } 1393 }
1440 1394
1441 static testUint16ListViewImpl(var array) { 1395 static testUint16ListViewImpl(var array) {
1442 Expect.isTrue(array is List<int>); 1396 Expect.isTrue(array is List<int>);
1443 Expect.equals(24, array.length); 1397 Expect.equals(24, array.length);
1444 Expect.equals(1, array.elementSizeInBytes); 1398 Expect.equals(1, array.elementSizeInBytes);
1445 Expect.equals(24, array.lengthInBytes); 1399 Expect.equals(24, array.lengthInBytes);
1446 for (int i = 0; i < array.length; ++i) { 1400 for (int i = 0; i < array.length; ++i) {
1447 array[i] = -1; 1401 array[i] = -1;
1448 } 1402 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 view); 1496 view);
1543 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, 1497 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0,
1544 1, 0, 0, 0, 1, 0, -1, -1, 1498 1, 0, 0, 0, 1, 0, -1, -1,
1545 7, 0, 8, 0, 9, 0, -1, -1], 1499 7, 0, 8, 0, 9, 0, -1, -1],
1546 array); 1500 array);
1547 } 1501 }
1548 1502
1549 static testUint16ListView() { 1503 static testUint16ListView() {
1550 var array = new Int8List(24); 1504 var array = new Int8List(24);
1551 testUint16ListViewImpl(array); 1505 testUint16ListViewImpl(array);
1552 array = new Int8List.transferable(24);
1553 testUint16ListViewImpl(array);
1554 } 1506 }
1555 1507
1556 static testInt32ListView() { 1508 static testInt32ListView() {
1557 var array = new Uint8List(48); 1509 var array = new Uint8List(48);
1558 Expect.equals(48, array.length); 1510 Expect.equals(48, array.length);
1559 Expect.equals(1, array.elementSizeInBytes); 1511 Expect.equals(1, array.elementSizeInBytes);
1560 Expect.equals(48, array.lengthInBytes); 1512 Expect.equals(48, array.lengthInBytes);
1561 for (int i = 0; i < array.length; ++i) { 1513 for (int i = 0; i < array.length; ++i) {
1562 array[i] = 0xFF; 1514 array[i] = 0xFF;
1563 } 1515 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 1, 0, 0, 0, 0, 0, 0, 0, 1780 1, 0, 0, 0, 0, 0, 0, 0,
1829 1, 0, 0, 0, -1, -1, -1, -1, 1781 1, 0, 0, 0, -1, -1, -1, -1,
1830 7, 0, 0, 0, 8, 0, 0, 0, 1782 7, 0, 0, 0, 8, 0, 0, 0,
1831 9, 0, 0, 0, -1, -1, -1, -1], 1783 9, 0, 0, 0, -1, -1, -1, -1],
1832 array); 1784 array);
1833 } 1785 }
1834 1786
1835 static testUint32ListView() { 1787 static testUint32ListView() {
1836 var array = new Int8List(48); 1788 var array = new Int8List(48);
1837 testUint32ListViewImpl(array); 1789 testUint32ListViewImpl(array);
1838 array = new Int8List.transferable(48);
1839 testUint32ListViewImpl(array);
1840 } 1790 }
1841 1791
1842 static testInt64ListViewImpl(var array) { 1792 static testInt64ListViewImpl(var array) {
1843 Expect.equals(96, array.length); 1793 Expect.equals(96, array.length);
1844 Expect.equals(1, array.elementSizeInBytes); 1794 Expect.equals(1, array.elementSizeInBytes);
1845 Expect.equals(96, array.lengthInBytes); 1795 Expect.equals(96, array.lengthInBytes);
1846 for (int i = 0; i < array.length; ++i) { 1796 for (int i = 0; i < array.length; ++i) {
1847 array[i] = 0xFF; 1797 array[i] = 0xFF;
1848 } 1798 }
1849 Expect.throws(() { new Int64List.view(array.buffer, -1); }, 1799 Expect.throws(() { new Int64List.view(array.buffer, -1); },
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1975 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2026 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1976 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2027 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1977 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2028 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], 1978 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
2029 array); 1979 array);
2030 } 1980 }
2031 1981
2032 static testInt64ListView() { 1982 static testInt64ListView() {
2033 var array = new Uint8List(96); 1983 var array = new Uint8List(96);
2034 testInt64ListViewImpl(array); 1984 testInt64ListViewImpl(array);
2035 array = new Uint8List.transferable(96);
2036 testInt64ListViewImpl(array);
2037 } 1985 }
2038 1986
2039 static testUint64ListViewImpl(var array) { 1987 static testUint64ListViewImpl(var array) {
2040 Expect.isTrue(array is List<int>); 1988 Expect.isTrue(array is List<int>);
2041 Expect.equals(96, array.length); 1989 Expect.equals(96, array.length);
2042 Expect.equals(1, array.elementSizeInBytes); 1990 Expect.equals(1, array.elementSizeInBytes);
2043 Expect.equals(96, array.lengthInBytes); 1991 Expect.equals(96, array.lengthInBytes);
2044 for (int i = 0; i < array.length; ++i) { 1992 for (int i = 0; i < array.length; ++i) {
2045 array[i] = -1; 1993 array[i] = -1;
2046 } 1994 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 7, 0, 0, 0, 0, 0, 0, 0, 2132 7, 0, 0, 0, 0, 0, 0, 0,
2185 8, 0, 0, 0, 0, 0, 0, 0, 2133 8, 0, 0, 0, 0, 0, 0, 0,
2186 9, 0, 0, 0, 0, 0, 0, 0, 2134 9, 0, 0, 0, 0, 0, 0, 0,
2187 -1, -1, -1, -1, -1, -1, -1, -1], 2135 -1, -1, -1, -1, -1, -1, -1, -1],
2188 array); 2136 array);
2189 } 2137 }
2190 2138
2191 static testUint64ListView() { 2139 static testUint64ListView() {
2192 var array = new Int8List(96); 2140 var array = new Int8List(96);
2193 testUint64ListViewImpl(array); 2141 testUint64ListViewImpl(array);
2194 array = new Int8List.transferable(96);
2195 testUint64ListViewImpl(array);
2196 } 2142 }
2197 2143
2198 static testFloat32ListViewImpl(var array) { 2144 static testFloat32ListViewImpl(var array) {
2199 Expect.isTrue(array is List<int>); 2145 Expect.isTrue(array is List<int>);
2200 Expect.equals(12, array.length); 2146 Expect.equals(12, array.length);
2201 Expect.equals(4, array.elementSizeInBytes); 2147 Expect.equals(4, array.elementSizeInBytes);
2202 Expect.equals(48, array.lengthInBytes); 2148 Expect.equals(48, array.lengthInBytes);
2203 for (int i = 0; i < array.length; ++i) { 2149 for (int i = 0; i < array.length; ++i) {
2204 array[i] = 0xBF800000; 2150 array[i] = 0xBF800000;
2205 } 2151 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 0xFF800000, 0x00000000, 2235 0xFF800000, 0x00000000,
2290 0x3F800000, 0x7F800000, 2236 0x3F800000, 0x7F800000,
2291 0x40E00000, 0x41000000, 2237 0x40E00000, 0x41000000,
2292 0x41100000, 0xBF800000], 2238 0x41100000, 0xBF800000],
2293 array); 2239 array);
2294 } 2240 }
2295 2241
2296 static testFloat32ListView() { 2242 static testFloat32ListView() {
2297 var array = new Uint32List(12); 2243 var array = new Uint32List(12);
2298 testFloat32ListViewImpl(array); 2244 testFloat32ListViewImpl(array);
2299 array = new Uint32List.transferable(12);
2300 testFloat32ListViewImpl(array);
2301 } 2245 }
2302 2246
2303 static testFloat64ListViewImpl(var array) { 2247 static testFloat64ListViewImpl(var array) {
2304 Expect.isTrue(array is List<int>); 2248 Expect.isTrue(array is List<int>);
2305 Expect.equals(12, array.length); 2249 Expect.equals(12, array.length);
2306 Expect.equals(8, array.elementSizeInBytes); 2250 Expect.equals(8, array.elementSizeInBytes);
2307 Expect.equals(96, array.lengthInBytes); 2251 Expect.equals(96, array.lengthInBytes);
2308 for (int i = 0; i < array.length; ++i) { 2252 for (int i = 0; i < array.length; ++i) {
2309 array[i] = 0xBFF0000000000000; 2253 array[i] = 0xBFF0000000000000;
2310 } 2254 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 0xFFF0000000000000, 0x0000000000000000, 2338 0xFFF0000000000000, 0x0000000000000000,
2395 0x3FF0000000000000, 0x7FF0000000000000, 2339 0x3FF0000000000000, 0x7FF0000000000000,
2396 0x401C000000000000, 0x4020000000000000, 2340 0x401C000000000000, 0x4020000000000000,
2397 0x4022000000000000, 0xBFF0000000000000], 2341 0x4022000000000000, 0xBFF0000000000000],
2398 array); 2342 array);
2399 } 2343 }
2400 2344
2401 static testFloat64ListView() { 2345 static testFloat64ListView() {
2402 var array = new Uint64List(12); 2346 var array = new Uint64List(12);
2403 testFloat64ListViewImpl(array); 2347 testFloat64ListViewImpl(array);
2404 array = new Uint64List.transferable(12);
2405 testFloat64ListViewImpl(array);
2406 } 2348 }
2407 2349
2408 static testMain() { 2350 static testMain() {
2409 testInt8List(); 2351 testInt8List();
2410 testUint8List(); 2352 testUint8List();
2411 testUint8ClampedList(); 2353 testUint8ClampedList();
2412 testInt16List(); 2354 testInt16List();
2413 testUint16List(); 2355 testUint16List();
2414 testInt32List(); 2356 testInt32List();
2415 testUint32List(); 2357 testUint32List();
(...skipping 15 matching lines...) Expand all
2431 2373
2432 testByteList(); 2374 testByteList();
2433 } 2375 }
2434 } 2376 }
2435 2377
2436 main() { 2378 main() {
2437 for (var i=0; i<1000; i++) { 2379 for (var i=0; i<1000; i++) {
2438 ByteArrayTest.testMain(); 2380 ByteArrayTest.testMain();
2439 } 2381 }
2440 } 2382 }
OLDNEW
« no previous file with comments | « runtime/lib/typeddata.dart ('k') | tests/lib/typeddata/float32x4_list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698