OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Library tag to be able to run in html test framework. | 5 // Library tag to be able to run in html test framework. |
6 library byte_array_test; | 6 library byte_array_test; |
7 | 7 |
8 import 'dart:scalarlist'; | 8 import 'dart:scalarlist'; |
9 | 9 |
10 class ByteArrayTest { | 10 class ByteArrayTest { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 array); | 66 array); |
67 for (int i = 0; i < array.length; ++i) { | 67 for (int i = 0; i < array.length; ++i) { |
68 array[i] = -0x80 + i; | 68 array[i] = -0x80 + i; |
69 } | 69 } |
70 Expect.listEquals([-128, -127, -126, -125, -124, | 70 Expect.listEquals([-128, -127, -126, -125, -124, |
71 -123, -122, -121, -120, -119], | 71 -123, -122, -121, -120, -119], |
72 array); | 72 array); |
73 for (int i = 0; i < array.length; ++i) { | 73 for (int i = 0; i < array.length; ++i) { |
74 array[i] = i; | 74 array[i] = i; |
75 } | 75 } |
76 var copy = array.getRange(0, array.length); | 76 var copy = array.sublist(0, array.length); |
77 Expect.isFalse(copy === array); | 77 Expect.isFalse(copy === array); |
78 Expect.isTrue(copy is Int8List); | 78 Expect.isTrue(copy is Int8List); |
79 Expect.equals(10, copy.length); | 79 Expect.equals(10, copy.length); |
80 Expect.listEquals(array, copy); | 80 Expect.listEquals(array, copy); |
81 var empty = array.getRange(array.length, 0); | 81 var empty = array.sublist(array.length, array.length); |
82 Expect.equals(0, empty.length); | 82 Expect.equals(0, empty.length); |
83 var region = array.getRange(3, array.length - 6); | 83 empty = array.sublist(array.length); |
| 84 Expect.equals(0, empty.length); |
| 85 |
| 86 var region = array.sublist(3, array.length - 3); |
84 Expect.isTrue(copy is Int8List); | 87 Expect.isTrue(copy is Int8List); |
85 Expect.equals(4, region.length); | 88 Expect.equals(4, region.length); |
86 Expect.listEquals([3, 4, 5, 6], region); | 89 Expect.listEquals([3, 4, 5, 6], region); |
87 array.setRange(3, 4, [-128, 0, 1, 127]); | 90 array.setRange(3, 4, [-128, 0, 1, 127]); |
88 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], | 91 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], |
89 array); | 92 array); |
90 } | 93 } |
91 static testInt8List() { | 94 static testInt8List() { |
92 Expect.throws(() { new Int8List(-1); }, | 95 Expect.throws(() { new Int8List(-1); }, |
93 (e) { return e is ArgumentError; }); | 96 (e) { return e is ArgumentError; }); |
94 Expect.throws(() { new Int8List.transferable(-1); }, | 97 Expect.throws(() { new Int8List.transferable(-1); }, |
95 (e) { return e is ArgumentError; }); | 98 (e) { return e is ArgumentError; }); |
96 var array = new Int8List(10); | 99 var array = new Int8List(10); |
97 testInt8ListImpl(array); | 100 testInt8ListImpl(array); |
98 array = new Int8List.transferable(10); | 101 array = new Int8List.transferable(10); |
99 testInt8ListImpl(array); | 102 testInt8ListImpl(array); |
100 } | 103 } |
101 | 104 |
102 static testUint8ListImpl(Uint8List array) { | 105 static testUint8ListImpl(Uint8List array) { |
103 Expect.isTrue(array is List<int>); | 106 Expect.isTrue(array is List<int>); |
104 Expect.equals(10, array.length); | 107 Expect.equals(10, array.length); |
105 Expect.equals(1, array.bytesPerElement()); | 108 Expect.equals(1, array.bytesPerElement()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 array); | 148 array); |
146 for (int i = 0; i < array.length; ++i) { | 149 for (int i = 0; i < array.length; ++i) { |
147 array[i] = 0xFF - i; | 150 array[i] = 0xFF - i; |
148 } | 151 } |
149 Expect.listEquals([0xFF, 0xFE, 0xFD, 0xFC, 0xFB, | 152 Expect.listEquals([0xFF, 0xFE, 0xFD, 0xFC, 0xFB, |
150 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], | 153 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], |
151 array); | 154 array); |
152 for (int i = 0; i < array.length; ++i) { | 155 for (int i = 0; i < array.length; ++i) { |
153 array[i] = i; | 156 array[i] = i; |
154 } | 157 } |
155 var copy = array.getRange(0, array.length); | 158 var copy = array.sublist(0, array.length); |
156 Expect.isFalse(copy === array); | 159 Expect.isFalse(copy === array); |
157 Expect.isTrue(copy is Uint8List); | 160 Expect.isTrue(copy is Uint8List); |
158 Expect.equals(10, copy.length); | 161 Expect.equals(10, copy.length); |
159 Expect.listEquals(array, copy); | 162 Expect.listEquals(array, copy); |
160 var empty = array.getRange(array.length, 0); | 163 var empty = array.sublist(array.length, array.length); |
161 Expect.equals(0, empty.length); | 164 Expect.equals(0, empty.length); |
162 var region = array.getRange(3, array.length - 6); | 165 empty = array.sublist(array.length); |
| 166 Expect.equals(0, empty.length); |
| 167 |
| 168 var region = array.sublist(3, array.length - 3); |
163 Expect.isTrue(copy is Uint8List); | 169 Expect.isTrue(copy is Uint8List); |
164 Expect.equals(4, region.length); | 170 Expect.equals(4, region.length); |
165 Expect.listEquals([3, 4, 5, 6], region); | 171 Expect.listEquals([3, 4, 5, 6], region); |
166 array.setRange(3, 4, [257, 0, 1, 255]); | 172 array.setRange(3, 4, [257, 0, 1, 255]); |
167 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], | 173 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], |
168 array); | 174 array); |
169 } | 175 } |
170 | 176 |
171 static testUint8List() { | 177 static testUint8List() { |
172 Expect.throws(() { new Uint8List(-1); }, | 178 Expect.throws(() { new Uint8List(-1); }, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 array); | 228 array); |
223 for (int i = 0; i < array.length; ++i) { | 229 for (int i = 0; i < array.length; ++i) { |
224 array[i] = 0xFF - i; | 230 array[i] = 0xFF - i; |
225 } | 231 } |
226 Expect.listEquals([0xFF, 0xFE, 0xFD, 0xFC, 0xFB, | 232 Expect.listEquals([0xFF, 0xFE, 0xFD, 0xFC, 0xFB, |
227 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], | 233 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], |
228 array); | 234 array); |
229 for (int i = 0; i < array.length; ++i) { | 235 for (int i = 0; i < array.length; ++i) { |
230 array[i] = i; | 236 array[i] = i; |
231 } | 237 } |
232 var copy = array.getRange(0, array.length); | 238 var copy = array.sublist(0, array.length); |
233 Expect.isFalse(copy === array); | 239 Expect.isFalse(copy === array); |
234 Expect.isTrue(copy is Uint8ClampedList); | 240 Expect.isTrue(copy is Uint8ClampedList); |
235 Expect.equals(10, copy.length); | 241 Expect.equals(10, copy.length); |
236 Expect.listEquals(array, copy); | 242 Expect.listEquals(array, copy); |
237 var empty = array.getRange(array.length, 0); | 243 var empty = array.sublist(array.length, array.length); |
238 Expect.equals(0, empty.length); | 244 Expect.equals(0, empty.length); |
239 var region = array.getRange(3, array.length - 6); | 245 empty = array.sublist(array.length); |
| 246 Expect.equals(0, empty.length); |
| 247 |
| 248 var region = array.sublist(3, array.length - 3); |
240 Expect.isTrue(copy is Uint8ClampedList); | 249 Expect.isTrue(copy is Uint8ClampedList); |
241 Expect.equals(4, region.length); | 250 Expect.equals(4, region.length); |
242 Expect.listEquals([3, 4, 5, 6], region); | 251 Expect.listEquals([3, 4, 5, 6], region); |
243 array.setRange(3, 4, [257, 0, 1, 255]); | 252 array.setRange(3, 4, [257, 0, 1, 255]); |
244 Expect.listEquals([0, 1, 2, 255, 0, 1, 255, 7, 8, 9], array); | 253 Expect.listEquals([0, 1, 2, 255, 0, 1, 255, 7, 8, 9], array); |
245 } | 254 } |
246 | 255 |
247 static testUint8ClampedList() { | 256 static testUint8ClampedList() { |
248 Expect.throws(() { new Uint8ClampedList(-1); }, | 257 Expect.throws(() { new Uint8ClampedList(-1); }, |
249 (e) { return e is ArgumentError; }); | 258 (e) { return e is ArgumentError; }); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 array); | 322 array); |
314 for (int i = 0; i < array.length; ++i) { | 323 for (int i = 0; i < array.length; ++i) { |
315 array[i] = -0x8000 + i; | 324 array[i] = -0x8000 + i; |
316 } | 325 } |
317 Expect.listEquals([-0x8000, -0x7FFF, -0x7FFE, -0x7FFD, -0x7FFC, | 326 Expect.listEquals([-0x8000, -0x7FFF, -0x7FFE, -0x7FFD, -0x7FFC, |
318 -0x7FFB, -0x7FFA, -0x7FF9, -0x7FF8, -0x7FF7], | 327 -0x7FFB, -0x7FFA, -0x7FF9, -0x7FF8, -0x7FF7], |
319 array); | 328 array); |
320 for (int i = 0; i < array.length; ++i) { | 329 for (int i = 0; i < array.length; ++i) { |
321 array[i] = i; | 330 array[i] = i; |
322 } | 331 } |
323 var copy = array.getRange(0, array.length); | 332 var copy = array.sublist(0, array.length); |
324 Expect.isFalse(copy === array); | 333 Expect.isFalse(copy === array); |
325 Expect.isTrue(copy is Int16List); | 334 Expect.isTrue(copy is Int16List); |
326 Expect.equals(10, copy.length); | 335 Expect.equals(10, copy.length); |
327 Expect.listEquals(array, copy); | 336 Expect.listEquals(array, copy); |
328 var empty = array.getRange(array.length, 0); | 337 var empty = array.sublist(array.length, array.length); |
329 Expect.equals(0, empty.length); | 338 Expect.equals(0, empty.length); |
330 var region = array.getRange(3, array.length - 6); | 339 empty = array.sublist(array.length); |
| 340 Expect.equals(0, empty.length); |
| 341 |
| 342 var region = array.sublist(3, array.length - 3); |
331 Expect.isTrue(copy is Int16List); | 343 Expect.isTrue(copy is Int16List); |
332 Expect.equals(4, region.length); | 344 Expect.equals(4, region.length); |
333 Expect.listEquals([3, 4, 5, 6], region); | 345 Expect.listEquals([3, 4, 5, 6], region); |
334 array.setRange(3, 4, [-32768, 0, 1, 32767]); | 346 array.setRange(3, 4, [-32768, 0, 1, 32767]); |
335 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], | 347 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], |
336 array); | 348 array); |
337 } | 349 } |
338 | 350 |
339 static testInt16List() { | 351 static testInt16List() { |
340 Expect.throws(() { new Int16List(-1); }, | 352 Expect.throws(() { new Int16List(-1); }, |
341 (e) { return e is ArgumentError; }); | 353 (e) { return e is ArgumentError; }); |
342 Expect.throws(() { new Int16List.transferable(-1); }, | 354 Expect.throws(() { new Int16List.transferable(-1); }, |
343 (e) { return e is ArgumentError; }); | 355 (e) { return e is ArgumentError; }); |
344 var array = new Int16List(10); | 356 var array = new Int16List(10); |
345 testInt16ListImpl(array); | 357 testInt16ListImpl(array); |
346 array = new Int16List.transferable(10); | 358 array = new Int16List.transferable(10); |
347 testInt16ListImpl(array); | 359 testInt16ListImpl(array); |
348 } | 360 } |
349 | 361 |
350 static testUint16ListImpl(Uint16List array) { | 362 static testUint16ListImpl(Uint16List array) { |
351 Expect.isTrue(array is List<int>); | 363 Expect.isTrue(array is List<int>); |
352 Expect.equals(10, array.length); | 364 Expect.equals(10, array.length); |
353 Expect.equals(2, array.bytesPerElement()); | 365 Expect.equals(2, array.bytesPerElement()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 array); | 405 array); |
394 for (int i = 0; i < array.length; ++i) { | 406 for (int i = 0; i < array.length; ++i) { |
395 array[i] = 0xFFFF - i; | 407 array[i] = 0xFFFF - i; |
396 } | 408 } |
397 Expect.listEquals([0xFFFF, 0xFFFE, 0xFFFD, 0xFFFC, 0xFFFB, | 409 Expect.listEquals([0xFFFF, 0xFFFE, 0xFFFD, 0xFFFC, 0xFFFB, |
398 0xFFFA, 0xFFF9, 0xFFF8, 0xFFF7, 0xFFF6], | 410 0xFFFA, 0xFFF9, 0xFFF8, 0xFFF7, 0xFFF6], |
399 array); | 411 array); |
400 for (int i = 0; i < array.length; ++i) { | 412 for (int i = 0; i < array.length; ++i) { |
401 array[i] = i; | 413 array[i] = i; |
402 } | 414 } |
403 var copy = array.getRange(0, array.length); | 415 var copy = array.sublist(0, array.length); |
404 Expect.isFalse(copy === array); | 416 Expect.isFalse(copy === array); |
405 Expect.isTrue(copy is Uint16List); | 417 Expect.isTrue(copy is Uint16List); |
406 Expect.equals(10, copy.length); | 418 Expect.equals(10, copy.length); |
407 Expect.listEquals(array, copy); | 419 Expect.listEquals(array, copy); |
408 var empty = array.getRange(array.length, 0); | 420 var empty = array.sublist(array.length, array.length); |
409 Expect.equals(0, empty.length); | 421 Expect.equals(0, empty.length); |
410 var region = array.getRange(3, array.length - 6); | 422 empty = array.sublist(array.length); |
| 423 Expect.equals(0, empty.length); |
| 424 |
| 425 var region = array.sublist(3, array.length - 3); |
411 Expect.isTrue(copy is Uint16List); | 426 Expect.isTrue(copy is Uint16List); |
412 Expect.equals(4, region.length); | 427 Expect.equals(4, region.length); |
413 Expect.listEquals([3, 4, 5, 6], region); | 428 Expect.listEquals([3, 4, 5, 6], region); |
414 array.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); | 429 array.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); |
415 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], | 430 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], |
416 array); | 431 array); |
417 } | 432 } |
418 | 433 |
419 static testUint16List() { | 434 static testUint16List() { |
420 Expect.throws(() { new Uint16List(-1); }, | 435 Expect.throws(() { new Uint16List(-1); }, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } | 506 } |
492 Expect.listEquals([-0x80000000, -0x7FFFFFFF, | 507 Expect.listEquals([-0x80000000, -0x7FFFFFFF, |
493 -0x7FFFFFFE, -0x7FFFFFFD, | 508 -0x7FFFFFFE, -0x7FFFFFFD, |
494 -0x7FFFFFFC, -0x7FFFFFFB, | 509 -0x7FFFFFFC, -0x7FFFFFFB, |
495 -0x7FFFFFFA, -0x7FFFFFF9, | 510 -0x7FFFFFFA, -0x7FFFFFF9, |
496 -0x7FFFFFF8, -0x7FFFFFF7], | 511 -0x7FFFFFF8, -0x7FFFFFF7], |
497 array); | 512 array); |
498 for (int i = 0; i < array.length; ++i) { | 513 for (int i = 0; i < array.length; ++i) { |
499 array[i] = i; | 514 array[i] = i; |
500 } | 515 } |
501 var copy = array.getRange(0, array.length); | 516 var copy = array.sublist(0, array.length); |
502 Expect.isFalse(copy === array); | 517 Expect.isFalse(copy === array); |
503 Expect.isTrue(copy is Int32List); | 518 Expect.isTrue(copy is Int32List); |
504 Expect.equals(10, copy.length); | 519 Expect.equals(10, copy.length); |
505 Expect.listEquals(array, copy); | 520 Expect.listEquals(array, copy); |
506 var empty = array.getRange(array.length, 0); | 521 var empty = array.sublist(array.length, array.length); |
507 Expect.equals(0, empty.length); | 522 Expect.equals(0, empty.length); |
508 var region = array.getRange(3, array.length - 6); | 523 empty = array.sublist(array.length); |
| 524 Expect.equals(0, empty.length); |
| 525 |
| 526 var region = array.sublist(3, array.length - 3); |
509 Expect.isTrue(copy is Int32List); | 527 Expect.isTrue(copy is Int32List); |
510 Expect.equals(4, region.length); | 528 Expect.equals(4, region.length); |
511 Expect.listEquals([3, 4, 5, 6], region); | 529 Expect.listEquals([3, 4, 5, 6], region); |
512 array.setRange(3, 4, [-0x80000000, 0, 1, 0x7FFFFFFF]); | 530 array.setRange(3, 4, [-0x80000000, 0, 1, 0x7FFFFFFF]); |
513 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], | 531 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], |
514 array); | 532 array); |
515 } | 533 } |
516 | 534 |
517 static testInt32List() { | 535 static testInt32List() { |
518 Expect.throws(() { new Int32List(-1); }, | 536 Expect.throws(() { new Int32List(-1); }, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 } | 592 } |
575 Expect.listEquals([0xFFFFFFFF, 0xFFFFFFFE, | 593 Expect.listEquals([0xFFFFFFFF, 0xFFFFFFFE, |
576 0xFFFFFFFD, 0xFFFFFFFC, | 594 0xFFFFFFFD, 0xFFFFFFFC, |
577 0xFFFFFFFB, 0xFFFFFFFA, | 595 0xFFFFFFFB, 0xFFFFFFFA, |
578 0xFFFFFFF9, 0xFFFFFFF8, | 596 0xFFFFFFF9, 0xFFFFFFF8, |
579 0xFFFFFFF7, 0xFFFFFFF6], | 597 0xFFFFFFF7, 0xFFFFFFF6], |
580 array); | 598 array); |
581 for (int i = 0; i < array.length; ++i) { | 599 for (int i = 0; i < array.length; ++i) { |
582 array[i] = i; | 600 array[i] = i; |
583 } | 601 } |
584 var copy = array.getRange(0, array.length); | 602 var copy = array.sublist(0, array.length); |
585 Expect.isFalse(copy === array); | 603 Expect.isFalse(copy === array); |
586 Expect.isTrue(copy is Uint32List); | 604 Expect.isTrue(copy is Uint32List); |
587 Expect.equals(10, copy.length); | 605 Expect.equals(10, copy.length); |
588 Expect.listEquals(array, copy); | 606 Expect.listEquals(array, copy); |
589 var empty = array.getRange(array.length, 0); | 607 var empty = array.sublist(array.length, array.length); |
590 Expect.equals(0, empty.length); | 608 Expect.equals(0, empty.length); |
591 var region = array.getRange(3, array.length - 6); | 609 empty = array.sublist(array.length); |
| 610 Expect.equals(0, empty.length); |
| 611 |
| 612 var region = array.sublist(3, array.length - 3); |
592 Expect.isTrue(copy is Uint32List); | 613 Expect.isTrue(copy is Uint32List); |
593 Expect.equals(4, region.length); | 614 Expect.equals(4, region.length); |
594 Expect.listEquals([3, 4, 5, 6], region); | 615 Expect.listEquals([3, 4, 5, 6], region); |
595 array.setRange(3, 4, [0x100000001, 0, 1, 0xFFFFFFFF]); | 616 array.setRange(3, 4, [0x100000001, 0, 1, 0xFFFFFFFF]); |
596 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], | 617 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], |
597 array); | 618 array); |
598 } | 619 } |
599 | 620 |
600 static testUint32List() { | 621 static testUint32List() { |
601 Expect.throws(() { new Uint32List(-1); }, | 622 Expect.throws(() { new Uint32List(-1); }, |
602 (e) { return e is ArgumentError; }); | 623 (e) { return e is ArgumentError; }); |
603 Expect.throws(() { new Uint32List(-1); }, | 624 Expect.throws(() { new Uint32List(-1); }, |
604 (e) { return e is ArgumentError; }); | 625 (e) { return e is ArgumentError; }); |
605 var array = new Uint32List(10); | 626 var array = new Uint32List(10); |
606 testUint32ListImpl(array); | 627 testUint32ListImpl(array); |
607 array = new Uint32List.transferable(10); | 628 array = new Uint32List.transferable(10); |
608 testUint32ListImpl(array); | 629 testUint32ListImpl(array); |
609 | 630 |
610 } | 631 } |
611 | 632 |
612 static testInt64ListImpl(Int64List array) { | 633 static testInt64ListImpl(Int64List array) { |
613 Expect.isTrue(array is List<int>); | 634 Expect.isTrue(array is List<int>); |
614 Expect.equals(10, array.length); | 635 Expect.equals(10, array.length); |
615 Expect.equals(8, array.bytesPerElement()); | 636 Expect.equals(8, array.bytesPerElement()); |
616 Expect.equals(80, array.lengthInBytes()); | 637 Expect.equals(80, array.lengthInBytes()); |
617 Expect.listEquals([0, 0, 0, 0, 0, | 638 Expect.listEquals([0, 0, 0, 0, 0, |
618 0, 0, 0, 0, 0], | 639 0, 0, 0, 0, 0], |
619 array); | 640 array); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 } | 694 } |
674 Expect.listEquals([-0x8000000000000000, -0x7FFFFFFFFFFFFFFF, | 695 Expect.listEquals([-0x8000000000000000, -0x7FFFFFFFFFFFFFFF, |
675 -0x7FFFFFFFFFFFFFFE, -0x7FFFFFFFFFFFFFFD, | 696 -0x7FFFFFFFFFFFFFFE, -0x7FFFFFFFFFFFFFFD, |
676 -0x7FFFFFFFFFFFFFFC, -0x7FFFFFFFFFFFFFFB, | 697 -0x7FFFFFFFFFFFFFFC, -0x7FFFFFFFFFFFFFFB, |
677 -0x7FFFFFFFFFFFFFFA, -0x7FFFFFFFFFFFFFF9, | 698 -0x7FFFFFFFFFFFFFFA, -0x7FFFFFFFFFFFFFF9, |
678 -0x7FFFFFFFFFFFFFF8, -0x7FFFFFFFFFFFFFF7], | 699 -0x7FFFFFFFFFFFFFF8, -0x7FFFFFFFFFFFFFF7], |
679 array); | 700 array); |
680 for (int i = 0; i < array.length; ++i) { | 701 for (int i = 0; i < array.length; ++i) { |
681 array[i] = i; | 702 array[i] = i; |
682 } | 703 } |
683 var copy = array.getRange(0, array.length); | 704 var copy = array.sublist(0, array.length); |
684 Expect.isFalse(copy === array); | 705 Expect.isFalse(copy === array); |
685 Expect.isTrue(copy is Int64List); | 706 Expect.isTrue(copy is Int64List); |
686 Expect.equals(10, copy.length); | 707 Expect.equals(10, copy.length); |
687 Expect.listEquals(array, copy); | 708 Expect.listEquals(array, copy); |
688 var empty = array.getRange(array.length, 0); | 709 var empty = array.sublist(array.length, array.length); |
689 Expect.equals(0, empty.length); | 710 Expect.equals(0, empty.length); |
690 var region = array.getRange(3, array.length - 6); | 711 empty = array.sublist(array.length); |
| 712 Expect.equals(0, empty.length); |
| 713 |
| 714 var region = array.sublist(3, array.length - 3); |
691 Expect.isTrue(copy is Int64List); | 715 Expect.isTrue(copy is Int64List); |
692 Expect.equals(4, region.length); | 716 Expect.equals(4, region.length); |
693 Expect.listEquals([3, 4, 5, 6], region); | 717 Expect.listEquals([3, 4, 5, 6], region); |
694 array.setRange(3, 4, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); | 718 array.setRange(3, 4, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); |
695 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, | 719 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, |
696 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], | 720 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], |
697 array); | 721 array); |
698 } | 722 } |
699 | 723 |
700 static testInt64List() { | 724 static testInt64List() { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 } | 781 } |
758 Expect.listEquals([0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFE, | 782 Expect.listEquals([0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFE, |
759 0xFFFFFFFFFFFFFFFD, 0xFFFFFFFFFFFFFFFC, | 783 0xFFFFFFFFFFFFFFFD, 0xFFFFFFFFFFFFFFFC, |
760 0xFFFFFFFFFFFFFFFB, 0xFFFFFFFFFFFFFFFA, | 784 0xFFFFFFFFFFFFFFFB, 0xFFFFFFFFFFFFFFFA, |
761 0xFFFFFFFFFFFFFFF9, 0xFFFFFFFFFFFFFFF8, | 785 0xFFFFFFFFFFFFFFF9, 0xFFFFFFFFFFFFFFF8, |
762 0xFFFFFFFFFFFFFFF7, 0xFFFFFFFFFFFFFFF6], | 786 0xFFFFFFFFFFFFFFF7, 0xFFFFFFFFFFFFFFF6], |
763 array); | 787 array); |
764 for (int i = 0; i < array.length; ++i) { | 788 for (int i = 0; i < array.length; ++i) { |
765 array[i] = i; | 789 array[i] = i; |
766 } | 790 } |
767 var copy = array.getRange(0, array.length); | 791 var copy = array.sublist(0, array.length); |
768 Expect.isFalse(copy === array); | 792 Expect.isFalse(copy === array); |
769 Expect.isTrue(copy is Uint64List); | 793 Expect.isTrue(copy is Uint64List); |
770 Expect.equals(10, copy.length); | 794 Expect.equals(10, copy.length); |
771 Expect.listEquals(array, copy); | 795 Expect.listEquals(array, copy); |
772 var empty = array.getRange(array.length, 0); | 796 var empty = array.sublist(array.length, array.length); |
773 Expect.equals(0, empty.length); | 797 Expect.equals(0, empty.length); |
774 var region = array.getRange(3, array.length - 6); | 798 empty = array.sublist(array.length); |
| 799 Expect.equals(0, empty.length); |
| 800 |
| 801 var region = array.sublist(3, array.length - 3); |
775 Expect.isTrue(copy is Uint64List); | 802 Expect.isTrue(copy is Uint64List); |
776 Expect.equals(4, region.length); | 803 Expect.equals(4, region.length); |
777 Expect.listEquals([3, 4, 5, 6], region); | 804 Expect.listEquals([3, 4, 5, 6], region); |
778 array.setRange(3, 4, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); | 805 array.setRange(3, 4, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); |
779 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], | 806 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], |
780 array); | 807 array); |
781 } | 808 } |
782 | 809 |
783 static testUint64List() { | 810 static testUint64List() { |
784 Expect.throws(() { new Uint64List(-1); }, | 811 Expect.throws(() { new Uint64List(-1); }, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 for (int i = 0; i < array.length; ++i) { | 853 for (int i = 0; i < array.length; ++i) { |
827 array[i] = 1.0 + i; | 854 array[i] = 1.0 + i; |
828 } | 855 } |
829 Expect.listEquals([1.0, 2.0, 3.0, 4.0, 5.0, | 856 Expect.listEquals([1.0, 2.0, 3.0, 4.0, 5.0, |
830 6.0, 7.0, 8.0, 9.0, 10.0], | 857 6.0, 7.0, 8.0, 9.0, 10.0], |
831 array); | 858 array); |
832 // TODO: min, max, and round | 859 // TODO: min, max, and round |
833 for (int i = 0; i < array.length; ++i) { | 860 for (int i = 0; i < array.length; ++i) { |
834 array[i] = i * 1.0; | 861 array[i] = i * 1.0; |
835 } | 862 } |
836 var copy = array.getRange(0, array.length); | 863 var copy = array.sublist(0, array.length); |
837 Expect.isFalse(copy === array); | 864 Expect.isFalse(copy === array); |
838 Expect.isTrue(copy is Float32List); | 865 Expect.isTrue(copy is Float32List); |
839 Expect.equals(10, copy.length); | 866 Expect.equals(10, copy.length); |
840 Expect.listEquals(array, copy); | 867 Expect.listEquals(array, copy); |
841 var empty = array.getRange(array.length, 0); | 868 var empty = array.sublist(array.length, array.length); |
842 Expect.equals(0, empty.length); | 869 Expect.equals(0, empty.length); |
843 var region = array.getRange(3, array.length - 6); | 870 empty = array.sublist(array.length); |
| 871 Expect.equals(0, empty.length); |
| 872 |
| 873 var region = array.sublist(3, array.length - 3); |
844 Expect.isTrue(copy is Float32List); | 874 Expect.isTrue(copy is Float32List); |
845 Expect.equals(4, region.length); | 875 Expect.equals(4, region.length); |
846 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 876 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
847 array.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 877 array.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
848 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 878 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
849 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 879 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
850 array); | 880 array); |
851 } | 881 } |
852 | 882 |
853 static testFloat32List() { | 883 static testFloat32List() { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 for (int i = 0; i < array.length; ++i) { | 926 for (int i = 0; i < array.length; ++i) { |
897 array[i] = 1.0 + i; | 927 array[i] = 1.0 + i; |
898 } | 928 } |
899 Expect.listEquals([1.0, 2.0, 3.0, 4.0, 5.0, | 929 Expect.listEquals([1.0, 2.0, 3.0, 4.0, 5.0, |
900 6.0, 7.0, 8.0, 9.0, 10.0], | 930 6.0, 7.0, 8.0, 9.0, 10.0], |
901 array); | 931 array); |
902 // TODO: min, max | 932 // TODO: min, max |
903 for (int i = 0; i < array.length; ++i) { | 933 for (int i = 0; i < array.length; ++i) { |
904 array[i] = i * 1.0; | 934 array[i] = i * 1.0; |
905 } | 935 } |
906 var copy = array.getRange(0, array.length); | 936 var copy = array.sublist(0, array.length); |
907 Expect.isFalse(copy === array); | 937 Expect.isFalse(copy === array); |
908 Expect.isTrue(copy is Float64List); | 938 Expect.isTrue(copy is Float64List); |
909 Expect.equals(10, copy.length); | 939 Expect.equals(10, copy.length); |
910 Expect.listEquals(array, copy); | 940 Expect.listEquals(array, copy); |
911 var empty = array.getRange(array.length, 0); | 941 var empty = array.sublist(array.length, array.length); |
912 Expect.equals(0, empty.length); | 942 Expect.equals(0, empty.length); |
913 var region = array.getRange(3, array.length - 6); | 943 empty = array.sublist(array.length); |
| 944 Expect.equals(0, empty.length); |
| 945 |
| 946 var region = array.sublist(3, array.length - 3); |
914 Expect.isTrue(copy is Float64List); | 947 Expect.isTrue(copy is Float64List); |
915 Expect.equals(4, region.length); | 948 Expect.equals(4, region.length); |
916 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 949 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
917 array.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 950 array.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
918 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 951 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
919 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 952 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
920 array); | 953 array); |
921 } | 954 } |
922 | 955 |
923 static testFloat64List() { | 956 static testFloat64List() { |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 } | 1210 } |
1178 Expect.listEquals([-128, -127, -126, -125, -124, | 1211 Expect.listEquals([-128, -127, -126, -125, -124, |
1179 -123, -122, -121, -120, -119], | 1212 -123, -122, -121, -120, -119], |
1180 view); | 1213 view); |
1181 Expect.listEquals([0xFF, 0x80, 0x81, 0x82, 0x83, 0x84, | 1214 Expect.listEquals([0xFF, 0x80, 0x81, 0x82, 0x83, 0x84, |
1182 0x85, 0x86, 0x87, 0x88, 0x89, 0xFF], | 1215 0x85, 0x86, 0x87, 0x88, 0x89, 0xFF], |
1183 array); | 1216 array); |
1184 for (int i = 0; i < view.length; ++i) { | 1217 for (int i = 0; i < view.length; ++i) { |
1185 view[i] = i; | 1218 view[i] = i; |
1186 } | 1219 } |
1187 var copy = view.getRange(0, view.length); | 1220 var copy = view.sublist(0, view.length); |
1188 Expect.isFalse(copy === view); | 1221 Expect.isFalse(copy === view); |
1189 Expect.isTrue(copy is Int8List); | 1222 Expect.isTrue(copy is Int8List); |
1190 Expect.equals(10, copy.length); | 1223 Expect.equals(10, copy.length); |
1191 Expect.listEquals(view, copy); | 1224 Expect.listEquals(view, copy); |
1192 var region = view.getRange(3, view.length - 6); | 1225 var region = view.sublist(3, view.length - 3); |
1193 Expect.isTrue(copy is Int8List); | 1226 Expect.isTrue(copy is Int8List); |
1194 Expect.equals(4, region.length); | 1227 Expect.equals(4, region.length); |
1195 Expect.listEquals([3, 4, 5, 6], region); | 1228 Expect.listEquals([3, 4, 5, 6], region); |
1196 view.setRange(3, 4, [-128, 0, 1, 127]); | 1229 view.setRange(3, 4, [-128, 0, 1, 127]); |
1197 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], | 1230 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], |
1198 view); | 1231 view); |
1199 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF], | 1232 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF], |
1200 array); | 1233 array); |
1201 } | 1234 } |
1202 static testInt8ListView() { | 1235 static testInt8ListView() { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 } | 1325 } |
1293 Expect.listEquals([0xFF, 0xFE, 0xFD, 0xFC, 0xFB, | 1326 Expect.listEquals([0xFF, 0xFE, 0xFD, 0xFC, 0xFB, |
1294 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], | 1327 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], |
1295 view); | 1328 view); |
1296 Expect.listEquals([-1, -1, -2, -3, -4, -5, | 1329 Expect.listEquals([-1, -1, -2, -3, -4, -5, |
1297 -6, -7, -8, -9, -10, -1], | 1330 -6, -7, -8, -9, -10, -1], |
1298 array); | 1331 array); |
1299 for (int i = 0; i < view.length; ++i) { | 1332 for (int i = 0; i < view.length; ++i) { |
1300 view[i] = i; | 1333 view[i] = i; |
1301 } | 1334 } |
1302 var copy = view.getRange(0, view.length); | 1335 var copy = view.sublist(0, view.length); |
1303 Expect.isFalse(copy === view); | 1336 Expect.isFalse(copy === view); |
1304 Expect.isTrue(copy is Uint8List); | 1337 Expect.isTrue(copy is Uint8List); |
1305 Expect.equals(10, copy.length); | 1338 Expect.equals(10, copy.length); |
1306 Expect.listEquals(view, copy); | 1339 Expect.listEquals(view, copy); |
1307 var region = view.getRange(3, view.length - 6); | 1340 var region = view.sublist(3, view.length - 3); |
1308 Expect.isTrue(copy is Uint8List); | 1341 Expect.isTrue(copy is Uint8List); |
1309 Expect.equals(4, region.length); | 1342 Expect.equals(4, region.length); |
1310 Expect.listEquals([3, 4, 5, 6], region); | 1343 Expect.listEquals([3, 4, 5, 6], region); |
1311 view.setRange(3, 4, [257, 0, 1, 255]); | 1344 view.setRange(3, 4, [257, 0, 1, 255]); |
1312 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], | 1345 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], |
1313 view); | 1346 view); |
1314 } | 1347 } |
1315 | 1348 |
1316 static testUint8ListView() { | 1349 static testUint8ListView() { |
1317 var array = new Int8List(12); | 1350 var array = new Int8List(12); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 Expect.listEquals([-0x8000, -0x7FFF, -0x7FFE, -0x7FFD, -0x7FFC, | 1461 Expect.listEquals([-0x8000, -0x7FFF, -0x7FFE, -0x7FFD, -0x7FFC, |
1429 -0x7FFB, -0x7FFA, -0x7FF9, -0x7FF8, -0x7FF7], | 1462 -0x7FFB, -0x7FFA, -0x7FF9, -0x7FF8, -0x7FF7], |
1430 view); | 1463 view); |
1431 Expect.listEquals([0xFF, 0xFF, 0x00, 0x80, 0x01, 0x80, 0x02, 0x80, | 1464 Expect.listEquals([0xFF, 0xFF, 0x00, 0x80, 0x01, 0x80, 0x02, 0x80, |
1432 0x03, 0x80, 0x04, 0x80, 0x05, 0x80, 0x06, 0x80, | 1465 0x03, 0x80, 0x04, 0x80, 0x05, 0x80, 0x06, 0x80, |
1433 0x07, 0x80, 0x08, 0x80, 0x09, 0x80, 0xFF, 0xFF], | 1466 0x07, 0x80, 0x08, 0x80, 0x09, 0x80, 0xFF, 0xFF], |
1434 array); | 1467 array); |
1435 for (int i = 0; i < view.length; ++i) { | 1468 for (int i = 0; i < view.length; ++i) { |
1436 view[i] = i; | 1469 view[i] = i; |
1437 } | 1470 } |
1438 var copy = view.getRange(0, view.length); | 1471 var copy = view.sublist(0, view.length); |
1439 Expect.isFalse(copy === view); | 1472 Expect.isFalse(copy === view); |
1440 Expect.isTrue(copy is Int16List); | 1473 Expect.isTrue(copy is Int16List); |
1441 Expect.equals(10, copy.length); | 1474 Expect.equals(10, copy.length); |
1442 Expect.listEquals(view, copy); | 1475 Expect.listEquals(view, copy); |
1443 var region = view.getRange(3, view.length - 6); | 1476 var region = view.sublist(3, view.length - 3); |
1444 Expect.isTrue(copy is Int16List); | 1477 Expect.isTrue(copy is Int16List); |
1445 Expect.equals(4, region.length); | 1478 Expect.equals(4, region.length); |
1446 Expect.listEquals([3, 4, 5, 6], region); | 1479 Expect.listEquals([3, 4, 5, 6], region); |
1447 view.setRange(3, 4, [-32768, 0, 1, 32767]); | 1480 view.setRange(3, 4, [-32768, 0, 1, 32767]); |
1448 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], | 1481 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], |
1449 view); | 1482 view); |
1450 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, | 1483 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, |
1451 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F, | 1484 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F, |
1452 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], | 1485 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], |
1453 array); | 1486 array); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 Expect.listEquals([0xFFFF, 0xFFFE, 0xFFFD, 0xFFFC, 0xFFFB, | 1580 Expect.listEquals([0xFFFF, 0xFFFE, 0xFFFD, 0xFFFC, 0xFFFB, |
1548 0xFFFA, 0xFFF9, 0xFFF8, 0xFFF7, 0xFFF6], | 1581 0xFFFA, 0xFFF9, 0xFFF8, 0xFFF7, 0xFFF6], |
1549 view); | 1582 view); |
1550 Expect.listEquals([-1, -1, -1, -1, -2, -1, -3, -1, | 1583 Expect.listEquals([-1, -1, -1, -1, -2, -1, -3, -1, |
1551 -4, -1, -5, -1, -6, -1, -7, -1, | 1584 -4, -1, -5, -1, -6, -1, -7, -1, |
1552 -8, -1, -9, -1, -10, -1, -1, -1], | 1585 -8, -1, -9, -1, -10, -1, -1, -1], |
1553 array); | 1586 array); |
1554 for (int i = 0; i < view.length; ++i) { | 1587 for (int i = 0; i < view.length; ++i) { |
1555 view[i] = i; | 1588 view[i] = i; |
1556 } | 1589 } |
1557 var copy = view.getRange(0, view.length); | 1590 var copy = view.sublist(0, view.length); |
1558 Expect.isFalse(copy === view); | 1591 Expect.isFalse(copy === view); |
1559 Expect.isTrue(copy is Uint16List); | 1592 Expect.isTrue(copy is Uint16List); |
1560 Expect.equals(10, copy.length); | 1593 Expect.equals(10, copy.length); |
1561 Expect.listEquals(view, copy); | 1594 Expect.listEquals(view, copy); |
1562 var region = view.getRange(3, view.length - 6); | 1595 var region = view.sublist(3, view.length - 3); |
1563 Expect.isTrue(copy is Uint16List); | 1596 Expect.isTrue(copy is Uint16List); |
1564 Expect.equals(4, region.length); | 1597 Expect.equals(4, region.length); |
1565 Expect.listEquals([3, 4, 5, 6], region); | 1598 Expect.listEquals([3, 4, 5, 6], region); |
1566 view.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); | 1599 view.setRange(3, 4, [0x10001, 0, 1, 0xFFFF]); |
1567 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], | 1600 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], |
1568 view); | 1601 view); |
1569 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, | 1602 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, |
1570 1, 0, 0, 0, 1, 0, -1, -1, | 1603 1, 0, 0, 0, 1, 0, -1, -1, |
1571 7, 0, 8, 0, 9, 0, -1, -1], | 1604 7, 0, 8, 0, 9, 0, -1, -1], |
1572 array); | 1605 array); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x80, | 1742 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x80, |
1710 0x01, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x80, | 1743 0x01, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x80, |
1711 0x03, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x80, | 1744 0x03, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x80, |
1712 0x05, 0x00, 0x00, 0x80, 0x06, 0x00, 0x00, 0x80, | 1745 0x05, 0x00, 0x00, 0x80, 0x06, 0x00, 0x00, 0x80, |
1713 0x07, 0x00, 0x00, 0x80, 0x08, 0x00, 0x00, 0x80, | 1746 0x07, 0x00, 0x00, 0x80, 0x08, 0x00, 0x00, 0x80, |
1714 0x09, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF], | 1747 0x09, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF], |
1715 array); | 1748 array); |
1716 for (int i = 0; i < view.length; ++i) { | 1749 for (int i = 0; i < view.length; ++i) { |
1717 view[i] = i; | 1750 view[i] = i; |
1718 } | 1751 } |
1719 var copy = view.getRange(0, view.length); | 1752 var copy = view.sublist(0, view.length); |
1720 Expect.isFalse(copy === view); | 1753 Expect.isFalse(copy === view); |
1721 Expect.isTrue(copy is Int32List); | 1754 Expect.isTrue(copy is Int32List); |
1722 Expect.equals(10, copy.length); | 1755 Expect.equals(10, copy.length); |
1723 Expect.listEquals(view, copy); | 1756 Expect.listEquals(view, copy); |
1724 var region = view.getRange(3, view.length - 6); | 1757 var region = view.sublist(3, view.length - 3); |
1725 Expect.isTrue(copy is Int32List); | 1758 Expect.isTrue(copy is Int32List); |
1726 Expect.equals(4, region.length); | 1759 Expect.equals(4, region.length); |
1727 Expect.listEquals([3, 4, 5, 6], region); | 1760 Expect.listEquals([3, 4, 5, 6], region); |
1728 view.setRange(3, 4, [-0x80000000, 0, 1, 0x7FFFFFFF]); | 1761 view.setRange(3, 4, [-0x80000000, 0, 1, 0x7FFFFFFF]); |
1729 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], | 1762 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], |
1730 view); | 1763 view); |
1731 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, | 1764 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, |
1732 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, | 1765 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
1733 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, | 1766 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, |
1734 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, | 1767 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1838 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, | 1871 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, |
1839 -2, -1, -1, -1, -3, -1, -1, -1, | 1872 -2, -1, -1, -1, -3, -1, -1, -1, |
1840 -4, -1, -1, -1, -5, -1, -1, -1, | 1873 -4, -1, -1, -1, -5, -1, -1, -1, |
1841 -6, -1, -1, -1, -7, -1, -1, -1, | 1874 -6, -1, -1, -1, -7, -1, -1, -1, |
1842 -8, -1, -1, -1, -9, -1, -1, -1, | 1875 -8, -1, -1, -1, -9, -1, -1, -1, |
1843 -10, -1, -1, -1, -1, -1, -1, -1], | 1876 -10, -1, -1, -1, -1, -1, -1, -1], |
1844 array); | 1877 array); |
1845 for (int i = 0; i < view.length; ++i) { | 1878 for (int i = 0; i < view.length; ++i) { |
1846 view[i] = i; | 1879 view[i] = i; |
1847 } | 1880 } |
1848 var copy = view.getRange(0, view.length); | 1881 var copy = view.sublist(0, view.length); |
1849 Expect.isFalse(copy === view); | 1882 Expect.isFalse(copy === view); |
1850 Expect.isTrue(copy is Uint32List); | 1883 Expect.isTrue(copy is Uint32List); |
1851 Expect.equals(10, copy.length); | 1884 Expect.equals(10, copy.length); |
1852 Expect.listEquals(view, copy); | 1885 Expect.listEquals(view, copy); |
1853 var region = view.getRange(3, view.length - 6); | 1886 var region = view.sublist(3, view.length - 3); |
1854 Expect.isTrue(copy is Uint32List); | 1887 Expect.isTrue(copy is Uint32List); |
1855 Expect.equals(4, region.length); | 1888 Expect.equals(4, region.length); |
1856 Expect.listEquals([3, 4, 5, 6], region); | 1889 Expect.listEquals([3, 4, 5, 6], region); |
1857 view.setRange(3, 4, [0x100000001, 0, 1, 0xFFFFFFFF]); | 1890 view.setRange(3, 4, [0x100000001, 0, 1, 0xFFFFFFFF]); |
1858 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], | 1891 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], |
1859 view); | 1892 view); |
1860 Expect.listEquals([-1, -1, -1, -1, 0, 0, 0, 0, | 1893 Expect.listEquals([-1, -1, -1, -1, 0, 0, 0, 0, |
1861 1, 0, 0, 0, 2, 0, 0, 0, | 1894 1, 0, 0, 0, 2, 0, 0, 0, |
1862 1, 0, 0, 0, 0, 0, 0, 0, | 1895 1, 0, 0, 0, 0, 0, 0, 0, |
1863 1, 0, 0, 0, -1, -1, -1, -1, | 1896 1, 0, 0, 0, -1, -1, -1, -1, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2032 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 2065 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
2033 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 2066 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
2034 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 2067 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
2035 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 2068 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
2036 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 2069 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
2037 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 2070 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
2038 array); | 2071 array); |
2039 for (int i = 0; i < view.length; ++i) { | 2072 for (int i = 0; i < view.length; ++i) { |
2040 view[i] = i; | 2073 view[i] = i; |
2041 } | 2074 } |
2042 var copy = view.getRange(0, view.length); | 2075 var copy = view.sublist(0, view.length); |
2043 Expect.isFalse(copy === view); | 2076 Expect.isFalse(copy === view); |
2044 Expect.isTrue(copy is Int64List); | 2077 Expect.isTrue(copy is Int64List); |
2045 Expect.equals(10, copy.length); | 2078 Expect.equals(10, copy.length); |
2046 Expect.listEquals(view, copy); | 2079 Expect.listEquals(view, copy); |
2047 var region = view.getRange(3, view.length - 6); | 2080 var region = view.sublist(3, view.length - 3); |
2048 Expect.isTrue(copy is Int64List); | 2081 Expect.isTrue(copy is Int64List); |
2049 Expect.equals(4, region.length); | 2082 Expect.equals(4, region.length); |
2050 Expect.listEquals([3, 4, 5, 6], region); | 2083 Expect.listEquals([3, 4, 5, 6], region); |
2051 view.setRange(3, 4, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); | 2084 view.setRange(3, 4, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); |
2052 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, | 2085 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, |
2053 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], | 2086 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], |
2054 view); | 2087 view); |
2055 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 2088 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
2056 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 2089 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
2057 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 2090 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2196 -6, -1, -1, -1, -1, -1, -1, -1, | 2229 -6, -1, -1, -1, -1, -1, -1, -1, |
2197 -7, -1, -1, -1, -1, -1, -1, -1, | 2230 -7, -1, -1, -1, -1, -1, -1, -1, |
2198 -8, -1, -1, -1, -1, -1, -1, -1, | 2231 -8, -1, -1, -1, -1, -1, -1, -1, |
2199 -9, -1, -1, -1, -1, -1, -1, -1, | 2232 -9, -1, -1, -1, -1, -1, -1, -1, |
2200 -10, -1, -1, -1, -1, -1, -1, -1, | 2233 -10, -1, -1, -1, -1, -1, -1, -1, |
2201 -1, -1, -1, -1, -1, -1, -1, -1], | 2234 -1, -1, -1, -1, -1, -1, -1, -1], |
2202 array); | 2235 array); |
2203 for (int i = 0; i < view.length; ++i) { | 2236 for (int i = 0; i < view.length; ++i) { |
2204 view[i] = i; | 2237 view[i] = i; |
2205 } | 2238 } |
2206 var copy = view.getRange(0, view.length); | 2239 var copy = view.sublist(0, view.length); |
2207 Expect.isFalse(copy === view); | 2240 Expect.isFalse(copy === view); |
2208 Expect.isTrue(copy is Uint64List); | 2241 Expect.isTrue(copy is Uint64List); |
2209 Expect.equals(10, copy.length); | 2242 Expect.equals(10, copy.length); |
2210 Expect.listEquals(view, copy); | 2243 Expect.listEquals(view, copy); |
2211 var region = view.getRange(3, view.length - 6); | 2244 var region = view.sublist(3, view.length - 3); |
2212 Expect.isTrue(copy is Uint64List); | 2245 Expect.isTrue(copy is Uint64List); |
2213 Expect.equals(4, region.length); | 2246 Expect.equals(4, region.length); |
2214 Expect.listEquals([3, 4, 5, 6], region); | 2247 Expect.listEquals([3, 4, 5, 6], region); |
2215 view.setRange(3, 4, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); | 2248 view.setRange(3, 4, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); |
2216 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], | 2249 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], |
2217 view); | 2250 view); |
2218 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, | 2251 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, |
2219 0, 0, 0, 0, 0, 0, 0, 0, | 2252 0, 0, 0, 0, 0, 0, 0, 0, |
2220 1, 0, 0, 0, 0, 0, 0, 0, | 2253 1, 0, 0, 0, 0, 0, 0, 0, |
2221 2, 0, 0, 0, 0, 0, 0, 0, | 2254 2, 0, 0, 0, 0, 0, 0, 0, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2310 0x40000000, 0x40400000, | 2343 0x40000000, 0x40400000, |
2311 0x40800000, 0x40A00000, | 2344 0x40800000, 0x40A00000, |
2312 0x40C00000, 0x40E00000, | 2345 0x40C00000, 0x40E00000, |
2313 0x41000000, 0x41100000, | 2346 0x41000000, 0x41100000, |
2314 0x41200000, 0xBF800000], | 2347 0x41200000, 0xBF800000], |
2315 array); | 2348 array); |
2316 // TODO: min, max, and round | 2349 // TODO: min, max, and round |
2317 for (int i = 0; i < view.length; ++i) { | 2350 for (int i = 0; i < view.length; ++i) { |
2318 view[i] = i * 1.0; | 2351 view[i] = i * 1.0; |
2319 } | 2352 } |
2320 var copy = view.getRange(0, view.length); | 2353 var copy = view.sublist(0, view.length); |
2321 Expect.isFalse(copy === view); | 2354 Expect.isFalse(copy === view); |
2322 Expect.isTrue(copy is Float32List); | 2355 Expect.isTrue(copy is Float32List); |
2323 Expect.equals(10, copy.length); | 2356 Expect.equals(10, copy.length); |
2324 Expect.listEquals(view, copy); | 2357 Expect.listEquals(view, copy); |
2325 var region = view.getRange(3, view.length - 6); | 2358 var region = view.sublist(3, view.length - 3); |
2326 Expect.isTrue(copy is Float32List); | 2359 Expect.isTrue(copy is Float32List); |
2327 Expect.equals(4, region.length); | 2360 Expect.equals(4, region.length); |
2328 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 2361 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
2329 view.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 2362 view.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
2330 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 2363 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
2331 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 2364 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
2332 view); | 2365 view); |
2333 Expect.listEquals([0xBF800000, 0x00000000, | 2366 Expect.listEquals([0xBF800000, 0x00000000, |
2334 0x3F800000, 0x40000000, | 2367 0x3F800000, 0x40000000, |
2335 0xFF800000, 0x00000000, | 2368 0xFF800000, 0x00000000, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2419 0x4000000000000000, 0x4008000000000000, | 2452 0x4000000000000000, 0x4008000000000000, |
2420 0x4010000000000000, 0x4014000000000000, | 2453 0x4010000000000000, 0x4014000000000000, |
2421 0x4018000000000000, 0x401C000000000000, | 2454 0x4018000000000000, 0x401C000000000000, |
2422 0x4020000000000000, 0x4022000000000000, | 2455 0x4020000000000000, 0x4022000000000000, |
2423 0x4024000000000000, 0xBFF0000000000000], | 2456 0x4024000000000000, 0xBFF0000000000000], |
2424 array); | 2457 array); |
2425 // TODO: min, max | 2458 // TODO: min, max |
2426 for (int i = 0; i < view.length; ++i) { | 2459 for (int i = 0; i < view.length; ++i) { |
2427 view[i] = i * 1.0; | 2460 view[i] = i * 1.0; |
2428 } | 2461 } |
2429 var copy = view.getRange(0, view.length); | 2462 var copy = view.sublist(0, view.length); |
2430 Expect.isFalse(copy === view); | 2463 Expect.isFalse(copy === view); |
2431 Expect.isTrue(copy is Float64List); | 2464 Expect.isTrue(copy is Float64List); |
2432 Expect.equals(10, copy.length); | 2465 Expect.equals(10, copy.length); |
2433 Expect.listEquals(view, copy); | 2466 Expect.listEquals(view, copy); |
2434 var region = view.getRange(3, view.length - 6); | 2467 var region = view.sublist(3, view.length - 3); |
2435 Expect.isTrue(copy is Float64List); | 2468 Expect.isTrue(copy is Float64List); |
2436 Expect.equals(4, region.length); | 2469 Expect.equals(4, region.length); |
2437 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 2470 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
2438 view.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 2471 view.setRange(3, 4, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
2439 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 2472 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
2440 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 2473 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
2441 view); | 2474 view); |
2442 Expect.listEquals([0xBFF0000000000000, 0x0000000000000000, | 2475 Expect.listEquals([0xBFF0000000000000, 0x0000000000000000, |
2443 0x3FF0000000000000, 0x4000000000000000, | 2476 0x3FF0000000000000, 0x4000000000000000, |
2444 0xFFF0000000000000, 0x0000000000000000, | 2477 0xFFF0000000000000, 0x0000000000000000, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2479 testFloat32ListView(); | 2512 testFloat32ListView(); |
2480 testFloat64ListView(); | 2513 testFloat64ListView(); |
2481 } | 2514 } |
2482 } | 2515 } |
2483 | 2516 |
2484 main() { | 2517 main() { |
2485 for (var i=0; i<1000; i++) { | 2518 for (var i=0; i<1000; i++) { |
2486 ByteArrayTest.testMain(); | 2519 ByteArrayTest.testMain(); |
2487 } | 2520 } |
2488 } | 2521 } |
OLD | NEW |