| 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 // VMOptions=--optimization_counter_threshold=10 --no-background-compilation | 4 // VMOptions=--optimization_counter_threshold=10 --no-background-compilation |
| 5 | 5 |
| 6 // Library tag to be able to run in html test framework. | 6 // Library tag to be able to run in html test framework. |
| 7 library byte_array_test; | 7 library byte_array_test; |
| 8 | 8 |
| 9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 10 import 'dart:typed_data'; | 10 import 'dart:typed_data'; |
| 11 | 11 |
| 12 // This test exercises optimized [] and []= operators | 12 // This test exercises optimized [] and []= operators |
| 13 // on byte array views. | 13 // on byte array views. |
| 14 class OptimizedByteArrayTest { | 14 class OptimizedByteArrayTest { |
| 15 static testInt8ListImpl(Int8List array) { | 15 static testInt8ListImpl(Int8List array) { |
| 16 Expect.isTrue(array is List<int>); | 16 Expect.isTrue(array is List<int>); |
| 17 Expect.equals(10, array.length); | 17 Expect.equals(10, array.length); |
| 18 Expect.equals(1, array.elementSizeInBytes); | 18 Expect.equals(1, array.elementSizeInBytes); |
| 19 Expect.equals(10, array.lengthInBytes); | 19 Expect.equals(10, array.lengthInBytes); |
| 20 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); | 20 Expect.listEquals([0, 0, 0, 0, 0, |
| 21 Expect.throws(() { | 21 0, 0, 0, 0, 0], |
| 22 array[-1] = 0; | 22 array); |
| 23 }, (e) { | 23 Expect.throws(() { array[-1] = 0; }, |
| 24 return e is RangeError; | 24 (e) { return e is RangeError; }); |
| 25 }); | 25 Expect.throws(() { return array[-1]; }, |
| 26 Expect.throws(() { | 26 (e) { return e is RangeError; }); |
| 27 return array[-1]; | 27 Expect.throws(() { array[10]; }, |
| 28 }, (e) { | 28 (e) { return e is RangeError; }); |
| 29 return e is RangeError; | 29 Expect.throws(() { array[10] = 0; }, |
| 30 }); | 30 (e) { return e is RangeError; }); |
| 31 Expect.throws(() { | 31 Expect.throws(() { array.add(0); }, |
| 32 array[10]; | 32 (e) { return e is UnsupportedError; }); |
| 33 }, (e) { | 33 Expect.throws(() { array.addAll([0]); }, |
| 34 return e is RangeError; | 34 (e) { return e is UnsupportedError; }); |
| 35 }); | 35 Expect.throws(() { array.clear(); }, |
| 36 Expect.throws(() { | 36 (e) { return e is UnsupportedError; }); |
| 37 array[10] = 0; | 37 Expect.throws(() { array.length = 0; }, |
| 38 }, (e) { | 38 (e) { return e is UnsupportedError; }); |
| 39 return e is RangeError; | 39 Expect.throws(() { array.removeLast(); }, |
| 40 }); | 40 (e) { return e is UnsupportedError; }); |
| 41 Expect.throws(() { | 41 Expect.throws(() { array.removeRange(0, array.length - 1); }, |
| 42 array.add(0); | 42 (e) { return e is UnsupportedError; }); |
| 43 }, (e) { | |
| 44 return e is UnsupportedError; | |
| 45 }); | |
| 46 Expect.throws(() { | |
| 47 array.addAll([0]); | |
| 48 }, (e) { | |
| 49 return e is UnsupportedError; | |
| 50 }); | |
| 51 Expect.throws(() { | |
| 52 array.clear(); | |
| 53 }, (e) { | |
| 54 return e is UnsupportedError; | |
| 55 }); | |
| 56 Expect.throws(() { | |
| 57 array.length = 0; | |
| 58 }, (e) { | |
| 59 return e is UnsupportedError; | |
| 60 }); | |
| 61 Expect.throws(() { | |
| 62 array.removeLast(); | |
| 63 }, (e) { | |
| 64 return e is UnsupportedError; | |
| 65 }); | |
| 66 Expect.throws(() { | |
| 67 array.removeRange(0, array.length - 1); | |
| 68 }, (e) { | |
| 69 return e is UnsupportedError; | |
| 70 }); | |
| 71 for (int i = 0; i < array.length; ++i) { | 43 for (int i = 0; i < array.length; ++i) { |
| 72 array[i] = 1 + i; | 44 array[i] = 1 + i; |
| 73 } | 45 } |
| 74 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); | 46 Expect.listEquals([1, 2, 3, 4, 5, |
| 47 6, 7, 8, 9, 10], |
| 48 array); |
| 75 for (int i = 0; i < array.length; ++i) { | 49 for (int i = 0; i < array.length; ++i) { |
| 76 array[i] = 0x100 + i; | 50 array[i] = 0x100 + i; |
| 77 } | 51 } |
| 78 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); | 52 Expect.listEquals([0, 1, 2, 3, 4, |
| 53 5, 6, 7, 8, 9], |
| 54 array); |
| 79 for (int i = 0; i < array.length; ++i) { | 55 for (int i = 0; i < array.length; ++i) { |
| 80 array[i] = -10 + i; | 56 array[i] = -10 + i; |
| 81 } | 57 } |
| 82 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], array); | 58 Expect.listEquals([-10, -9, -8, -7, -6, |
| 59 -5, -4, -3, -2, -1], |
| 60 array); |
| 83 for (int i = 0; i < array.length; ++i) { | 61 for (int i = 0; i < array.length; ++i) { |
| 84 array[i] = 0x7F - i; | 62 array[i] = 0x7F - i; |
| 85 } | 63 } |
| 86 Expect | 64 Expect.listEquals([127, 126, 125, 124, 123, |
| 87 .listEquals([127, 126, 125, 124, 123, 122, 121, 120, 119, 118], array); | 65 122, 121, 120, 119, 118], |
| 66 array); |
| 88 for (int i = 0; i < array.length; ++i) { | 67 for (int i = 0; i < array.length; ++i) { |
| 89 array[i] = -0x80 + i; | 68 array[i] = -0x80 + i; |
| 90 } | 69 } |
| 91 Expect.listEquals( | 70 Expect.listEquals([-128, -127, -126, -125, -124, |
| 92 [-128, -127, -126, -125, -124, -123, -122, -121, -120, -119], array); | 71 -123, -122, -121, -120, -119], |
| 72 array); |
| 93 for (int i = 0; i < array.length; ++i) { | 73 for (int i = 0; i < array.length; ++i) { |
| 94 array[i] = i; | 74 array[i] = i; |
| 95 } | 75 } |
| 96 var copy = array.sublist(0, array.length); | 76 var copy = array.sublist(0, array.length); |
| 97 Expect.isFalse(identical(copy, array)); | 77 Expect.isFalse(identical(copy, array)); |
| 98 Expect.isTrue(copy is Int8List); | 78 Expect.isTrue(copy is Int8List); |
| 99 Expect.equals(10, copy.length); | 79 Expect.equals(10, copy.length); |
| 100 Expect.listEquals(array, copy); | 80 Expect.listEquals(array, copy); |
| 101 var empty = array.sublist(array.length, array.length); | 81 var empty = array.sublist(array.length, array.length); |
| 102 Expect.equals(0, empty.length); | 82 Expect.equals(0, empty.length); |
| 103 var region = array.sublist(3, array.length - 3); | 83 var region = array.sublist(3, array.length - 3); |
| 104 Expect.isTrue(copy is Int8List); | 84 Expect.isTrue(copy is Int8List); |
| 105 Expect.equals(4, region.length); | 85 Expect.equals(4, region.length); |
| 106 Expect.listEquals([3, 4, 5, 6], region); | 86 Expect.listEquals([3, 4, 5, 6], region); |
| 107 array.setRange(3, 7, [-128, 0, 1, 127]); | 87 array.setRange(3, 7, [-128, 0, 1, 127]); |
| 108 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], array); | 88 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], |
| 89 array); |
| 109 } | 90 } |
| 110 | |
| 111 static testInt8List() { | 91 static testInt8List() { |
| 112 Expect.throws(() { | 92 Expect.throws(() { new Int8List(-1); }, |
| 113 new Int8List(-1); | 93 (e) { return e is ArgumentError; }); |
| 114 }, (e) { | |
| 115 return e is ArgumentError; | |
| 116 }); | |
| 117 var array = new Int8List(10); | 94 var array = new Int8List(10); |
| 118 testInt8ListImpl(array); | 95 testInt8ListImpl(array); |
| 119 } | 96 } |
| 120 | 97 |
| 121 static testUint8ListImpl(Uint8List array) { | 98 static testUint8ListImpl(Uint8List array) { |
| 122 Expect.isTrue(array is List<int>); | 99 Expect.isTrue(array is List<int>); |
| 123 Expect.equals(10, array.length); | 100 Expect.equals(10, array.length); |
| 124 Expect.equals(1, array.elementSizeInBytes); | 101 Expect.equals(1, array.elementSizeInBytes); |
| 125 Expect.equals(10, array.lengthInBytes); | 102 Expect.equals(10, array.lengthInBytes); |
| 126 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); | 103 Expect.listEquals([0, 0, 0, 0, 0, |
| 127 Expect.throws(() { | 104 0, 0, 0, 0, 0], |
| 128 array[-1] = 0; | 105 array); |
| 129 }, (e) { | 106 Expect.throws(() { array[-1] = 0; }, |
| 130 return e is RangeError; | 107 (e) { return e is RangeError; }); |
| 131 }); | 108 Expect.throws(() { return array[-1]; }, |
| 132 Expect.throws(() { | 109 (e) { return e is RangeError; }); |
| 133 return array[-1]; | 110 Expect.throws(() { array[10]; }, |
| 134 }, (e) { | 111 (e) { return e is RangeError; }); |
| 135 return e is RangeError; | 112 Expect.throws(() { array[10] = 0; }, |
| 136 }); | 113 (e) { return e is RangeError; }); |
| 137 Expect.throws(() { | 114 Expect.throws(() { array.add(0); }, |
| 138 array[10]; | 115 (e) { return e is UnsupportedError; }); |
| 139 }, (e) { | 116 Expect.throws(() { array.addAll([0]); }, |
| 140 return e is RangeError; | 117 (e) { return e is UnsupportedError; }); |
| 141 }); | 118 Expect.throws(() { array.clear(); }, |
| 142 Expect.throws(() { | 119 (e) { return e is UnsupportedError; }); |
| 143 array[10] = 0; | 120 Expect.throws(() { array.length = 0; }, |
| 144 }, (e) { | 121 (e) { return e is UnsupportedError; }); |
| 145 return e is RangeError; | 122 Expect.throws(() { array.removeLast(); }, |
| 146 }); | 123 (e) { return e is UnsupportedError; }); |
| 147 Expect.throws(() { | 124 Expect.throws(() { array.removeRange(0, array.length - 1); }, |
| 148 array.add(0); | 125 (e) { return e is UnsupportedError; }); |
| 149 }, (e) { | |
| 150 return e is UnsupportedError; | |
| 151 }); | |
| 152 Expect.throws(() { | |
| 153 array.addAll([0]); | |
| 154 }, (e) { | |
| 155 return e is UnsupportedError; | |
| 156 }); | |
| 157 Expect.throws(() { | |
| 158 array.clear(); | |
| 159 }, (e) { | |
| 160 return e is UnsupportedError; | |
| 161 }); | |
| 162 Expect.throws(() { | |
| 163 array.length = 0; | |
| 164 }, (e) { | |
| 165 return e is UnsupportedError; | |
| 166 }); | |
| 167 Expect.throws(() { | |
| 168 array.removeLast(); | |
| 169 }, (e) { | |
| 170 return e is UnsupportedError; | |
| 171 }); | |
| 172 Expect.throws(() { | |
| 173 array.removeRange(0, array.length - 1); | |
| 174 }, (e) { | |
| 175 return e is UnsupportedError; | |
| 176 }); | |
| 177 for (int i = 0; i < array.length; ++i) { | 126 for (int i = 0; i < array.length; ++i) { |
| 178 array[i] = 1 + i; | 127 array[i] = 1 + i; |
| 179 } | 128 } |
| 180 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); | 129 Expect.listEquals([1, 2, 3, 4, 5, |
| 130 6, 7, 8, 9, 10], |
| 131 array); |
| 181 for (int i = 0; i < array.length; ++i) { | 132 for (int i = 0; i < array.length; ++i) { |
| 182 array[i] = 0x100 + i; | 133 array[i] = 0x100 + i; |
| 183 } | 134 } |
| 184 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); | 135 Expect.listEquals([0, 1, 2, 3, 4, |
| 136 5, 6, 7, 8, 9], |
| 137 array); |
| 185 for (int i = 0; i < array.length; ++i) { | 138 for (int i = 0; i < array.length; ++i) { |
| 186 array[i] = 0xFF - i; | 139 array[i] = 0xFF - i; |
| 187 } | 140 } |
| 188 Expect.listEquals( | 141 Expect.listEquals([0xFF, 0xFE, 0xFD, 0xFC, 0xFB, |
| 189 [0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], array); | 142 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], |
| 143 array); |
| 190 for (int i = 0; i < array.length; ++i) { | 144 for (int i = 0; i < array.length; ++i) { |
| 191 array[i] = i; | 145 array[i] = i; |
| 192 } | 146 } |
| 193 var copy = array.sublist(0, array.length); | 147 var copy = array.sublist(0, array.length); |
| 194 Expect.isFalse(identical(copy, array)); | 148 Expect.isFalse(identical(copy, array)); |
| 195 Expect.isTrue(copy is Uint8List); | 149 Expect.isTrue(copy is Uint8List); |
| 196 Expect.equals(10, copy.length); | 150 Expect.equals(10, copy.length); |
| 197 Expect.listEquals(array, copy); | 151 Expect.listEquals(array, copy); |
| 198 var empty = array.sublist(array.length, array.length); | 152 var empty = array.sublist(array.length, array.length); |
| 199 Expect.equals(0, empty.length); | 153 Expect.equals(0, empty.length); |
| 200 var region = array.sublist(3, array.length - 3); | 154 var region = array.sublist(3, array.length - 3); |
| 201 Expect.isTrue(copy is Uint8List); | 155 Expect.isTrue(copy is Uint8List); |
| 202 Expect.equals(4, region.length); | 156 Expect.equals(4, region.length); |
| 203 Expect.listEquals([3, 4, 5, 6], region); | 157 Expect.listEquals([3, 4, 5, 6], region); |
| 204 array.setRange(3, 7, [257, 0, 1, 255]); | 158 array.setRange(3, 7, [257, 0, 1, 255]); |
| 205 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], array); | 159 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], |
| 160 array); |
| 206 } | 161 } |
| 207 | 162 |
| 208 static testUint8List() { | 163 static testUint8List() { |
| 209 Expect.throws(() { | 164 Expect.throws(() { new Uint8List(-1); }, |
| 210 new Uint8List(-1); | 165 (e) { return e is ArgumentError; }); |
| 211 }, (e) { | |
| 212 return e is ArgumentError; | |
| 213 }); | |
| 214 var array = new Uint8List(10); | 166 var array = new Uint8List(10); |
| 215 testUint8ListImpl(array); | 167 testUint8ListImpl(array); |
| 216 } | 168 } |
| 217 | 169 |
| 218 static testInt16ListImpl(Int16List array) { | 170 static testInt16ListImpl(Int16List array) { |
| 219 Expect.isTrue(array is List<int>); | 171 Expect.isTrue(array is List<int>); |
| 220 Expect.equals(10, array.length); | 172 Expect.equals(10, array.length); |
| 221 Expect.equals(2, array.elementSizeInBytes); | 173 Expect.equals(2, array.elementSizeInBytes); |
| 222 Expect.equals(20, array.lengthInBytes); | 174 Expect.equals(20, array.lengthInBytes); |
| 223 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); | 175 Expect.listEquals([0, 0, 0, 0, 0, |
| 224 Expect.throws(() { | 176 0, 0, 0, 0, 0], |
| 225 array[-1] = 0; | 177 array); |
| 226 }, (e) { | 178 Expect.throws(() { array[-1] = 0; }, |
| 227 return e is RangeError; | 179 (e) { return e is RangeError; }); |
| 228 }); | 180 Expect.throws(() { return array[-1]; }, |
| 229 Expect.throws(() { | 181 (e) { return e is RangeError; }); |
| 230 return array[-1]; | 182 Expect.throws(() { array[10]; }, |
| 231 }, (e) { | 183 (e) { return e is RangeError; }); |
| 232 return e is RangeError; | 184 Expect.throws(() { array[10] = 0; }, |
| 233 }); | 185 (e) { return e is RangeError; }); |
| 234 Expect.throws(() { | 186 Expect.throws(() { array.add(0); }, |
| 235 array[10]; | 187 (e) { return e is UnsupportedError; }); |
| 236 }, (e) { | 188 Expect.throws(() { array.addAll([0]); }, |
| 237 return e is RangeError; | 189 (e) { return e is UnsupportedError; }); |
| 238 }); | 190 Expect.throws(() { array.clear(); }, |
| 239 Expect.throws(() { | 191 (e) { return e is UnsupportedError; }); |
| 240 array[10] = 0; | 192 Expect.throws(() { array.length = 0; }, |
| 241 }, (e) { | 193 (e) { return e is UnsupportedError; }); |
| 242 return e is RangeError; | 194 Expect.throws(() { array.removeLast(); }, |
| 243 }); | 195 (e) { return e is UnsupportedError; }); |
| 244 Expect.throws(() { | 196 Expect.throws(() { array.removeRange(0, array.length - 1); }, |
| 245 array.add(0); | 197 (e) { return e is UnsupportedError; }); |
| 246 }, (e) { | |
| 247 return e is UnsupportedError; | |
| 248 }); | |
| 249 Expect.throws(() { | |
| 250 array.addAll([0]); | |
| 251 }, (e) { | |
| 252 return e is UnsupportedError; | |
| 253 }); | |
| 254 Expect.throws(() { | |
| 255 array.clear(); | |
| 256 }, (e) { | |
| 257 return e is UnsupportedError; | |
| 258 }); | |
| 259 Expect.throws(() { | |
| 260 array.length = 0; | |
| 261 }, (e) { | |
| 262 return e is UnsupportedError; | |
| 263 }); | |
| 264 Expect.throws(() { | |
| 265 array.removeLast(); | |
| 266 }, (e) { | |
| 267 return e is UnsupportedError; | |
| 268 }); | |
| 269 Expect.throws(() { | |
| 270 array.removeRange(0, array.length - 1); | |
| 271 }, (e) { | |
| 272 return e is UnsupportedError; | |
| 273 }); | |
| 274 for (int i = 0; i < array.length; ++i) { | 198 for (int i = 0; i < array.length; ++i) { |
| 275 array[i] = 1 + i; | 199 array[i] = 1 + i; |
| 276 } | 200 } |
| 277 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); | 201 Expect.listEquals([1, 2, 3, 4, 5, |
| 202 6, 7, 8, 9, 10], |
| 203 array); |
| 278 for (int i = 0; i < array.length; ++i) { | 204 for (int i = 0; i < array.length; ++i) { |
| 279 array[i] = 0x10000 + i; | 205 array[i] = 0x10000 + i; |
| 280 } | 206 } |
| 281 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); | 207 Expect.listEquals([0, 1, 2, 3, 4, |
| 208 5, 6, 7, 8, 9], |
| 209 array); |
| 282 for (int i = 0; i < array.length; ++i) { | 210 for (int i = 0; i < array.length; ++i) { |
| 283 array[i] = -10 + i; | 211 array[i] = -10 + i; |
| 284 } | 212 } |
| 285 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], array); | 213 Expect.listEquals([-10, -9, -8, -7, -6, |
| 214 -5, -4, -3, -2, -1], |
| 215 array); |
| 286 for (int i = 0; i < array.length; ++i) { | 216 for (int i = 0; i < array.length; ++i) { |
| 287 array[i] = 0x7FFF - i; | 217 array[i] = 0x7FFF - i; |
| 288 } | 218 } |
| 289 Expect.listEquals([ | 219 Expect.listEquals([0x7FFF, 0x7FFE, 0x7FFD, 0x7FFC, 0x7FFB, |
| 290 0x7FFF, | 220 0x7FFA, 0x7FF9, 0x7FF8, 0x7FF7, 0x7FF6], |
| 291 0x7FFE, | 221 array); |
| 292 0x7FFD, | |
| 293 0x7FFC, | |
| 294 0x7FFB, | |
| 295 0x7FFA, | |
| 296 0x7FF9, | |
| 297 0x7FF8, | |
| 298 0x7FF7, | |
| 299 0x7FF6 | |
| 300 ], array); | |
| 301 for (int i = 0; i < array.length; ++i) { | 222 for (int i = 0; i < array.length; ++i) { |
| 302 array[i] = -0x8000 + i; | 223 array[i] = -0x8000 + i; |
| 303 } | 224 } |
| 304 Expect.listEquals([ | 225 Expect.listEquals([-0x8000, -0x7FFF, -0x7FFE, -0x7FFD, -0x7FFC, |
| 305 -0x8000, | 226 -0x7FFB, -0x7FFA, -0x7FF9, -0x7FF8, -0x7FF7], |
| 306 -0x7FFF, | 227 array); |
| 307 -0x7FFE, | |
| 308 -0x7FFD, | |
| 309 -0x7FFC, | |
| 310 -0x7FFB, | |
| 311 -0x7FFA, | |
| 312 -0x7FF9, | |
| 313 -0x7FF8, | |
| 314 -0x7FF7 | |
| 315 ], array); | |
| 316 for (int i = 0; i < array.length; ++i) { | 228 for (int i = 0; i < array.length; ++i) { |
| 317 array[i] = i; | 229 array[i] = i; |
| 318 } | 230 } |
| 319 var copy = array.sublist(0, array.length); | 231 var copy = array.sublist(0, array.length); |
| 320 Expect.isFalse(identical(copy, array)); | 232 Expect.isFalse(identical(copy, array)); |
| 321 Expect.isTrue(copy is Int16List); | 233 Expect.isTrue(copy is Int16List); |
| 322 Expect.equals(10, copy.length); | 234 Expect.equals(10, copy.length); |
| 323 Expect.listEquals(array, copy); | 235 Expect.listEquals(array, copy); |
| 324 var empty = array.sublist(array.length, array.length); | 236 var empty = array.sublist(array.length, array.length); |
| 325 Expect.equals(0, empty.length); | 237 Expect.equals(0, empty.length); |
| 326 var region = array.sublist(3, array.length - 3); | 238 var region = array.sublist(3, array.length - 3); |
| 327 Expect.isTrue(copy is Int16List); | 239 Expect.isTrue(copy is Int16List); |
| 328 Expect.equals(4, region.length); | 240 Expect.equals(4, region.length); |
| 329 Expect.listEquals([3, 4, 5, 6], region); | 241 Expect.listEquals([3, 4, 5, 6], region); |
| 330 array.setRange(3, 7, [-32768, 0, 1, 32767]); | 242 array.setRange(3, 7, [-32768, 0, 1, 32767]); |
| 331 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], array); | 243 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], |
| 244 array); |
| 332 } | 245 } |
| 333 | 246 |
| 334 static testInt16List() { | 247 static testInt16List() { |
| 335 Expect.throws(() { | 248 Expect.throws(() { new Int16List(-1); }, |
| 336 new Int16List(-1); | 249 (e) { return e is ArgumentError; }); |
| 337 }, (e) { | |
| 338 return e is ArgumentError; | |
| 339 }); | |
| 340 var array = new Int16List(10); | 250 var array = new Int16List(10); |
| 341 testInt16ListImpl(array); | 251 testInt16ListImpl(array); |
| 342 } | 252 } |
| 343 | 253 |
| 344 static testUint16ListImpl(Uint16List array) { | 254 static testUint16ListImpl(Uint16List array) { |
| 345 Expect.isTrue(array is List<int>); | 255 Expect.isTrue(array is List<int>); |
| 346 Expect.equals(10, array.length); | 256 Expect.equals(10, array.length); |
| 347 Expect.equals(2, array.elementSizeInBytes); | 257 Expect.equals(2, array.elementSizeInBytes); |
| 348 Expect.equals(20, array.lengthInBytes); | 258 Expect.equals(20, array.lengthInBytes); |
| 349 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); | 259 Expect.listEquals([0, 0, 0, 0, 0, |
| 350 Expect.throws(() { | 260 0, 0, 0, 0, 0], |
| 351 array[-1] = 0; | 261 array); |
| 352 }, (e) { | 262 Expect.throws(() { array[-1] = 0; }, |
| 353 return e is RangeError; | 263 (e) { return e is RangeError; }); |
| 354 }); | 264 Expect.throws(() { return array[-1]; }, |
| 355 Expect.throws(() { | 265 (e) { return e is RangeError; }); |
| 356 return array[-1]; | 266 Expect.throws(() { array[10]; }, |
| 357 }, (e) { | 267 (e) { return e is RangeError; }); |
| 358 return e is RangeError; | 268 Expect.throws(() { array[10] = 0; }, |
| 359 }); | 269 (e) { return e is RangeError; }); |
| 360 Expect.throws(() { | 270 Expect.throws(() { array.add(0); }, |
| 361 array[10]; | 271 (e) { return e is UnsupportedError; }); |
| 362 }, (e) { | 272 Expect.throws(() { array.addAll([0]); }, |
| 363 return e is RangeError; | 273 (e) { return e is UnsupportedError; }); |
| 364 }); | 274 Expect.throws(() { array.clear(); }, |
| 365 Expect.throws(() { | 275 (e) { return e is UnsupportedError; }); |
| 366 array[10] = 0; | 276 Expect.throws(() { array.length = 0; }, |
| 367 }, (e) { | 277 (e) { return e is UnsupportedError; }); |
| 368 return e is RangeError; | 278 Expect.throws(() { array.removeLast(); }, |
| 369 }); | 279 (e) { return e is UnsupportedError; }); |
| 370 Expect.throws(() { | 280 Expect.throws(() { array.removeRange(0, array.length - 1); }, |
| 371 array.add(0); | 281 (e) { return e is UnsupportedError; }); |
| 372 }, (e) { | |
| 373 return e is UnsupportedError; | |
| 374 }); | |
| 375 Expect.throws(() { | |
| 376 array.addAll([0]); | |
| 377 }, (e) { | |
| 378 return e is UnsupportedError; | |
| 379 }); | |
| 380 Expect.throws(() { | |
| 381 array.clear(); | |
| 382 }, (e) { | |
| 383 return e is UnsupportedError; | |
| 384 }); | |
| 385 Expect.throws(() { | |
| 386 array.length = 0; | |
| 387 }, (e) { | |
| 388 return e is UnsupportedError; | |
| 389 }); | |
| 390 Expect.throws(() { | |
| 391 array.removeLast(); | |
| 392 }, (e) { | |
| 393 return e is UnsupportedError; | |
| 394 }); | |
| 395 Expect.throws(() { | |
| 396 array.removeRange(0, array.length - 1); | |
| 397 }, (e) { | |
| 398 return e is UnsupportedError; | |
| 399 }); | |
| 400 for (int i = 0; i < array.length; ++i) { | 282 for (int i = 0; i < array.length; ++i) { |
| 401 array[i] = 1 + i; | 283 array[i] = 1 + i; |
| 402 } | 284 } |
| 403 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); | 285 Expect.listEquals([1, 2, 3, 4, 5, |
| 286 6, 7, 8, 9, 10], |
| 287 array); |
| 404 for (int i = 0; i < array.length; ++i) { | 288 for (int i = 0; i < array.length; ++i) { |
| 405 array[i] = 0x10000 + i; | 289 array[i] = 0x10000 + i; |
| 406 } | 290 } |
| 407 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); | 291 Expect.listEquals([0, 1, 2, 3, 4, |
| 292 5, 6, 7, 8, 9], |
| 293 array); |
| 408 for (int i = 0; i < array.length; ++i) { | 294 for (int i = 0; i < array.length; ++i) { |
| 409 array[i] = 0xFFFF - i; | 295 array[i] = 0xFFFF - i; |
| 410 } | 296 } |
| 411 Expect.listEquals([ | 297 Expect.listEquals([0xFFFF, 0xFFFE, 0xFFFD, 0xFFFC, 0xFFFB, |
| 412 0xFFFF, | 298 0xFFFA, 0xFFF9, 0xFFF8, 0xFFF7, 0xFFF6], |
| 413 0xFFFE, | 299 array); |
| 414 0xFFFD, | |
| 415 0xFFFC, | |
| 416 0xFFFB, | |
| 417 0xFFFA, | |
| 418 0xFFF9, | |
| 419 0xFFF8, | |
| 420 0xFFF7, | |
| 421 0xFFF6 | |
| 422 ], array); | |
| 423 for (int i = 0; i < array.length; ++i) { | 300 for (int i = 0; i < array.length; ++i) { |
| 424 array[i] = i; | 301 array[i] = i; |
| 425 } | 302 } |
| 426 var copy = array.sublist(0, array.length); | 303 var copy = array.sublist(0, array.length); |
| 427 Expect.isFalse(identical(copy, array)); | 304 Expect.isFalse(identical(copy, array)); |
| 428 Expect.isTrue(copy is Uint16List); | 305 Expect.isTrue(copy is Uint16List); |
| 429 Expect.equals(10, copy.length); | 306 Expect.equals(10, copy.length); |
| 430 Expect.listEquals(array, copy); | 307 Expect.listEquals(array, copy); |
| 431 var empty = array.sublist(array.length, array.length); | 308 var empty = array.sublist(array.length, array.length); |
| 432 Expect.equals(0, empty.length); | 309 Expect.equals(0, empty.length); |
| 433 var region = array.sublist(3, array.length - 3); | 310 var region = array.sublist(3, array.length - 3); |
| 434 Expect.isTrue(copy is Uint16List); | 311 Expect.isTrue(copy is Uint16List); |
| 435 Expect.equals(4, region.length); | 312 Expect.equals(4, region.length); |
| 436 Expect.listEquals([3, 4, 5, 6], region); | 313 Expect.listEquals([3, 4, 5, 6], region); |
| 437 array.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]); | 314 array.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]); |
| 438 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], array); | 315 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], |
| 316 array); |
| 439 } | 317 } |
| 440 | 318 |
| 441 static testUint16List() { | 319 static testUint16List() { |
| 442 Expect.throws(() { | 320 Expect.throws(() { new Uint16List(-1); }, |
| 443 new Uint16List(-1); | 321 (e) { return e is ArgumentError; }); |
| 444 }, (e) { | |
| 445 return e is ArgumentError; | |
| 446 }); | |
| 447 var array = new Uint16List(10); | 322 var array = new Uint16List(10); |
| 448 testUint16ListImpl(array); | 323 testUint16ListImpl(array); |
| 449 } | 324 } |
| 450 | 325 |
| 451 static testInt32ListImpl(Int32List array) { | 326 static testInt32ListImpl(Int32List array) { |
| 452 Expect.isTrue(array is List<int>); | 327 Expect.isTrue(array is List<int>); |
| 453 Expect.equals(10, array.length); | 328 Expect.equals(10, array.length); |
| 454 Expect.equals(4, array.elementSizeInBytes); | 329 Expect.equals(4, array.elementSizeInBytes); |
| 455 Expect.equals(40, array.lengthInBytes); | 330 Expect.equals(40, array.lengthInBytes); |
| 456 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); | 331 Expect.listEquals([0, 0, 0, 0, 0, |
| 457 Expect.throws(() { | 332 0, 0, 0, 0, 0], |
| 458 array[-1] = 0; | 333 array); |
| 459 }, (e) { | 334 Expect.throws(() { array[-1] = 0; }, |
| 460 return e is RangeError; | 335 (e) { return e is RangeError; }); |
| 461 }); | 336 Expect.throws(() { return array[-1]; }, |
| 462 Expect.throws(() { | 337 (e) { return e is RangeError; }); |
| 463 return array[-1]; | 338 Expect.throws(() { array[10]; }, |
| 464 }, (e) { | 339 (e) { return e is RangeError; }); |
| 465 return e is RangeError; | 340 Expect.throws(() { array[10] = 0; }, |
| 466 }); | 341 (e) { return e is RangeError; }); |
| 467 Expect.throws(() { | 342 Expect.throws(() { array.add(0); }, |
| 468 array[10]; | 343 (e) { return e is UnsupportedError; }); |
| 469 }, (e) { | 344 Expect.throws(() { array.addAll([0]); }, |
| 470 return e is RangeError; | 345 (e) { return e is UnsupportedError; }); |
| 471 }); | 346 Expect.throws(() { array.clear(); }, |
| 472 Expect.throws(() { | 347 (e) { return e is UnsupportedError; }); |
| 473 array[10] = 0; | 348 Expect.throws(() { array.length = 0; }, |
| 474 }, (e) { | 349 (e) { return e is UnsupportedError; }); |
| 475 return e is RangeError; | 350 Expect.throws(() { array.removeLast(); }, |
| 476 }); | 351 (e) { return e is UnsupportedError; }); |
| 477 Expect.throws(() { | 352 Expect.throws(() { array.removeRange(0, array.length - 1); }, |
| 478 array.add(0); | 353 (e) { return e is UnsupportedError; }); |
| 479 }, (e) { | |
| 480 return e is UnsupportedError; | |
| 481 }); | |
| 482 Expect.throws(() { | |
| 483 array.addAll([0]); | |
| 484 }, (e) { | |
| 485 return e is UnsupportedError; | |
| 486 }); | |
| 487 Expect.throws(() { | |
| 488 array.clear(); | |
| 489 }, (e) { | |
| 490 return e is UnsupportedError; | |
| 491 }); | |
| 492 Expect.throws(() { | |
| 493 array.length = 0; | |
| 494 }, (e) { | |
| 495 return e is UnsupportedError; | |
| 496 }); | |
| 497 Expect.throws(() { | |
| 498 array.removeLast(); | |
| 499 }, (e) { | |
| 500 return e is UnsupportedError; | |
| 501 }); | |
| 502 Expect.throws(() { | |
| 503 array.removeRange(0, array.length - 1); | |
| 504 }, (e) { | |
| 505 return e is UnsupportedError; | |
| 506 }); | |
| 507 for (int i = 0; i < array.length; ++i) { | 354 for (int i = 0; i < array.length; ++i) { |
| 508 array[i] = 1 + i; | 355 array[i] = 1 + i; |
| 509 } | 356 } |
| 510 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); | 357 Expect.listEquals([1, 2, 3, 4, 5, |
| 358 6, 7, 8, 9, 10], |
| 359 array); |
| 511 for (int i = 0; i < array.length; ++i) { | 360 for (int i = 0; i < array.length; ++i) { |
| 512 array[i] = 0x100000000 + i; | 361 array[i] = 0x100000000 + i; |
| 513 } | 362 } |
| 514 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); | 363 Expect.listEquals([0, 1, 2, 3, 4, |
| 364 5, 6, 7, 8, 9], |
| 365 array); |
| 515 for (int i = 0; i < array.length; ++i) { | 366 for (int i = 0; i < array.length; ++i) { |
| 516 array[i] = -10 + i; | 367 array[i] = -10 + i; |
| 517 } | 368 } |
| 518 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], array); | 369 Expect.listEquals([-10, -9, -8, -7, -6, |
| 370 -5, -4, -3, -2, -1], |
| 371 array); |
| 519 for (int i = 0; i < array.length; ++i) { | 372 for (int i = 0; i < array.length; ++i) { |
| 520 array[i] = 0x7FFFFFFF - i; | 373 array[i] = 0x7FFFFFFF - i; |
| 521 } | 374 } |
| 522 Expect.listEquals([ | 375 Expect.listEquals([0x7FFFFFFF, 0x7FFFFFFE, |
| 523 0x7FFFFFFF, | 376 0x7FFFFFFD, 0x7FFFFFFC, |
| 524 0x7FFFFFFE, | 377 0x7FFFFFFB, 0x7FFFFFFA, |
| 525 0x7FFFFFFD, | 378 0x7FFFFFF9, 0x7FFFFFF8, |
| 526 0x7FFFFFFC, | 379 0x7FFFFFF7, 0x7FFFFFF6], |
| 527 0x7FFFFFFB, | 380 array); |
| 528 0x7FFFFFFA, | |
| 529 0x7FFFFFF9, | |
| 530 0x7FFFFFF8, | |
| 531 0x7FFFFFF7, | |
| 532 0x7FFFFFF6 | |
| 533 ], array); | |
| 534 for (int i = 0; i < array.length; ++i) { | 381 for (int i = 0; i < array.length; ++i) { |
| 535 array[i] = -0x80000000 + i; | 382 array[i] = -0x80000000 + i; |
| 536 } | 383 } |
| 537 Expect.listEquals([ | 384 Expect.listEquals([-0x80000000, -0x7FFFFFFF, |
| 538 -0x80000000, | 385 -0x7FFFFFFE, -0x7FFFFFFD, |
| 539 -0x7FFFFFFF, | 386 -0x7FFFFFFC, -0x7FFFFFFB, |
| 540 -0x7FFFFFFE, | 387 -0x7FFFFFFA, -0x7FFFFFF9, |
| 541 -0x7FFFFFFD, | 388 -0x7FFFFFF8, -0x7FFFFFF7], |
| 542 -0x7FFFFFFC, | 389 array); |
| 543 -0x7FFFFFFB, | |
| 544 -0x7FFFFFFA, | |
| 545 -0x7FFFFFF9, | |
| 546 -0x7FFFFFF8, | |
| 547 -0x7FFFFFF7 | |
| 548 ], array); | |
| 549 for (int i = 0; i < array.length; ++i) { | 390 for (int i = 0; i < array.length; ++i) { |
| 550 array[i] = i; | 391 array[i] = i; |
| 551 } | 392 } |
| 552 var copy = array.sublist(0, array.length); | 393 var copy = array.sublist(0, array.length); |
| 553 Expect.isFalse(identical(copy, array)); | 394 Expect.isFalse(identical(copy, array)); |
| 554 Expect.isTrue(copy is Int32List); | 395 Expect.isTrue(copy is Int32List); |
| 555 Expect.equals(10, copy.length); | 396 Expect.equals(10, copy.length); |
| 556 Expect.listEquals(array, copy); | 397 Expect.listEquals(array, copy); |
| 557 var empty = array.sublist(array.length, array.length); | 398 var empty = array.sublist(array.length, array.length); |
| 558 Expect.equals(0, empty.length); | 399 Expect.equals(0, empty.length); |
| 559 var region = array.sublist(3, array.length - 3); | 400 var region = array.sublist(3, array.length - 3); |
| 560 Expect.isTrue(copy is Int32List); | 401 Expect.isTrue(copy is Int32List); |
| 561 Expect.equals(4, region.length); | 402 Expect.equals(4, region.length); |
| 562 Expect.listEquals([3, 4, 5, 6], region); | 403 Expect.listEquals([3, 4, 5, 6], region); |
| 563 array.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]); | 404 array.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]); |
| 564 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], array); | 405 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], |
| 406 array); |
| 565 } | 407 } |
| 566 | 408 |
| 567 static testInt32List() { | 409 static testInt32List() { |
| 568 Expect.throws(() { | 410 Expect.throws(() { new Int32List(-1); }, |
| 569 new Int32List(-1); | 411 (e) { return e is ArgumentError; }); |
| 570 }, (e) { | |
| 571 return e is ArgumentError; | |
| 572 }); | |
| 573 var array = new Int32List(10); | 412 var array = new Int32List(10); |
| 574 testInt32ListImpl(array); | 413 testInt32ListImpl(array); |
| 575 } | 414 } |
| 576 | 415 |
| 577 static testUint32ListImpl(Uint32List array) { | 416 static testUint32ListImpl(Uint32List array) { |
| 578 Expect.isTrue(array is List<int>); | 417 Expect.isTrue(array is List<int>); |
| 579 Expect.equals(10, array.length); | 418 Expect.equals(10, array.length); |
| 580 Expect.equals(4, array.elementSizeInBytes); | 419 Expect.equals(4, array.elementSizeInBytes); |
| 581 Expect.equals(40, array.lengthInBytes); | 420 Expect.equals(40, array.lengthInBytes); |
| 582 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); | 421 Expect.listEquals([0, 0, 0, 0, 0, |
| 583 Expect.throws(() { | 422 0, 0, 0, 0, 0], |
| 584 array[-1] = 0; | 423 array); |
| 585 }, (e) { | 424 Expect.throws(() { array[-1] = 0; }, |
| 586 return e is RangeError; | 425 (e) { return e is RangeError; }); |
| 587 }); | 426 Expect.throws(() { return array[-1]; }, |
| 588 Expect.throws(() { | 427 (e) { return e is RangeError; }); |
| 589 return array[-1]; | 428 Expect.throws(() { array[10]; }, |
| 590 }, (e) { | 429 (e) { return e is RangeError; }); |
| 591 return e is RangeError; | 430 Expect.throws(() { array[10] = 0; }, |
| 592 }); | 431 (e) { return e is RangeError; }); |
| 593 Expect.throws(() { | 432 Expect.throws(() { array.add(0); }, |
| 594 array[10]; | 433 (e) { return e is UnsupportedError; }); |
| 595 }, (e) { | 434 Expect.throws(() { array.addAll([0]); }, |
| 596 return e is RangeError; | 435 (e) { return e is UnsupportedError; }); |
| 597 }); | 436 Expect.throws(() { array.clear(); }, |
| 598 Expect.throws(() { | 437 (e) { return e is UnsupportedError; }); |
| 599 array[10] = 0; | 438 Expect.throws(() { array.length = 0; }, |
| 600 }, (e) { | 439 (e) { return e is UnsupportedError; }); |
| 601 return e is RangeError; | 440 Expect.throws(() { array.removeLast(); }, |
| 602 }); | 441 (e) { return e is UnsupportedError; }); |
| 603 Expect.throws(() { | 442 Expect.throws(() { array.removeRange(0, array.length - 1); }, |
| 604 array.add(0); | 443 (e) { return e is UnsupportedError; }); |
| 605 }, (e) { | |
| 606 return e is UnsupportedError; | |
| 607 }); | |
| 608 Expect.throws(() { | |
| 609 array.addAll([0]); | |
| 610 }, (e) { | |
| 611 return e is UnsupportedError; | |
| 612 }); | |
| 613 Expect.throws(() { | |
| 614 array.clear(); | |
| 615 }, (e) { | |
| 616 return e is UnsupportedError; | |
| 617 }); | |
| 618 Expect.throws(() { | |
| 619 array.length = 0; | |
| 620 }, (e) { | |
| 621 return e is UnsupportedError; | |
| 622 }); | |
| 623 Expect.throws(() { | |
| 624 array.removeLast(); | |
| 625 }, (e) { | |
| 626 return e is UnsupportedError; | |
| 627 }); | |
| 628 Expect.throws(() { | |
| 629 array.removeRange(0, array.length - 1); | |
| 630 }, (e) { | |
| 631 return e is UnsupportedError; | |
| 632 }); | |
| 633 for (int i = 0; i < array.length; ++i) { | 444 for (int i = 0; i < array.length; ++i) { |
| 634 array[i] = 1 + i; | 445 array[i] = 1 + i; |
| 635 } | 446 } |
| 636 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); | 447 Expect.listEquals([1, 2, 3, 4, 5, |
| 448 6, 7, 8, 9, 10], |
| 449 array); |
| 637 for (int i = 0; i < array.length; ++i) { | 450 for (int i = 0; i < array.length; ++i) { |
| 638 array[i] = 0x100000000 + i; | 451 array[i] = 0x100000000 + i; |
| 639 } | 452 } |
| 640 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); | 453 Expect.listEquals([0, 1, 2, 3, 4, |
| 454 5, 6, 7, 8, 9], |
| 455 array); |
| 641 for (int i = 0; i < array.length; ++i) { | 456 for (int i = 0; i < array.length; ++i) { |
| 642 array[i] = 0xFFFFFFFF - i; | 457 array[i] = 0xFFFFFFFF - i; |
| 643 } | 458 } |
| 644 Expect.listEquals([ | 459 Expect.listEquals([0xFFFFFFFF, 0xFFFFFFFE, |
| 645 0xFFFFFFFF, | 460 0xFFFFFFFD, 0xFFFFFFFC, |
| 646 0xFFFFFFFE, | 461 0xFFFFFFFB, 0xFFFFFFFA, |
| 647 0xFFFFFFFD, | 462 0xFFFFFFF9, 0xFFFFFFF8, |
| 648 0xFFFFFFFC, | 463 0xFFFFFFF7, 0xFFFFFFF6], |
| 649 0xFFFFFFFB, | 464 array); |
| 650 0xFFFFFFFA, | |
| 651 0xFFFFFFF9, | |
| 652 0xFFFFFFF8, | |
| 653 0xFFFFFFF7, | |
| 654 0xFFFFFFF6 | |
| 655 ], array); | |
| 656 for (int i = 0; i < array.length; ++i) { | 465 for (int i = 0; i < array.length; ++i) { |
| 657 array[i] = i; | 466 array[i] = i; |
| 658 } | 467 } |
| 659 var copy = array.sublist(0, array.length); | 468 var copy = array.sublist(0, array.length); |
| 660 Expect.isFalse(identical(copy, array)); | 469 Expect.isFalse(identical(copy, array)); |
| 661 Expect.isTrue(copy is Uint32List); | 470 Expect.isTrue(copy is Uint32List); |
| 662 Expect.equals(10, copy.length); | 471 Expect.equals(10, copy.length); |
| 663 Expect.listEquals(array, copy); | 472 Expect.listEquals(array, copy); |
| 664 var empty = array.sublist(array.length, array.length); | 473 var empty = array.sublist(array.length, array.length); |
| 665 Expect.equals(0, empty.length); | 474 Expect.equals(0, empty.length); |
| 666 var region = array.sublist(3, array.length - 3); | 475 var region = array.sublist(3, array.length - 3); |
| 667 Expect.isTrue(copy is Uint32List); | 476 Expect.isTrue(copy is Uint32List); |
| 668 Expect.equals(4, region.length); | 477 Expect.equals(4, region.length); |
| 669 Expect.listEquals([3, 4, 5, 6], region); | 478 Expect.listEquals([3, 4, 5, 6], region); |
| 670 array.setRange(3, 7, [0x100000001, 0, 1, 0xFFFFFFFF]); | 479 array.setRange(3, 7, [0x100000001, 0, 1, 0xFFFFFFFF]); |
| 671 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], array); | 480 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], |
| 481 array); |
| 672 } | 482 } |
| 673 | 483 |
| 674 static testUint32List() { | 484 static testUint32List() { |
| 675 Expect.throws(() { | 485 Expect.throws(() { new Uint32List(-1); }, |
| 676 new Uint32List(-1); | 486 (e) { return e is ArgumentError; }); |
| 677 }, (e) { | 487 Expect.throws(() { new Uint32List(-1); }, |
| 678 return e is ArgumentError; | 488 (e) { return e is ArgumentError; }); |
| 679 }); | |
| 680 Expect.throws(() { | |
| 681 new Uint32List(-1); | |
| 682 }, (e) { | |
| 683 return e is ArgumentError; | |
| 684 }); | |
| 685 var array = new Uint32List(10); | 489 var array = new Uint32List(10); |
| 686 testUint32ListImpl(array); | 490 testUint32ListImpl(array); |
| 491 |
| 687 } | 492 } |
| 688 | 493 |
| 689 static testInt64ListImpl(Int64List array) { | 494 static testInt64ListImpl(Int64List array) { |
| 690 Expect.isTrue(array is List<int>); | 495 Expect.isTrue(array is List<int>); |
| 691 Expect.equals(10, array.length); | 496 Expect.equals(10, array.length); |
| 692 Expect.equals(8, array.elementSizeInBytes); | 497 Expect.equals(8, array.elementSizeInBytes); |
| 693 Expect.equals(80, array.lengthInBytes); | 498 Expect.equals(80, array.lengthInBytes); |
| 694 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); | 499 Expect.listEquals([0, 0, 0, 0, 0, |
| 695 Expect.throws(() { | 500 0, 0, 0, 0, 0], |
| 696 array[-1] = 0; | 501 array); |
| 697 }, (e) { | 502 Expect.throws(() { array[-1] = 0; }, |
| 698 return e is RangeError; | 503 (e) { return e is RangeError; }); |
| 699 }); | 504 Expect.throws(() { return array[-1]; }, |
| 700 Expect.throws(() { | 505 (e) { return e is RangeError; }); |
| 701 return array[-1]; | 506 Expect.throws(() { array[10]; }, |
| 702 }, (e) { | 507 (e) { return e is RangeError; }); |
| 703 return e is RangeError; | 508 Expect.throws(() { array[10] = 0; }, |
| 704 }); | 509 (e) { return e is RangeError; }); |
| 705 Expect.throws(() { | 510 Expect.throws(() { array.add(0); }, |
| 706 array[10]; | 511 (e) { return e is UnsupportedError; }); |
| 707 }, (e) { | 512 Expect.throws(() { array.addAll([0]); }, |
| 708 return e is RangeError; | 513 (e) { return e is UnsupportedError; }); |
| 709 }); | 514 Expect.throws(() { array.clear(); }, |
| 710 Expect.throws(() { | 515 (e) { return e is UnsupportedError; }); |
| 711 array[10] = 0; | 516 Expect.throws(() { array.length = 0; }, |
| 712 }, (e) { | 517 (e) { return e is UnsupportedError; }); |
| 713 return e is RangeError; | 518 Expect.throws(() { array.removeLast(); }, |
| 714 }); | 519 (e) { return e is UnsupportedError; }); |
| 715 Expect.throws(() { | 520 Expect.throws(() { array.removeRange(0, array.length - 1); }, |
| 716 array.add(0); | 521 (e) { return e is UnsupportedError; }); |
| 717 }, (e) { | |
| 718 return e is UnsupportedError; | |
| 719 }); | |
| 720 Expect.throws(() { | |
| 721 array.addAll([0]); | |
| 722 }, (e) { | |
| 723 return e is UnsupportedError; | |
| 724 }); | |
| 725 Expect.throws(() { | |
| 726 array.clear(); | |
| 727 }, (e) { | |
| 728 return e is UnsupportedError; | |
| 729 }); | |
| 730 Expect.throws(() { | |
| 731 array.length = 0; | |
| 732 }, (e) { | |
| 733 return e is UnsupportedError; | |
| 734 }); | |
| 735 Expect.throws(() { | |
| 736 array.removeLast(); | |
| 737 }, (e) { | |
| 738 return e is UnsupportedError; | |
| 739 }); | |
| 740 Expect.throws(() { | |
| 741 array.removeRange(0, array.length - 1); | |
| 742 }, (e) { | |
| 743 return e is UnsupportedError; | |
| 744 }); | |
| 745 for (int i = 0; i < array.length; ++i) { | 522 for (int i = 0; i < array.length; ++i) { |
| 746 array[i] = 1 + i; | 523 array[i] = 1 + i; |
| 747 } | 524 } |
| 748 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); | 525 Expect.listEquals([1, 2, 3, 4, 5, |
| 526 6, 7, 8, 9, 10], |
| 527 array); |
| 749 for (int i = 0; i < array.length; ++i) { | 528 for (int i = 0; i < array.length; ++i) { |
| 750 array[i] = 0x10000000000000000 + i; | 529 array[i] = 0x10000000000000000 + i; |
| 751 } | 530 } |
| 752 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); | 531 Expect.listEquals([0, 1, 2, 3, 4, |
| 532 5, 6, 7, 8, 9], |
| 533 array); |
| 753 for (int i = 0; i < array.length; ++i) { | 534 for (int i = 0; i < array.length; ++i) { |
| 754 array[i] = -10 + i; | 535 array[i] = -10 + i; |
| 755 } | 536 } |
| 756 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], array); | 537 Expect.listEquals([-10, -9, -8, -7, -6, |
| 538 -5, -4, -3, -2, -1], |
| 539 array); |
| 757 for (int i = 0; i < array.length; ++i) { | 540 for (int i = 0; i < array.length; ++i) { |
| 758 array[i] = 0x7FFFFFFFFFFFFFFF - i; | 541 array[i] = 0x7FFFFFFFFFFFFFFF - i; |
| 759 } | 542 } |
| 760 Expect.listEquals([ | 543 Expect.listEquals([0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFE, |
| 761 0x7FFFFFFFFFFFFFFF, | 544 0x7FFFFFFFFFFFFFFD, 0x7FFFFFFFFFFFFFFC, |
| 762 0x7FFFFFFFFFFFFFFE, | 545 0x7FFFFFFFFFFFFFFB, 0x7FFFFFFFFFFFFFFA, |
| 763 0x7FFFFFFFFFFFFFFD, | 546 0x7FFFFFFFFFFFFFF9, 0x7FFFFFFFFFFFFFF8, |
| 764 0x7FFFFFFFFFFFFFFC, | 547 0x7FFFFFFFFFFFFFF7, 0x7FFFFFFFFFFFFFF6], |
| 765 0x7FFFFFFFFFFFFFFB, | 548 array); |
| 766 0x7FFFFFFFFFFFFFFA, | |
| 767 0x7FFFFFFFFFFFFFF9, | |
| 768 0x7FFFFFFFFFFFFFF8, | |
| 769 0x7FFFFFFFFFFFFFF7, | |
| 770 0x7FFFFFFFFFFFFFF6 | |
| 771 ], array); | |
| 772 for (int i = 0; i < array.length; ++i) { | 549 for (int i = 0; i < array.length; ++i) { |
| 773 array[i] = -0x8000000000000000 + i; | 550 array[i] = -0x8000000000000000 + i; |
| 774 } | 551 } |
| 775 Expect.listEquals([ | 552 Expect.listEquals([-0x8000000000000000, -0x7FFFFFFFFFFFFFFF, |
| 776 -0x8000000000000000, | 553 -0x7FFFFFFFFFFFFFFE, -0x7FFFFFFFFFFFFFFD, |
| 777 -0x7FFFFFFFFFFFFFFF, | 554 -0x7FFFFFFFFFFFFFFC, -0x7FFFFFFFFFFFFFFB, |
| 778 -0x7FFFFFFFFFFFFFFE, | 555 -0x7FFFFFFFFFFFFFFA, -0x7FFFFFFFFFFFFFF9, |
| 779 -0x7FFFFFFFFFFFFFFD, | 556 -0x7FFFFFFFFFFFFFF8, -0x7FFFFFFFFFFFFFF7], |
| 780 -0x7FFFFFFFFFFFFFFC, | 557 array); |
| 781 -0x7FFFFFFFFFFFFFFB, | |
| 782 -0x7FFFFFFFFFFFFFFA, | |
| 783 -0x7FFFFFFFFFFFFFF9, | |
| 784 -0x7FFFFFFFFFFFFFF8, | |
| 785 -0x7FFFFFFFFFFFFFF7 | |
| 786 ], array); | |
| 787 for (int i = 0; i < array.length; ++i) { | 558 for (int i = 0; i < array.length; ++i) { |
| 788 array[i] = i; | 559 array[i] = i; |
| 789 } | 560 } |
| 790 var copy = array.sublist(0, array.length); | 561 var copy = array.sublist(0, array.length); |
| 791 Expect.isFalse(identical(copy, array)); | 562 Expect.isFalse(identical(copy, array)); |
| 792 Expect.isTrue(copy is Int64List); | 563 Expect.isTrue(copy is Int64List); |
| 793 Expect.equals(10, copy.length); | 564 Expect.equals(10, copy.length); |
| 794 Expect.listEquals(array, copy); | 565 Expect.listEquals(array, copy); |
| 795 var empty = array.sublist(array.length, array.length); | 566 var empty = array.sublist(array.length, array.length); |
| 796 Expect.equals(0, empty.length); | 567 Expect.equals(0, empty.length); |
| 797 var region = array.sublist(3, array.length - 3); | 568 var region = array.sublist(3, array.length - 3); |
| 798 Expect.isTrue(copy is Int64List); | 569 Expect.isTrue(copy is Int64List); |
| 799 Expect.equals(4, region.length); | 570 Expect.equals(4, region.length); |
| 800 Expect.listEquals([3, 4, 5, 6], region); | 571 Expect.listEquals([3, 4, 5, 6], region); |
| 801 array.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); | 572 array.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); |
| 802 Expect.listEquals( | 573 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, |
| 803 [0, 1, 2, -0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], | 574 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], |
| 804 array); | 575 array); |
| 805 } | 576 } |
| 806 | 577 |
| 807 static testInt64List() { | 578 static testInt64List() { |
| 808 Expect.throws(() { | 579 Expect.throws(() { new Int64List(-1); }, |
| 809 new Int64List(-1); | 580 (e) { return e is ArgumentError; }); |
| 810 }, (e) { | |
| 811 return e is ArgumentError; | |
| 812 }); | |
| 813 var array = new Int64List(10); | 581 var array = new Int64List(10); |
| 814 testInt64ListImpl(array); | 582 testInt64ListImpl(array); |
| 815 } | 583 } |
| 816 | 584 |
| 817 static testUint64ListImpl(Uint64List array) { | 585 static testUint64ListImpl(Uint64List array) { |
| 818 Expect.isTrue(array is List<int>); | 586 Expect.isTrue(array is List<int>); |
| 819 Expect.equals(10, array.length); | 587 Expect.equals(10, array.length); |
| 820 Expect.equals(8, array.elementSizeInBytes); | 588 Expect.equals(8, array.elementSizeInBytes); |
| 821 Expect.equals(80, array.lengthInBytes); | 589 Expect.equals(80, array.lengthInBytes); |
| 822 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); | 590 Expect.listEquals([0, 0, 0, 0, 0, |
| 823 Expect.throws(() { | 591 0, 0, 0, 0, 0], |
| 824 array[-1] = 0; | 592 array); |
| 825 }, (e) { | 593 Expect.throws(() { array[-1] = 0; }, |
| 826 return e is RangeError; | 594 (e) { return e is RangeError; }); |
| 827 }); | 595 Expect.throws(() { return array[-1]; }, |
| 828 Expect.throws(() { | 596 (e) { return e is RangeError; }); |
| 829 return array[-1]; | 597 Expect.throws(() { array[10]; }, |
| 830 }, (e) { | 598 (e) { return e is RangeError; }); |
| 831 return e is RangeError; | 599 Expect.throws(() { array[10] = 0; }, |
| 832 }); | 600 (e) { return e is RangeError; }); |
| 833 Expect.throws(() { | 601 Expect.throws(() { array.add(0); }, |
| 834 array[10]; | 602 (e) { return e is UnsupportedError; }); |
| 835 }, (e) { | 603 Expect.throws(() { array.addAll([0]); }, |
| 836 return e is RangeError; | 604 (e) { return e is UnsupportedError; }); |
| 837 }); | 605 Expect.throws(() { array.clear(); }, |
| 838 Expect.throws(() { | 606 (e) { return e is UnsupportedError; }); |
| 839 array[10] = 0; | 607 Expect.throws(() { array.length = 0; }, |
| 840 }, (e) { | 608 (e) { return e is UnsupportedError; }); |
| 841 return e is RangeError; | 609 Expect.throws(() { array.removeLast(); }, |
| 842 }); | 610 (e) { return e is UnsupportedError; }); |
| 843 Expect.throws(() { | 611 Expect.throws(() { array.removeRange(0, array.length - 1); }, |
| 844 array.add(0); | 612 (e) { return e is UnsupportedError; }); |
| 845 }, (e) { | |
| 846 return e is UnsupportedError; | |
| 847 }); | |
| 848 Expect.throws(() { | |
| 849 array.addAll([0]); | |
| 850 }, (e) { | |
| 851 return e is UnsupportedError; | |
| 852 }); | |
| 853 Expect.throws(() { | |
| 854 array.clear(); | |
| 855 }, (e) { | |
| 856 return e is UnsupportedError; | |
| 857 }); | |
| 858 Expect.throws(() { | |
| 859 array.length = 0; | |
| 860 }, (e) { | |
| 861 return e is UnsupportedError; | |
| 862 }); | |
| 863 Expect.throws(() { | |
| 864 array.removeLast(); | |
| 865 }, (e) { | |
| 866 return e is UnsupportedError; | |
| 867 }); | |
| 868 Expect.throws(() { | |
| 869 array.removeRange(0, array.length - 1); | |
| 870 }, (e) { | |
| 871 return e is UnsupportedError; | |
| 872 }); | |
| 873 for (int i = 0; i < array.length; ++i) { | 613 for (int i = 0; i < array.length; ++i) { |
| 874 array[i] = 1 + i; | 614 array[i] = 1 + i; |
| 875 } | 615 } |
| 876 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); | 616 Expect.listEquals([1, 2, 3, 4, 5, |
| 617 6, 7, 8, 9, 10], |
| 618 array); |
| 877 for (int i = 0; i < array.length; ++i) { | 619 for (int i = 0; i < array.length; ++i) { |
| 878 array[i] = 0x10000000000000000 + i; | 620 array[i] = 0x10000000000000000 + i; |
| 879 } | 621 } |
| 880 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); | 622 Expect.listEquals([0, 1, 2, 3, 4, |
| 623 5, 6, 7, 8, 9], |
| 624 array); |
| 881 for (int i = 0; i < array.length; ++i) { | 625 for (int i = 0; i < array.length; ++i) { |
| 882 array[i] = 0xFFFFFFFFFFFFFFFF - i; | 626 array[i] = 0xFFFFFFFFFFFFFFFF - i; |
| 883 } | 627 } |
| 884 Expect.listEquals([ | 628 Expect.listEquals([0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFE, |
| 885 0xFFFFFFFFFFFFFFFF, | 629 0xFFFFFFFFFFFFFFFD, 0xFFFFFFFFFFFFFFFC, |
| 886 0xFFFFFFFFFFFFFFFE, | 630 0xFFFFFFFFFFFFFFFB, 0xFFFFFFFFFFFFFFFA, |
| 887 0xFFFFFFFFFFFFFFFD, | 631 0xFFFFFFFFFFFFFFF9, 0xFFFFFFFFFFFFFFF8, |
| 888 0xFFFFFFFFFFFFFFFC, | 632 0xFFFFFFFFFFFFFFF7, 0xFFFFFFFFFFFFFFF6], |
| 889 0xFFFFFFFFFFFFFFFB, | 633 array); |
| 890 0xFFFFFFFFFFFFFFFA, | |
| 891 0xFFFFFFFFFFFFFFF9, | |
| 892 0xFFFFFFFFFFFFFFF8, | |
| 893 0xFFFFFFFFFFFFFFF7, | |
| 894 0xFFFFFFFFFFFFFFF6 | |
| 895 ], array); | |
| 896 for (int i = 0; i < array.length; ++i) { | 634 for (int i = 0; i < array.length; ++i) { |
| 897 array[i] = i; | 635 array[i] = i; |
| 898 } | 636 } |
| 899 var copy = array.sublist(0, array.length); | 637 var copy = array.sublist(0, array.length); |
| 900 Expect.isFalse(identical(copy, array)); | 638 Expect.isFalse(identical(copy, array)); |
| 901 Expect.isTrue(copy is Uint64List); | 639 Expect.isTrue(copy is Uint64List); |
| 902 Expect.equals(10, copy.length); | 640 Expect.equals(10, copy.length); |
| 903 Expect.listEquals(array, copy); | 641 Expect.listEquals(array, copy); |
| 904 var empty = array.sublist(array.length, array.length); | 642 var empty = array.sublist(array.length, array.length); |
| 905 Expect.equals(0, empty.length); | 643 Expect.equals(0, empty.length); |
| 906 var region = array.sublist(3, array.length - 3); | 644 var region = array.sublist(3, array.length - 3); |
| 907 Expect.isTrue(copy is Uint64List); | 645 Expect.isTrue(copy is Uint64List); |
| 908 Expect.equals(4, region.length); | 646 Expect.equals(4, region.length); |
| 909 Expect.listEquals([3, 4, 5, 6], region); | 647 Expect.listEquals([3, 4, 5, 6], region); |
| 910 array.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); | 648 array.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); |
| 911 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], array); | 649 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], |
| 650 array); |
| 912 } | 651 } |
| 913 | 652 |
| 914 static testUint64List() { | 653 static testUint64List() { |
| 915 Expect.throws(() { | 654 Expect.throws(() { new Uint64List(-1); }, |
| 916 new Uint64List(-1); | 655 (e) { return e is ArgumentError; }); |
| 917 }, (e) { | |
| 918 return e is ArgumentError; | |
| 919 }); | |
| 920 var array = new Uint64List(10); | 656 var array = new Uint64List(10); |
| 921 testUint64ListImpl(array); | 657 testUint64ListImpl(array); |
| 922 } | 658 } |
| 923 | 659 |
| 924 static testFloat32ListImpl(Float32List array) { | 660 static testFloat32ListImpl(Float32List array) { |
| 925 Expect.isTrue(array is List<double>); | 661 Expect.isTrue(array is List<double>); |
| 926 Expect.equals(10, array.length); | 662 Expect.equals(10, array.length); |
| 927 Expect.equals(4, array.elementSizeInBytes); | 663 Expect.equals(4, array.elementSizeInBytes); |
| 928 Expect.equals(40, array.lengthInBytes); | 664 Expect.equals(40, array.lengthInBytes); |
| 929 Expect | 665 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, |
| 930 .listEquals([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], array); | 666 0.0, 0.0, 0.0, 0.0, 0.0], |
| 931 Expect.throws(() { | 667 array); |
| 932 array[-1] = 0.0; | 668 Expect.throws(() { array[-1] = 0.0; }, |
| 933 }, (e) { | 669 (e) { return e is RangeError; }); |
| 934 return e is RangeError; | 670 Expect.throws(() { return array[-1]; }, |
| 935 }); | 671 (e) { return e is RangeError; }); |
| 936 Expect.throws(() { | 672 Expect.throws(() { array[10]; }, |
| 937 return array[-1]; | 673 (e) { return e is RangeError; }); |
| 938 }, (e) { | 674 Expect.throws(() { array[10] = 0.0; }, |
| 939 return e is RangeError; | 675 (e) { return e is RangeError; }); |
| 940 }); | 676 Expect.throws(() { array.add(0.0); }, |
| 941 Expect.throws(() { | 677 (e) { return e is UnsupportedError; }); |
| 942 array[10]; | 678 Expect.throws(() { array.addAll([0]); }, |
| 943 }, (e) { | 679 (e) { return e is UnsupportedError; }); |
| 944 return e is RangeError; | 680 Expect.throws(() { array.clear(); }, |
| 945 }); | 681 (e) { return e is UnsupportedError; }); |
| 946 Expect.throws(() { | 682 Expect.throws(() { array.length = 0; }, |
| 947 array[10] = 0.0; | 683 (e) { return e is UnsupportedError; }); |
| 948 }, (e) { | 684 Expect.throws(() { array.removeLast(); }, |
| 949 return e is RangeError; | 685 (e) { return e is UnsupportedError; }); |
| 950 }); | 686 Expect.throws(() { array.removeRange(0, array.length - 1); }, |
| 951 Expect.throws(() { | 687 (e) { return e is UnsupportedError; }); |
| 952 array.add(0.0); | |
| 953 }, (e) { | |
| 954 return e is UnsupportedError; | |
| 955 }); | |
| 956 Expect.throws(() { | |
| 957 array.addAll([0]); | |
| 958 }, (e) { | |
| 959 return e is UnsupportedError; | |
| 960 }); | |
| 961 Expect.throws(() { | |
| 962 array.clear(); | |
| 963 }, (e) { | |
| 964 return e is UnsupportedError; | |
| 965 }); | |
| 966 Expect.throws(() { | |
| 967 array.length = 0; | |
| 968 }, (e) { | |
| 969 return e is UnsupportedError; | |
| 970 }); | |
| 971 Expect.throws(() { | |
| 972 array.removeLast(); | |
| 973 }, (e) { | |
| 974 return e is UnsupportedError; | |
| 975 }); | |
| 976 Expect.throws(() { | |
| 977 array.removeRange(0, array.length - 1); | |
| 978 }, (e) { | |
| 979 return e is UnsupportedError; | |
| 980 }); | |
| 981 for (int i = 0; i < array.length; ++i) { | 688 for (int i = 0; i < array.length; ++i) { |
| 982 array[i] = 1.0 + i; | 689 array[i] = 1.0 + i; |
| 983 } | 690 } |
| 984 Expect | 691 Expect.listEquals([1.0, 2.0, 3.0, 4.0, 5.0, |
| 985 .listEquals([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], array); | 692 6.0, 7.0, 8.0, 9.0, 10.0], |
| 693 array); |
| 986 // TODO: min, max, and round | 694 // TODO: min, max, and round |
| 987 for (int i = 0; i < array.length; ++i) { | 695 for (int i = 0; i < array.length; ++i) { |
| 988 array[i] = i * 1.0; | 696 array[i] = i * 1.0; |
| 989 } | 697 } |
| 990 var copy = array.sublist(0, array.length); | 698 var copy = array.sublist(0, array.length); |
| 991 Expect.isFalse(identical(copy, array)); | 699 Expect.isFalse(identical(copy, array)); |
| 992 Expect.isTrue(copy is Float32List); | 700 Expect.isTrue(copy is Float32List); |
| 993 Expect.equals(10, copy.length); | 701 Expect.equals(10, copy.length); |
| 994 Expect.listEquals(array, copy); | 702 Expect.listEquals(array, copy); |
| 995 var empty = array.sublist(array.length, array.length); | 703 var empty = array.sublist(array.length, array.length); |
| 996 Expect.equals(0, empty.length); | 704 Expect.equals(0, empty.length); |
| 997 var region = array.sublist(3, array.length - 3); | 705 var region = array.sublist(3, array.length - 3); |
| 998 Expect.isTrue(copy is Float32List); | 706 Expect.isTrue(copy is Float32List); |
| 999 Expect.equals(4, region.length); | 707 Expect.equals(4, region.length); |
| 1000 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 708 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
| 1001 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 709 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
| 1002 Expect.listEquals([ | 710 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
| 1003 0.0, | 711 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
| 1004 1.0, | 712 array); |
| 1005 2.0, | |
| 1006 double.NEGATIVE_INFINITY, | |
| 1007 0.0, | |
| 1008 1.0, | |
| 1009 double.INFINITY, | |
| 1010 7.0, | |
| 1011 8.0, | |
| 1012 9.0 | |
| 1013 ], array); | |
| 1014 } | 713 } |
| 1015 | 714 |
| 1016 static testFloat32List() { | 715 static testFloat32List() { |
| 1017 Expect.throws(() { | 716 Expect.throws(() { new Float32List(-1); }, |
| 1018 new Float32List(-1); | 717 (e) { return e is ArgumentError; }); |
| 1019 }, (e) { | |
| 1020 return e is ArgumentError; | |
| 1021 }); | |
| 1022 var array = new Float32List(10); | 718 var array = new Float32List(10); |
| 1023 testFloat32ListImpl(array); | 719 testFloat32ListImpl(array); |
| 1024 } | 720 } |
| 1025 | 721 |
| 1026 static testFloat64ListImpl(Float64List array) { | 722 static testFloat64ListImpl(Float64List array) { |
| 1027 Expect.isTrue(array is List<double>); | 723 Expect.isTrue(array is List<double>); |
| 1028 Expect.equals(10, array.length); | 724 Expect.equals(10, array.length); |
| 1029 Expect.equals(8, array.elementSizeInBytes); | 725 Expect.equals(8, array.elementSizeInBytes); |
| 1030 Expect.equals(80, array.lengthInBytes); | 726 Expect.equals(80, array.lengthInBytes); |
| 1031 Expect | 727 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, |
| 1032 .listEquals([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], array); | 728 0.0, 0.0, 0.0, 0.0, 0.0], |
| 1033 Expect.throws(() { | 729 array); |
| 1034 array[-1] = 0.0; | 730 Expect.throws(() { array[-1] = 0.0; }, |
| 1035 }, (e) { | 731 (e) { return e is RangeError; }); |
| 1036 return e is RangeError; | 732 Expect.throws(() { return array[-1]; }, |
| 1037 }); | 733 (e) { return e is RangeError; }); |
| 1038 Expect.throws(() { | 734 Expect.throws(() { array[10]; }, |
| 1039 return array[-1]; | 735 (e) { return e is RangeError; }); |
| 1040 }, (e) { | 736 Expect.throws(() { array[10] = 0.0; }, |
| 1041 return e is RangeError; | 737 (e) { return e is RangeError; }); |
| 1042 }); | 738 Expect.throws(() { array.add(0.0); }, |
| 1043 Expect.throws(() { | 739 (e) { return e is UnsupportedError; }); |
| 1044 array[10]; | 740 Expect.throws(() { array.addAll([0]); }, |
| 1045 }, (e) { | 741 (e) { return e is UnsupportedError; }); |
| 1046 return e is RangeError; | 742 Expect.throws(() { array.clear(); }, |
| 1047 }); | 743 (e) { return e is UnsupportedError; }); |
| 1048 Expect.throws(() { | 744 Expect.throws(() { array.length = 0; }, |
| 1049 array[10] = 0.0; | 745 (e) { return e is UnsupportedError; }); |
| 1050 }, (e) { | 746 Expect.throws(() { array.removeLast(); }, |
| 1051 return e is RangeError; | 747 (e) { return e is UnsupportedError; }); |
| 1052 }); | 748 Expect.throws(() { array.removeRange(0, array.length - 1); }, |
| 1053 Expect.throws(() { | 749 (e) { return e is UnsupportedError; }); |
| 1054 array.add(0.0); | |
| 1055 }, (e) { | |
| 1056 return e is UnsupportedError; | |
| 1057 }); | |
| 1058 Expect.throws(() { | |
| 1059 array.addAll([0]); | |
| 1060 }, (e) { | |
| 1061 return e is UnsupportedError; | |
| 1062 }); | |
| 1063 Expect.throws(() { | |
| 1064 array.clear(); | |
| 1065 }, (e) { | |
| 1066 return e is UnsupportedError; | |
| 1067 }); | |
| 1068 Expect.throws(() { | |
| 1069 array.length = 0; | |
| 1070 }, (e) { | |
| 1071 return e is UnsupportedError; | |
| 1072 }); | |
| 1073 Expect.throws(() { | |
| 1074 array.removeLast(); | |
| 1075 }, (e) { | |
| 1076 return e is UnsupportedError; | |
| 1077 }); | |
| 1078 Expect.throws(() { | |
| 1079 array.removeRange(0, array.length - 1); | |
| 1080 }, (e) { | |
| 1081 return e is UnsupportedError; | |
| 1082 }); | |
| 1083 for (int i = 0; i < array.length; ++i) { | 750 for (int i = 0; i < array.length; ++i) { |
| 1084 array[i] = 1.0 + i; | 751 array[i] = 1.0 + i; |
| 1085 } | 752 } |
| 1086 Expect | 753 Expect.listEquals([1.0, 2.0, 3.0, 4.0, 5.0, |
| 1087 .listEquals([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], array); | 754 6.0, 7.0, 8.0, 9.0, 10.0], |
| 755 array); |
| 1088 // TODO: min, max | 756 // TODO: min, max |
| 1089 for (int i = 0; i < array.length; ++i) { | 757 for (int i = 0; i < array.length; ++i) { |
| 1090 array[i] = i * 1.0; | 758 array[i] = i * 1.0; |
| 1091 } | 759 } |
| 1092 var copy = array.sublist(0, array.length); | 760 var copy = array.sublist(0, array.length); |
| 1093 Expect.isFalse(identical(copy, array)); | 761 Expect.isFalse(identical(copy, array)); |
| 1094 Expect.isTrue(copy is Float64List); | 762 Expect.isTrue(copy is Float64List); |
| 1095 Expect.equals(10, copy.length); | 763 Expect.equals(10, copy.length); |
| 1096 Expect.listEquals(array, copy); | 764 Expect.listEquals(array, copy); |
| 1097 var empty = array.sublist(array.length, array.length); | 765 var empty = array.sublist(array.length, array.length); |
| 1098 Expect.equals(0, empty.length); | 766 Expect.equals(0, empty.length); |
| 1099 var region = array.sublist(3, array.length - 3); | 767 var region = array.sublist(3, array.length - 3); |
| 1100 Expect.isTrue(copy is Float64List); | 768 Expect.isTrue(copy is Float64List); |
| 1101 Expect.equals(4, region.length); | 769 Expect.equals(4, region.length); |
| 1102 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 770 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
| 1103 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 771 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
| 1104 Expect.listEquals([ | 772 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
| 1105 0.0, | 773 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
| 1106 1.0, | 774 array); |
| 1107 2.0, | |
| 1108 double.NEGATIVE_INFINITY, | |
| 1109 0.0, | |
| 1110 1.0, | |
| 1111 double.INFINITY, | |
| 1112 7.0, | |
| 1113 8.0, | |
| 1114 9.0 | |
| 1115 ], array); | |
| 1116 } | 775 } |
| 1117 | 776 |
| 1118 static testFloat64List() { | 777 static testFloat64List() { |
| 1119 Expect.throws(() { | 778 Expect.throws(() { new Float64List(-1); }, |
| 1120 new Float64List(-1); | 779 (e) { return e is ArgumentError; }); |
| 1121 }, (e) { | |
| 1122 return e is ArgumentError; | |
| 1123 }); | |
| 1124 var array = new Float64List(10); | 780 var array = new Float64List(10); |
| 1125 testFloat64ListImpl(array); | 781 testFloat64ListImpl(array); |
| 1126 } | 782 } |
| 1127 | 783 |
| 1128 static testInt8ListViewImpl(var array) { | 784 static testInt8ListViewImpl(var array) { |
| 1129 Expect.equals(12, array.length); | 785 Expect.equals(12, array.length); |
| 1130 Expect.equals(1, array.elementSizeInBytes); | 786 Expect.equals(1, array.elementSizeInBytes); |
| 1131 Expect.equals(12, array.lengthInBytes); | 787 Expect.equals(12, array.lengthInBytes); |
| 1132 for (int i = 0; i < array.length; ++i) { | 788 for (int i = 0; i < array.length; ++i) { |
| 1133 array[i] = 0xFF; | 789 array[i] = 0xFF; |
| 1134 } | 790 } |
| 1135 Expect.throws(() { | 791 Expect.throws(() { new Int8List.view(array.buffer, -1); }, |
| 1136 new Int8List.view(array.buffer, -1); | 792 (e) { return e is RangeError; }); |
| 1137 }, (e) { | 793 Expect.throws(() { new Int8List.view(array.buffer, 0, -1); }, |
| 1138 return e is RangeError; | 794 (e) { return e is RangeError; }); |
| 1139 }); | 795 Expect.throws(() { new Int8List.view(array.buffer, |
| 1140 Expect.throws(() { | 796 array.lengthInBytes + 1); }, |
| 1141 new Int8List.view(array.buffer, 0, -1); | 797 (e) { return e is RangeError; }); |
| 1142 }, (e) { | 798 Expect.throws(() { new Int8List.view(array.buffer, |
| 1143 return e is RangeError; | 799 0, array.length + 1); }, |
| 1144 }); | 800 (e) { return e is RangeError; }); |
| 1145 Expect.throws(() { | 801 Expect.throws(() { new Int8List.view(array.buffer, |
| 1146 new Int8List.view(array.buffer, array.lengthInBytes + 1); | 802 array.length - 1, 2); }, |
| 1147 }, (e) { | 803 (e) { return e is RangeError; }); |
| 1148 return e is RangeError; | 804 var empty = new Int8List.view(array.buffer, |
| 1149 }); | 805 array.lengthInBytes); |
| 1150 Expect.throws(() { | |
| 1151 new Int8List.view(array.buffer, 0, array.length + 1); | |
| 1152 }, (e) { | |
| 1153 return e is RangeError; | |
| 1154 }); | |
| 1155 Expect.throws(() { | |
| 1156 new Int8List.view(array.buffer, array.length - 1, 2); | |
| 1157 }, (e) { | |
| 1158 return e is RangeError; | |
| 1159 }); | |
| 1160 var empty = new Int8List.view(array.buffer, array.lengthInBytes); | |
| 1161 Expect.isTrue(empty is List<int>); | 806 Expect.isTrue(empty is List<int>); |
| 1162 Expect.isTrue(empty is Int8List); | 807 Expect.isTrue(empty is Int8List); |
| 1163 Expect.equals(0, empty.length); | 808 Expect.equals(0, empty.length); |
| 1164 var whole = new Int8List.view(array.buffer); | 809 var whole = new Int8List.view(array.buffer); |
| 1165 Expect.isTrue(whole is List<int>); | 810 Expect.isTrue(whole is List<int>); |
| 1166 Expect.isTrue(whole is Int8List); | 811 Expect.isTrue(whole is Int8List); |
| 1167 Expect.equals(12, whole.length); | 812 Expect.equals(12, whole.length); |
| 1168 var view = new Int8List.view(array.buffer, 1, array.length - 2); | 813 var view = new Int8List.view(array.buffer, 1, array.length - 2); |
| 1169 Expect.isTrue(view is List<int>); | 814 Expect.isTrue(view is List<int>); |
| 1170 Expect.isTrue(view is Int8List); | 815 Expect.isTrue(view is Int8List); |
| 1171 Expect.equals(10, view.length); | 816 Expect.equals(10, view.length); |
| 1172 Expect.equals(1, view.elementSizeInBytes); | 817 Expect.equals(1, view.elementSizeInBytes); |
| 1173 Expect.equals(10, view.lengthInBytes); | 818 Expect.equals(10, view.lengthInBytes); |
| 1174 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], view); | 819 Expect.listEquals([-1, -1, -1, -1, -1, |
| 1175 Expect.throws(() { | 820 -1, -1, -1, -1, -1], |
| 1176 view[-1] = 0; | 821 view); |
| 1177 }, (e) { | 822 Expect.throws(() { view[-1] = 0; }, |
| 1178 return e is RangeError; | 823 (e) { return e is RangeError; }); |
| 1179 }); | 824 Expect.throws(() { return view[-1]; }, |
| 1180 Expect.throws(() { | 825 (e) { return e is RangeError; }); |
| 1181 return view[-1]; | 826 Expect.throws(() { view[view.length]; }, |
| 1182 }, (e) { | 827 (e) { return e is RangeError; }); |
| 1183 return e is RangeError; | 828 Expect.throws(() { view[10] = 0; }, |
| 1184 }); | 829 (e) { return e is RangeError; }); |
| 1185 Expect.throws(() { | 830 Expect.throws(() { view.add(0); }, |
| 1186 view[view.length]; | 831 (e) { return e is UnsupportedError; }); |
| 1187 }, (e) { | 832 Expect.throws(() { view.addAll([0]); }, |
| 1188 return e is RangeError; | 833 (e) { return e is UnsupportedError; }); |
| 1189 }); | 834 Expect.throws(() { view.clear(); }, |
| 1190 Expect.throws(() { | 835 (e) { return e is UnsupportedError; }); |
| 1191 view[10] = 0; | 836 Expect.throws(() { view.length = 0; }, |
| 1192 }, (e) { | 837 (e) { return e is UnsupportedError; }); |
| 1193 return e is RangeError; | 838 Expect.throws(() { view.removeLast(); }, |
| 1194 }); | 839 (e) { return e is UnsupportedError; }); |
| 1195 Expect.throws(() { | 840 Expect.throws(() { view.removeRange(0, view.length - 1); }, |
| 1196 view.add(0); | 841 (e) { return e is UnsupportedError; }); |
| 1197 }, (e) { | |
| 1198 return e is UnsupportedError; | |
| 1199 }); | |
| 1200 Expect.throws(() { | |
| 1201 view.addAll([0]); | |
| 1202 }, (e) { | |
| 1203 return e is UnsupportedError; | |
| 1204 }); | |
| 1205 Expect.throws(() { | |
| 1206 view.clear(); | |
| 1207 }, (e) { | |
| 1208 return e is UnsupportedError; | |
| 1209 }); | |
| 1210 Expect.throws(() { | |
| 1211 view.length = 0; | |
| 1212 }, (e) { | |
| 1213 return e is UnsupportedError; | |
| 1214 }); | |
| 1215 Expect.throws(() { | |
| 1216 view.removeLast(); | |
| 1217 }, (e) { | |
| 1218 return e is UnsupportedError; | |
| 1219 }); | |
| 1220 Expect.throws(() { | |
| 1221 view.removeRange(0, view.length - 1); | |
| 1222 }, (e) { | |
| 1223 return e is UnsupportedError; | |
| 1224 }); | |
| 1225 for (int i = 0; i < view.length; ++i) { | 842 for (int i = 0; i < view.length; ++i) { |
| 1226 view[i] = 1 + i; | 843 view[i] = 1 + i; |
| 1227 } | 844 } |
| 1228 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); | 845 Expect.listEquals([1, 2, 3, 4, 5, |
| 1229 Expect.listEquals([0xFF, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0xFF], array); | 846 6, 7, 8, 9, 10], |
| 847 view); |
| 848 Expect.listEquals([0xFF, 1, 2, 3, 4, 5, |
| 849 6, 7, 8, 9, 10, 0xFF], |
| 850 array); |
| 1230 for (int i = 0; i < view.length; ++i) { | 851 for (int i = 0; i < view.length; ++i) { |
| 1231 view[i] = 0x100 + i; | 852 view[i] = 0x100 + i; |
| 1232 } | 853 } |
| 1233 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); | 854 Expect.listEquals([0, 1, 2, 3, 4, |
| 1234 Expect.listEquals([0xFF, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xFF], array); | 855 5, 6, 7, 8, 9], |
| 856 view); |
| 857 Expect.listEquals([0xFF, 0, 1, 2, 3, 4, |
| 858 5, 6, 7, 8, 9, 0xFF], |
| 859 array); |
| 1235 for (int i = 0; i < view.length; ++i) { | 860 for (int i = 0; i < view.length; ++i) { |
| 1236 view[i] = -10 + i; | 861 view[i] = -10 + i; |
| 1237 } | 862 } |
| 1238 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], view); | 863 Expect.listEquals([-10, -9, -8, -7, -6, |
| 1239 Expect.listEquals([ | 864 -5, -4, -3, -2, -1], |
| 1240 0xFF, | 865 view); |
| 1241 0xF6, | 866 Expect.listEquals([0xFF, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, |
| 1242 0xF7, | 867 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0xFF], |
| 1243 0xF8, | 868 array); |
| 1244 0xF9, | |
| 1245 0xFA, | |
| 1246 0xFB, | |
| 1247 0xFC, | |
| 1248 0xFD, | |
| 1249 0xFE, | |
| 1250 0xFF, | |
| 1251 0xFF | |
| 1252 ], array); | |
| 1253 for (int i = 0; i < view.length; ++i) { | 869 for (int i = 0; i < view.length; ++i) { |
| 1254 view[i] = 0x7F - i; | 870 view[i] = 0x7F - i; |
| 1255 } | 871 } |
| 1256 Expect.listEquals([127, 126, 125, 124, 123, 122, 121, 120, 119, 118], view); | 872 Expect.listEquals([127, 126, 125, 124, 123, |
| 1257 Expect.listEquals( | 873 122, 121, 120, 119, 118], |
| 1258 [0xFF, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 0xFF], array); | 874 view); |
| 875 Expect.listEquals([0xFF, 127, 126, 125, 124, 123, |
| 876 122, 121, 120, 119, 118, 0xFF], |
| 877 array); |
| 1259 for (int i = 0; i < view.length; ++i) { | 878 for (int i = 0; i < view.length; ++i) { |
| 1260 view[i] = -0x80 + i; | 879 view[i] = -0x80 + i; |
| 1261 } | 880 } |
| 1262 Expect.listEquals( | 881 Expect.listEquals([-128, -127, -126, -125, -124, |
| 1263 [-128, -127, -126, -125, -124, -123, -122, -121, -120, -119], view); | 882 -123, -122, -121, -120, -119], |
| 1264 Expect.listEquals([ | 883 view); |
| 1265 0xFF, | 884 Expect.listEquals([0xFF, 0x80, 0x81, 0x82, 0x83, 0x84, |
| 1266 0x80, | 885 0x85, 0x86, 0x87, 0x88, 0x89, 0xFF], |
| 1267 0x81, | 886 array); |
| 1268 0x82, | |
| 1269 0x83, | |
| 1270 0x84, | |
| 1271 0x85, | |
| 1272 0x86, | |
| 1273 0x87, | |
| 1274 0x88, | |
| 1275 0x89, | |
| 1276 0xFF | |
| 1277 ], array); | |
| 1278 for (int i = 0; i < view.length; ++i) { | 887 for (int i = 0; i < view.length; ++i) { |
| 1279 view[i] = i; | 888 view[i] = i; |
| 1280 } | 889 } |
| 1281 var copy = view.sublist(0, view.length); | 890 var copy = view.sublist(0, view.length); |
| 1282 Expect.isFalse(identical(copy, view)); | 891 Expect.isFalse(identical(copy, view)); |
| 1283 Expect.isTrue(copy is Int8List); | 892 Expect.isTrue(copy is Int8List); |
| 1284 Expect.equals(10, copy.length); | 893 Expect.equals(10, copy.length); |
| 1285 Expect.listEquals(view, copy); | 894 Expect.listEquals(view, copy); |
| 1286 var region = view.sublist(3, view.length - 3); | 895 var region = view.sublist(3, view.length - 3); |
| 1287 Expect.isTrue(copy is Int8List); | 896 Expect.isTrue(copy is Int8List); |
| 1288 Expect.equals(4, region.length); | 897 Expect.equals(4, region.length); |
| 1289 Expect.listEquals([3, 4, 5, 6], region); | 898 Expect.listEquals([3, 4, 5, 6], region); |
| 1290 view.setRange(3, 7, [-128, 0, 1, 127]); | 899 view.setRange(3, 7, [-128, 0, 1, 127]); |
| 1291 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], view); | 900 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], |
| 1292 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF], array); | 901 view); |
| 902 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF], |
| 903 array); |
| 1293 } | 904 } |
| 1294 | |
| 1295 static testInt8ListView() { | 905 static testInt8ListView() { |
| 1296 var array = new Uint8List(12); | 906 var array = new Uint8List(12); |
| 1297 testInt8ListViewImpl(array); | 907 testInt8ListViewImpl(array); |
| 1298 } | 908 } |
| 1299 | 909 |
| 1300 static testUint8ListViewImpl(var array) { | 910 static testUint8ListViewImpl(var array) { |
| 1301 Expect.isTrue(array is List<int>); | 911 Expect.isTrue(array is List<int>); |
| 1302 Expect.equals(12, array.length); | 912 Expect.equals(12, array.length); |
| 1303 Expect.equals(1, array.elementSizeInBytes); | 913 Expect.equals(1, array.elementSizeInBytes); |
| 1304 Expect.equals(12, array.lengthInBytes); | 914 Expect.equals(12, array.lengthInBytes); |
| 1305 for (int i = 0; i < array.length; ++i) { | 915 for (int i = 0; i < array.length; ++i) { |
| 1306 array[i] = -1; | 916 array[i] = -1; |
| 1307 } | 917 } |
| 1308 Expect.throws(() { | 918 Expect.throws(() { new Uint8List.view(array.buffer, -1); }, |
| 1309 new Uint8List.view(array.buffer, -1); | 919 (e) { return e is RangeError; }); |
| 1310 }, (e) { | 920 Expect.throws(() { new Uint8List.view(array.buffer, 0, -1); }, |
| 1311 return e is RangeError; | 921 (e) { return e is RangeError; }); |
| 1312 }); | 922 Expect.throws(() { new Uint8List.view(array.buffer, |
| 1313 Expect.throws(() { | 923 array.lengthInBytes + 1); }, |
| 1314 new Uint8List.view(array.buffer, 0, -1); | 924 (e) { return e is RangeError; }); |
| 1315 }, (e) { | 925 Expect.throws(() { new Uint8List.view(array.buffer, |
| 1316 return e is RangeError; | 926 0, array.length + 1); }, |
| 1317 }); | 927 (e) { return e is RangeError; }); |
| 1318 Expect.throws(() { | 928 Expect.throws(() { new Uint8List.view(array.buffer, |
| 1319 new Uint8List.view(array.buffer, array.lengthInBytes + 1); | 929 array.length - 1, 2); }, |
| 1320 }, (e) { | 930 (e) { return e is RangeError; }); |
| 1321 return e is RangeError; | 931 var empty = new Uint8List.view(array.buffer, |
| 1322 }); | 932 array.lengthInBytes); |
| 1323 Expect.throws(() { | |
| 1324 new Uint8List.view(array.buffer, 0, array.length + 1); | |
| 1325 }, (e) { | |
| 1326 return e is RangeError; | |
| 1327 }); | |
| 1328 Expect.throws(() { | |
| 1329 new Uint8List.view(array.buffer, array.length - 1, 2); | |
| 1330 }, (e) { | |
| 1331 return e is RangeError; | |
| 1332 }); | |
| 1333 var empty = new Uint8List.view(array.buffer, array.lengthInBytes); | |
| 1334 Expect.isTrue(empty is List<int>); | 933 Expect.isTrue(empty is List<int>); |
| 1335 Expect.isTrue(empty is Uint8List); | 934 Expect.isTrue(empty is Uint8List); |
| 1336 Expect.equals(0, empty.length); | 935 Expect.equals(0, empty.length); |
| 1337 var whole = new Uint8List.view(array.buffer); | 936 var whole = new Uint8List.view(array.buffer); |
| 1338 Expect.isTrue(whole is List<int>); | 937 Expect.isTrue(whole is List<int>); |
| 1339 Expect.isTrue(whole is Uint8List); | 938 Expect.isTrue(whole is Uint8List); |
| 1340 Expect.equals(12, whole.length); | 939 Expect.equals(12, whole.length); |
| 1341 var view = new Uint8List.view(array.buffer, 1, array.length - 2); | 940 var view = new Uint8List.view(array.buffer, 1, array.length - 2); |
| 1342 Expect.isTrue(view is List<int>); | 941 Expect.isTrue(view is List<int>); |
| 1343 Expect.isTrue(view is Uint8List); | 942 Expect.isTrue(view is Uint8List); |
| 1344 Expect.equals(10, view.length); | 943 Expect.equals(10, view.length); |
| 1345 Expect.equals(1, view.elementSizeInBytes); | 944 Expect.equals(1, view.elementSizeInBytes); |
| 1346 Expect.equals(10, view.lengthInBytes); | 945 Expect.equals(10, view.lengthInBytes); |
| 1347 Expect.listEquals( | 946 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 1348 [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], view); | 947 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
| 1349 Expect.throws(() { | 948 view); |
| 1350 view[-1] = 0; | 949 Expect.throws(() { view[-1] = 0; }, |
| 1351 }, (e) { | 950 (e) { return e is RangeError; }); |
| 1352 return e is RangeError; | 951 Expect.throws(() { return view[-1]; }, |
| 1353 }); | 952 (e) { return e is RangeError; }); |
| 1354 Expect.throws(() { | 953 Expect.throws(() { view[view.length]; }, |
| 1355 return view[-1]; | 954 (e) { return e is RangeError; }); |
| 1356 }, (e) { | 955 Expect.throws(() { view[view.length] = 0; }, |
| 1357 return e is RangeError; | 956 (e) { return e is RangeError; }); |
| 1358 }); | 957 Expect.throws(() { view.add(0); }, |
| 1359 Expect.throws(() { | 958 (e) { return e is UnsupportedError; }); |
| 1360 view[view.length]; | 959 Expect.throws(() { view.addAll([0]); }, |
| 1361 }, (e) { | 960 (e) { return e is UnsupportedError; }); |
| 1362 return e is RangeError; | 961 Expect.throws(() { view.clear(); }, |
| 1363 }); | 962 (e) { return e is UnsupportedError; }); |
| 1364 Expect.throws(() { | 963 Expect.throws(() { view.length = 0; }, |
| 1365 view[view.length] = 0; | 964 (e) { return e is UnsupportedError; }); |
| 1366 }, (e) { | 965 Expect.throws(() { view.removeLast(); }, |
| 1367 return e is RangeError; | 966 (e) { return e is UnsupportedError; }); |
| 1368 }); | 967 Expect.throws(() { view.removeRange(0, view.length - 1); }, |
| 1369 Expect.throws(() { | 968 (e) { return e is UnsupportedError; }); |
| 1370 view.add(0); | |
| 1371 }, (e) { | |
| 1372 return e is UnsupportedError; | |
| 1373 }); | |
| 1374 Expect.throws(() { | |
| 1375 view.addAll([0]); | |
| 1376 }, (e) { | |
| 1377 return e is UnsupportedError; | |
| 1378 }); | |
| 1379 Expect.throws(() { | |
| 1380 view.clear(); | |
| 1381 }, (e) { | |
| 1382 return e is UnsupportedError; | |
| 1383 }); | |
| 1384 Expect.throws(() { | |
| 1385 view.length = 0; | |
| 1386 }, (e) { | |
| 1387 return e is UnsupportedError; | |
| 1388 }); | |
| 1389 Expect.throws(() { | |
| 1390 view.removeLast(); | |
| 1391 }, (e) { | |
| 1392 return e is UnsupportedError; | |
| 1393 }); | |
| 1394 Expect.throws(() { | |
| 1395 view.removeRange(0, view.length - 1); | |
| 1396 }, (e) { | |
| 1397 return e is UnsupportedError; | |
| 1398 }); | |
| 1399 for (int i = 0; i < view.length; ++i) { | 969 for (int i = 0; i < view.length; ++i) { |
| 1400 view[i] = 1 + i; | 970 view[i] = 1 + i; |
| 1401 } | 971 } |
| 1402 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); | 972 Expect.listEquals([1, 2, 3, 4, 5, |
| 1403 Expect.listEquals([-1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1], array); | 973 6, 7, 8, 9, 10], |
| 974 view); |
| 975 Expect.listEquals([-1, 1, 2, 3, 4, 5, |
| 976 6, 7, 8, 9, 10, -1], |
| 977 array); |
| 1404 for (int i = 0; i < view.length; ++i) { | 978 for (int i = 0; i < view.length; ++i) { |
| 1405 view[i] = 0x100 + i; | 979 view[i] = 0x100 + i; |
| 1406 } | 980 } |
| 1407 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); | 981 Expect.listEquals([0, 1, 2, 3, 4, |
| 1408 Expect.listEquals([-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1], array); | 982 5, 6, 7, 8, 9], |
| 983 view); |
| 984 Expect.listEquals([-1, 0, 1, 2, 3, 4, |
| 985 5, 6, 7, 8, 9, -1], |
| 986 array); |
| 1409 for (int i = 0; i < view.length; ++i) { | 987 for (int i = 0; i < view.length; ++i) { |
| 1410 view[i] = 0xFF - i; | 988 view[i] = 0xFF - i; |
| 1411 } | 989 } |
| 1412 Expect.listEquals( | 990 Expect.listEquals([0xFF, 0xFE, 0xFD, 0xFC, 0xFB, |
| 1413 [0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], view); | 991 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], |
| 1414 Expect.listEquals([-1, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -1], array); | 992 view); |
| 993 Expect.listEquals([-1, -1, -2, -3, -4, -5, |
| 994 -6, -7, -8, -9, -10, -1], |
| 995 array); |
| 1415 for (int i = 0; i < view.length; ++i) { | 996 for (int i = 0; i < view.length; ++i) { |
| 1416 view[i] = i; | 997 view[i] = i; |
| 1417 } | 998 } |
| 1418 var copy = view.sublist(0, view.length); | 999 var copy = view.sublist(0, view.length); |
| 1419 Expect.isFalse(identical(copy, view)); | 1000 Expect.isFalse(identical(copy, view)); |
| 1420 Expect.isTrue(copy is Uint8List); | 1001 Expect.isTrue(copy is Uint8List); |
| 1421 Expect.equals(10, copy.length); | 1002 Expect.equals(10, copy.length); |
| 1422 Expect.listEquals(view, copy); | 1003 Expect.listEquals(view, copy); |
| 1423 var region = view.sublist(3, view.length - 3); | 1004 var region = view.sublist(3, view.length - 3); |
| 1424 Expect.isTrue(copy is Uint8List); | 1005 Expect.isTrue(copy is Uint8List); |
| 1425 Expect.equals(4, region.length); | 1006 Expect.equals(4, region.length); |
| 1426 Expect.listEquals([3, 4, 5, 6], region); | 1007 Expect.listEquals([3, 4, 5, 6], region); |
| 1427 view.setRange(3, 7, [257, 0, 1, 255]); | 1008 view.setRange(3, 7, [257, 0, 1, 255]); |
| 1428 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], view); | 1009 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], |
| 1010 view); |
| 1429 } | 1011 } |
| 1430 | 1012 |
| 1431 static testUint8ListView() { | 1013 static testUint8ListView() { |
| 1432 var array = new Int8List(12); | 1014 var array = new Int8List(12); |
| 1433 testUint8ListViewImpl(array); | 1015 testUint8ListViewImpl(array); |
| 1434 } | 1016 } |
| 1435 | 1017 |
| 1436 static testInt16ListViewImpl(var array) { | 1018 static testInt16ListViewImpl(var array) { |
| 1437 Expect.equals(24, array.length); | 1019 Expect.equals(24, array.length); |
| 1438 Expect.equals(1, array.elementSizeInBytes); | 1020 Expect.equals(1, array.elementSizeInBytes); |
| 1439 Expect.equals(24, array.lengthInBytes); | 1021 Expect.equals(24, array.lengthInBytes); |
| 1440 for (int i = 0; i < array.length; ++i) { | 1022 for (int i = 0; i < array.length; ++i) { |
| 1441 array[i] = 0xFF; | 1023 array[i] = 0xFF; |
| 1442 } | 1024 } |
| 1443 Expect.throws(() { | 1025 Expect.throws(() { new Int16List.view(array.buffer, -1); }, |
| 1444 new Int16List.view(array.buffer, -1); | 1026 (e) { return e is RangeError; }); |
| 1445 }, (e) { | 1027 Expect.throws(() { new Int16List.view(array.buffer, 0, -1); }, |
| 1446 return e is RangeError; | 1028 (e) { return e is RangeError; }); |
| 1447 }); | 1029 Expect.throws(() { new Int16List.view(array.buffer, |
| 1448 Expect.throws(() { | 1030 array.lengthInBytes + 1); }, |
| 1449 new Int16List.view(array.buffer, 0, -1); | 1031 (e) { return e is RangeError; }); |
| 1450 }, (e) { | 1032 Expect.throws(() { new Int16List.view(array.buffer, |
| 1451 return e is RangeError; | 1033 0, array.length + 1); }, |
| 1452 }); | 1034 (e) { return e is RangeError; }); |
| 1453 Expect.throws(() { | 1035 Expect.throws(() { new Int16List.view(array.buffer, |
| 1454 new Int16List.view(array.buffer, array.lengthInBytes + 1); | 1036 array.length - 1, 2); }, |
| 1455 }, (e) { | 1037 (e) { return e is RangeError; }); |
| 1456 return e is RangeError; | 1038 var empty = new Int16List.view(array.buffer, |
| 1457 }); | 1039 array.lengthInBytes); |
| 1458 Expect.throws(() { | |
| 1459 new Int16List.view(array.buffer, 0, array.length + 1); | |
| 1460 }, (e) { | |
| 1461 return e is RangeError; | |
| 1462 }); | |
| 1463 Expect.throws(() { | |
| 1464 new Int16List.view(array.buffer, array.length - 1, 2); | |
| 1465 }, (e) { | |
| 1466 return e is RangeError; | |
| 1467 }); | |
| 1468 var empty = new Int16List.view(array.buffer, array.lengthInBytes); | |
| 1469 Expect.isTrue(empty is List<int>); | 1040 Expect.isTrue(empty is List<int>); |
| 1470 Expect.isTrue(empty is Int16List); | 1041 Expect.isTrue(empty is Int16List); |
| 1471 Expect.equals(0, empty.length); | 1042 Expect.equals(0, empty.length); |
| 1472 var whole = new Int16List.view(array.buffer); | 1043 var whole = new Int16List.view(array.buffer); |
| 1473 Expect.isTrue(whole is List<int>); | 1044 Expect.isTrue(whole is List<int>); |
| 1474 Expect.isTrue(whole is Int16List); | 1045 Expect.isTrue(whole is Int16List); |
| 1475 Expect.equals(12, whole.length); | 1046 Expect.equals(12, whole.length); |
| 1476 var view = new Int16List.view(array.buffer, 2, 10); | 1047 var view = new Int16List.view(array.buffer, 2, 10); |
| 1477 Expect.isTrue(view is List<int>); | 1048 Expect.isTrue(view is List<int>); |
| 1478 Expect.isTrue(view is Int16List); | 1049 Expect.isTrue(view is Int16List); |
| 1479 Expect.equals(10, view.length); | 1050 Expect.equals(10, view.length); |
| 1480 Expect.equals(2, view.elementSizeInBytes); | 1051 Expect.equals(2, view.elementSizeInBytes); |
| 1481 Expect.equals(20, view.lengthInBytes); | 1052 Expect.equals(20, view.lengthInBytes); |
| 1482 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], view); | 1053 Expect.listEquals([-1, -1, -1, -1, -1, |
| 1483 Expect.throws(() { | 1054 -1, -1, -1, -1, -1], |
| 1484 view[-1] = 0; | 1055 view); |
| 1485 }, (e) { | 1056 Expect.throws(() { view[-1] = 0; }, |
| 1486 return e is RangeError; | 1057 (e) { return e is RangeError; }); |
| 1487 }); | 1058 Expect.throws(() { return view[-1]; }, |
| 1488 Expect.throws(() { | 1059 (e) { return e is RangeError; }); |
| 1489 return view[-1]; | 1060 Expect.throws(() { view[view.length]; }, |
| 1490 }, (e) { | 1061 (e) { return e is RangeError; }); |
| 1491 return e is RangeError; | 1062 Expect.throws(() { view[10] = 0; }, |
| 1492 }); | 1063 (e) { return e is RangeError; }); |
| 1493 Expect.throws(() { | 1064 Expect.throws(() { view.add(0); }, |
| 1494 view[view.length]; | 1065 (e) { return e is UnsupportedError; }); |
| 1495 }, (e) { | 1066 Expect.throws(() { view.addAll([0]); }, |
| 1496 return e is RangeError; | 1067 (e) { return e is UnsupportedError; }); |
| 1497 }); | 1068 Expect.throws(() { view.clear(); }, |
| 1498 Expect.throws(() { | 1069 (e) { return e is UnsupportedError; }); |
| 1499 view[10] = 0; | 1070 Expect.throws(() { view.length = 0; }, |
| 1500 }, (e) { | 1071 (e) { return e is UnsupportedError; }); |
| 1501 return e is RangeError; | 1072 Expect.throws(() { view.removeLast(); }, |
| 1502 }); | 1073 (e) { return e is UnsupportedError; }); |
| 1503 Expect.throws(() { | 1074 Expect.throws(() { view.removeRange(0, view.length - 1); }, |
| 1504 view.add(0); | 1075 (e) { return e is UnsupportedError; }); |
| 1505 }, (e) { | |
| 1506 return e is UnsupportedError; | |
| 1507 }); | |
| 1508 Expect.throws(() { | |
| 1509 view.addAll([0]); | |
| 1510 }, (e) { | |
| 1511 return e is UnsupportedError; | |
| 1512 }); | |
| 1513 Expect.throws(() { | |
| 1514 view.clear(); | |
| 1515 }, (e) { | |
| 1516 return e is UnsupportedError; | |
| 1517 }); | |
| 1518 Expect.throws(() { | |
| 1519 view.length = 0; | |
| 1520 }, (e) { | |
| 1521 return e is UnsupportedError; | |
| 1522 }); | |
| 1523 Expect.throws(() { | |
| 1524 view.removeLast(); | |
| 1525 }, (e) { | |
| 1526 return e is UnsupportedError; | |
| 1527 }); | |
| 1528 Expect.throws(() { | |
| 1529 view.removeRange(0, view.length - 1); | |
| 1530 }, (e) { | |
| 1531 return e is UnsupportedError; | |
| 1532 }); | |
| 1533 for (int i = 0; i < view.length; ++i) { | 1076 for (int i = 0; i < view.length; ++i) { |
| 1534 view[i] = 1 + i; | 1077 view[i] = 1 + i; |
| 1535 } | 1078 } |
| 1536 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); | 1079 Expect.listEquals([1, 2, 3, 4, 5, |
| 1537 Expect.listEquals([ | 1080 6, 7, 8, 9, 10], |
| 1538 0xFF, | 1081 view); |
| 1539 0xFF, | 1082 Expect.listEquals([0xFF, 0xFF, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, |
| 1540 0x01, | 1083 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, |
| 1541 0x00, | 1084 0x08, 0x00, 0x09, 0x00, 0x0A, 0x00, 0xFF, 0xFF], |
| 1542 0x02, | 1085 array); |
| 1543 0x00, | |
| 1544 0x03, | |
| 1545 0x00, | |
| 1546 0x04, | |
| 1547 0x00, | |
| 1548 0x05, | |
| 1549 0x00, | |
| 1550 0x06, | |
| 1551 0x00, | |
| 1552 0x07, | |
| 1553 0x00, | |
| 1554 0x08, | |
| 1555 0x00, | |
| 1556 0x09, | |
| 1557 0x00, | |
| 1558 0x0A, | |
| 1559 0x00, | |
| 1560 0xFF, | |
| 1561 0xFF | |
| 1562 ], array); | |
| 1563 for (int i = 0; i < view.length; ++i) { | 1086 for (int i = 0; i < view.length; ++i) { |
| 1564 view[i] = 0x10000 + i; | 1087 view[i] = 0x10000 + i; |
| 1565 } | 1088 } |
| 1566 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); | 1089 Expect.listEquals([0, 1, 2, 3, 4, |
| 1567 Expect.listEquals([ | 1090 5, 6, 7, 8, 9], |
| 1568 0xFF, | 1091 view); |
| 1569 0xFF, | 1092 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, |
| 1570 0x00, | 1093 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, |
| 1571 0x00, | 1094 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], |
| 1572 0x01, | 1095 array); |
| 1573 0x00, | |
| 1574 0x02, | |
| 1575 0x00, | |
| 1576 0x03, | |
| 1577 0x00, | |
| 1578 0x04, | |
| 1579 0x00, | |
| 1580 0x05, | |
| 1581 0x00, | |
| 1582 0x06, | |
| 1583 0x00, | |
| 1584 0x07, | |
| 1585 0x00, | |
| 1586 0x08, | |
| 1587 0x00, | |
| 1588 0x09, | |
| 1589 0x00, | |
| 1590 0xFF, | |
| 1591 0xFF | |
| 1592 ], array); | |
| 1593 for (int i = 0; i < view.length; ++i) { | 1096 for (int i = 0; i < view.length; ++i) { |
| 1594 view[i] = -10 + i; | 1097 view[i] = -10 + i; |
| 1595 } | 1098 } |
| 1596 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], view); | 1099 Expect.listEquals([-10, -9, -8, -7, -6, |
| 1597 Expect.listEquals([ | 1100 -5, -4, -3, -2, -1], |
| 1598 0xFF, | 1101 view); |
| 1599 0xFF, | 1102 Expect.listEquals([0xFF, 0xFF, 0xF6, 0xFF, 0xF7, 0xFF, 0xF8, 0xFF, |
| 1600 0xF6, | 1103 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, |
| 1601 0xFF, | 1104 0xFD, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
| 1602 0xF7, | 1105 array); |
| 1603 0xFF, | |
| 1604 0xF8, | |
| 1605 0xFF, | |
| 1606 0xF9, | |
| 1607 0xFF, | |
| 1608 0xFA, | |
| 1609 0xFF, | |
| 1610 0xFB, | |
| 1611 0xFF, | |
| 1612 0xFC, | |
| 1613 0xFF, | |
| 1614 0xFD, | |
| 1615 0xFF, | |
| 1616 0xFE, | |
| 1617 0xFF, | |
| 1618 0xFF, | |
| 1619 0xFF, | |
| 1620 0xFF, | |
| 1621 0xFF | |
| 1622 ], array); | |
| 1623 for (int i = 0; i < view.length; ++i) { | 1106 for (int i = 0; i < view.length; ++i) { |
| 1624 view[i] = 0x7FFF - i; | 1107 view[i] = 0x7FFF - i; |
| 1625 } | 1108 } |
| 1626 Expect.listEquals([ | 1109 Expect.listEquals([0x7FFF, 0x7FFE, 0x7FFD, 0x7FFC, 0x7FFB, |
| 1627 0x7FFF, | 1110 0x7FFA, 0x7FF9, 0x7FF8, 0x7FF7, 0x7FF6], |
| 1628 0x7FFE, | 1111 view); |
| 1629 0x7FFD, | 1112 Expect.listEquals([0xFF, 0xFF, 0xFF, 0x7F, 0xFE, 0x7F, 0xFD, 0x7F, |
| 1630 0x7FFC, | 1113 0xFC, 0x7F, 0xFB, 0x7F, 0xFA, 0x7F, 0xF9, 0x7F, |
| 1631 0x7FFB, | 1114 0xF8, 0x7F, 0xF7, 0x7F, 0xF6, 0x7F, 0xFF, 0xFF], |
| 1632 0x7FFA, | 1115 array); |
| 1633 0x7FF9, | |
| 1634 0x7FF8, | |
| 1635 0x7FF7, | |
| 1636 0x7FF6 | |
| 1637 ], view); | |
| 1638 Expect.listEquals([ | |
| 1639 0xFF, | |
| 1640 0xFF, | |
| 1641 0xFF, | |
| 1642 0x7F, | |
| 1643 0xFE, | |
| 1644 0x7F, | |
| 1645 0xFD, | |
| 1646 0x7F, | |
| 1647 0xFC, | |
| 1648 0x7F, | |
| 1649 0xFB, | |
| 1650 0x7F, | |
| 1651 0xFA, | |
| 1652 0x7F, | |
| 1653 0xF9, | |
| 1654 0x7F, | |
| 1655 0xF8, | |
| 1656 0x7F, | |
| 1657 0xF7, | |
| 1658 0x7F, | |
| 1659 0xF6, | |
| 1660 0x7F, | |
| 1661 0xFF, | |
| 1662 0xFF | |
| 1663 ], array); | |
| 1664 for (int i = 0; i < view.length; ++i) { | 1116 for (int i = 0; i < view.length; ++i) { |
| 1665 view[i] = -0x8000 + i; | 1117 view[i] = -0x8000 + i; |
| 1666 } | 1118 } |
| 1667 Expect.listEquals([ | 1119 Expect.listEquals([-0x8000, -0x7FFF, -0x7FFE, -0x7FFD, -0x7FFC, |
| 1668 -0x8000, | 1120 -0x7FFB, -0x7FFA, -0x7FF9, -0x7FF8, -0x7FF7], |
| 1669 -0x7FFF, | 1121 view); |
| 1670 -0x7FFE, | 1122 Expect.listEquals([0xFF, 0xFF, 0x00, 0x80, 0x01, 0x80, 0x02, 0x80, |
| 1671 -0x7FFD, | 1123 0x03, 0x80, 0x04, 0x80, 0x05, 0x80, 0x06, 0x80, |
| 1672 -0x7FFC, | 1124 0x07, 0x80, 0x08, 0x80, 0x09, 0x80, 0xFF, 0xFF], |
| 1673 -0x7FFB, | 1125 array); |
| 1674 -0x7FFA, | |
| 1675 -0x7FF9, | |
| 1676 -0x7FF8, | |
| 1677 -0x7FF7 | |
| 1678 ], view); | |
| 1679 Expect.listEquals([ | |
| 1680 0xFF, | |
| 1681 0xFF, | |
| 1682 0x00, | |
| 1683 0x80, | |
| 1684 0x01, | |
| 1685 0x80, | |
| 1686 0x02, | |
| 1687 0x80, | |
| 1688 0x03, | |
| 1689 0x80, | |
| 1690 0x04, | |
| 1691 0x80, | |
| 1692 0x05, | |
| 1693 0x80, | |
| 1694 0x06, | |
| 1695 0x80, | |
| 1696 0x07, | |
| 1697 0x80, | |
| 1698 0x08, | |
| 1699 0x80, | |
| 1700 0x09, | |
| 1701 0x80, | |
| 1702 0xFF, | |
| 1703 0xFF | |
| 1704 ], array); | |
| 1705 for (int i = 0; i < view.length; ++i) { | 1126 for (int i = 0; i < view.length; ++i) { |
| 1706 view[i] = i; | 1127 view[i] = i; |
| 1707 } | 1128 } |
| 1708 var copy = view.sublist(0, view.length); | 1129 var copy = view.sublist(0, view.length); |
| 1709 Expect.isFalse(identical(copy, view)); | 1130 Expect.isFalse(identical(copy, view)); |
| 1710 Expect.isTrue(copy is Int16List); | 1131 Expect.isTrue(copy is Int16List); |
| 1711 Expect.equals(10, copy.length); | 1132 Expect.equals(10, copy.length); |
| 1712 Expect.listEquals(view, copy); | 1133 Expect.listEquals(view, copy); |
| 1713 var region = view.sublist(3, view.length - 3); | 1134 var region = view.sublist(3, view.length - 3); |
| 1714 Expect.isTrue(copy is Int16List); | 1135 Expect.isTrue(copy is Int16List); |
| 1715 Expect.equals(4, region.length); | 1136 Expect.equals(4, region.length); |
| 1716 Expect.listEquals([3, 4, 5, 6], region); | 1137 Expect.listEquals([3, 4, 5, 6], region); |
| 1717 view.setRange(3, 7, [-32768, 0, 1, 32767]); | 1138 view.setRange(3, 7, [-32768, 0, 1, 32767]); |
| 1718 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], view); | 1139 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], |
| 1719 Expect.listEquals([ | 1140 view); |
| 1720 0xFF, | 1141 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, |
| 1721 0xFF, | 1142 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F, |
| 1722 0x00, | 1143 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], |
| 1723 0x00, | 1144 array); |
| 1724 0x01, | |
| 1725 0x00, | |
| 1726 0x02, | |
| 1727 0x00, | |
| 1728 0x00, | |
| 1729 0x80, | |
| 1730 0x00, | |
| 1731 0x00, | |
| 1732 0x01, | |
| 1733 0x00, | |
| 1734 0xFF, | |
| 1735 0x7F, | |
| 1736 0x07, | |
| 1737 0x00, | |
| 1738 0x08, | |
| 1739 0x00, | |
| 1740 0x09, | |
| 1741 0x00, | |
| 1742 0xFF, | |
| 1743 0xFF | |
| 1744 ], array); | |
| 1745 } | 1145 } |
| 1746 | 1146 |
| 1747 static testInt16ListView() { | 1147 static testInt16ListView() { |
| 1748 var array = new Uint8List(24); | 1148 var array = new Uint8List(24); |
| 1749 testInt16ListViewImpl(array); | 1149 testInt16ListViewImpl(array); |
| 1750 } | 1150 } |
| 1751 | 1151 |
| 1752 static testUint16ListViewImpl(var array) { | 1152 static testUint16ListViewImpl(var array) { |
| 1753 Expect.isTrue(array is List<int>); | 1153 Expect.isTrue(array is List<int>); |
| 1754 Expect.equals(24, array.length); | 1154 Expect.equals(24, array.length); |
| 1755 Expect.equals(1, array.elementSizeInBytes); | 1155 Expect.equals(1, array.elementSizeInBytes); |
| 1756 Expect.equals(24, array.lengthInBytes); | 1156 Expect.equals(24, array.lengthInBytes); |
| 1757 for (int i = 0; i < array.length; ++i) { | 1157 for (int i = 0; i < array.length; ++i) { |
| 1758 array[i] = -1; | 1158 array[i] = -1; |
| 1759 } | 1159 } |
| 1760 Expect.throws(() { | 1160 Expect.throws(() { new Uint16List.view(array.buffer, -1); }, |
| 1761 new Uint16List.view(array.buffer, -1); | 1161 (e) { return e is RangeError; }); |
| 1762 }, (e) { | 1162 Expect.throws(() { new Uint16List.view(array.buffer, 0, -1); }, |
| 1763 return e is RangeError; | 1163 (e) { return e is RangeError; }); |
| 1764 }); | 1164 Expect.throws(() { new Uint16List.view(array.buffer, |
| 1765 Expect.throws(() { | 1165 array.lengthInBytes + 1); }, |
| 1766 new Uint16List.view(array.buffer, 0, -1); | 1166 (e) { return e is RangeError; }); |
| 1767 }, (e) { | 1167 Expect.throws(() { new Uint16List.view(array.buffer, |
| 1768 return e is RangeError; | 1168 0, array.length + 1); }, |
| 1769 }); | 1169 (e) { return e is RangeError; }); |
| 1770 Expect.throws(() { | 1170 Expect.throws(() { new Uint16List.view(array.buffer, |
| 1771 new Uint16List.view(array.buffer, array.lengthInBytes + 1); | 1171 array.length - 1, 2); }, |
| 1772 }, (e) { | 1172 (e) { return e is RangeError; }); |
| 1773 return e is RangeError; | 1173 var empty = new Uint16List.view(array.buffer, |
| 1774 }); | 1174 array.lengthInBytes); |
| 1775 Expect.throws(() { | |
| 1776 new Uint16List.view(array.buffer, 0, array.length + 1); | |
| 1777 }, (e) { | |
| 1778 return e is RangeError; | |
| 1779 }); | |
| 1780 Expect.throws(() { | |
| 1781 new Uint16List.view(array.buffer, array.length - 1, 2); | |
| 1782 }, (e) { | |
| 1783 return e is RangeError; | |
| 1784 }); | |
| 1785 var empty = new Uint16List.view(array.buffer, array.lengthInBytes); | |
| 1786 Expect.isTrue(empty is List<int>); | 1175 Expect.isTrue(empty is List<int>); |
| 1787 Expect.isTrue(empty is Uint16List); | 1176 Expect.isTrue(empty is Uint16List); |
| 1788 Expect.equals(0, empty.length); | 1177 Expect.equals(0, empty.length); |
| 1789 var whole = new Uint16List.view(array.buffer); | 1178 var whole = new Uint16List.view(array.buffer); |
| 1790 Expect.isTrue(whole is List<int>); | 1179 Expect.isTrue(whole is List<int>); |
| 1791 Expect.isTrue(whole is Uint16List); | 1180 Expect.isTrue(whole is Uint16List); |
| 1792 Expect.equals(12, whole.length); | 1181 Expect.equals(12, whole.length); |
| 1793 var view = new Uint16List.view(array.buffer, 2, 10); | 1182 var view = new Uint16List.view(array.buffer, 2, 10); |
| 1794 Expect.isTrue(view is List<int>); | 1183 Expect.isTrue(view is List<int>); |
| 1795 Expect.isTrue(view is Uint16List); | 1184 Expect.isTrue(view is Uint16List); |
| 1796 Expect.equals(10, view.length); | 1185 Expect.equals(10, view.length); |
| 1797 Expect.equals(2, view.elementSizeInBytes); | 1186 Expect.equals(2, view.elementSizeInBytes); |
| 1798 Expect.equals(20, view.lengthInBytes); | 1187 Expect.equals(20, view.lengthInBytes); |
| 1799 Expect.listEquals([ | 1188 Expect.listEquals([0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 1800 0xFFFF, | 1189 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF], |
| 1801 0xFFFF, | 1190 view); |
| 1802 0xFFFF, | 1191 Expect.throws(() { view[-1] = 0; }, |
| 1803 0xFFFF, | 1192 (e) { return e is RangeError; }); |
| 1804 0xFFFF, | 1193 Expect.throws(() { return view[-1]; }, |
| 1805 0xFFFF, | 1194 (e) { return e is RangeError; }); |
| 1806 0xFFFF, | 1195 Expect.throws(() { view[view.length]; }, |
| 1807 0xFFFF, | 1196 (e) { return e is RangeError; }); |
| 1808 0xFFFF, | 1197 Expect.throws(() { view[view.length] = 0; }, |
| 1809 0xFFFF | 1198 (e) { return e is RangeError; }); |
| 1810 ], view); | 1199 Expect.throws(() { view.add(0); }, |
| 1811 Expect.throws(() { | 1200 (e) { return e is UnsupportedError; }); |
| 1812 view[-1] = 0; | 1201 Expect.throws(() { view.addAll([0]); }, |
| 1813 }, (e) { | 1202 (e) { return e is UnsupportedError; }); |
| 1814 return e is RangeError; | 1203 Expect.throws(() { view.clear(); }, |
| 1815 }); | 1204 (e) { return e is UnsupportedError; }); |
| 1816 Expect.throws(() { | 1205 Expect.throws(() { view.length = 0; }, |
| 1817 return view[-1]; | 1206 (e) { return e is UnsupportedError; }); |
| 1818 }, (e) { | 1207 Expect.throws(() { view.removeLast(); }, |
| 1819 return e is RangeError; | 1208 (e) { return e is UnsupportedError; }); |
| 1820 }); | 1209 Expect.throws(() { view.removeRange(0, view.length - 1); }, |
| 1821 Expect.throws(() { | 1210 (e) { return e is UnsupportedError; }); |
| 1822 view[view.length]; | |
| 1823 }, (e) { | |
| 1824 return e is RangeError; | |
| 1825 }); | |
| 1826 Expect.throws(() { | |
| 1827 view[view.length] = 0; | |
| 1828 }, (e) { | |
| 1829 return e is RangeError; | |
| 1830 }); | |
| 1831 Expect.throws(() { | |
| 1832 view.add(0); | |
| 1833 }, (e) { | |
| 1834 return e is UnsupportedError; | |
| 1835 }); | |
| 1836 Expect.throws(() { | |
| 1837 view.addAll([0]); | |
| 1838 }, (e) { | |
| 1839 return e is UnsupportedError; | |
| 1840 }); | |
| 1841 Expect.throws(() { | |
| 1842 view.clear(); | |
| 1843 }, (e) { | |
| 1844 return e is UnsupportedError; | |
| 1845 }); | |
| 1846 Expect.throws(() { | |
| 1847 view.length = 0; | |
| 1848 }, (e) { | |
| 1849 return e is UnsupportedError; | |
| 1850 }); | |
| 1851 Expect.throws(() { | |
| 1852 view.removeLast(); | |
| 1853 }, (e) { | |
| 1854 return e is UnsupportedError; | |
| 1855 }); | |
| 1856 Expect.throws(() { | |
| 1857 view.removeRange(0, view.length - 1); | |
| 1858 }, (e) { | |
| 1859 return e is UnsupportedError; | |
| 1860 }); | |
| 1861 for (int i = 0; i < view.length; ++i) { | 1211 for (int i = 0; i < view.length; ++i) { |
| 1862 view[i] = 1 + i; | 1212 view[i] = 1 + i; |
| 1863 } | 1213 } |
| 1864 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); | 1214 Expect.listEquals([1, 2, 3, 4, 5, |
| 1865 Expect.listEquals([ | 1215 6, 7, 8, 9, 10], |
| 1866 -1, | 1216 view); |
| 1867 -1, | 1217 Expect.listEquals([-1, -1, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, |
| 1868 1, | 1218 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, -1, -1], |
| 1869 0, | 1219 array); |
| 1870 2, | |
| 1871 0, | |
| 1872 3, | |
| 1873 0, | |
| 1874 4, | |
| 1875 0, | |
| 1876 5, | |
| 1877 0, | |
| 1878 6, | |
| 1879 0, | |
| 1880 7, | |
| 1881 0, | |
| 1882 8, | |
| 1883 0, | |
| 1884 9, | |
| 1885 0, | |
| 1886 10, | |
| 1887 0, | |
| 1888 -1, | |
| 1889 -1 | |
| 1890 ], array); | |
| 1891 for (int i = 0; i < view.length; ++i) { | 1220 for (int i = 0; i < view.length; ++i) { |
| 1892 view[i] = 0x10000 + i; | 1221 view[i] = 0x10000 + i; |
| 1893 } | 1222 } |
| 1894 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); | 1223 Expect.listEquals([0, 1, 2, 3, 4, |
| 1895 Expect.listEquals([ | 1224 5, 6, 7, 8, 9], |
| 1896 -1, | 1225 view); |
| 1897 -1, | 1226 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, |
| 1898 0, | 1227 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, -1, -1], |
| 1899 0, | 1228 array); |
| 1900 1, | |
| 1901 0, | |
| 1902 2, | |
| 1903 0, | |
| 1904 3, | |
| 1905 0, | |
| 1906 4, | |
| 1907 0, | |
| 1908 5, | |
| 1909 0, | |
| 1910 6, | |
| 1911 0, | |
| 1912 7, | |
| 1913 0, | |
| 1914 8, | |
| 1915 0, | |
| 1916 9, | |
| 1917 0, | |
| 1918 -1, | |
| 1919 -1 | |
| 1920 ], array); | |
| 1921 for (int i = 0; i < view.length; ++i) { | 1229 for (int i = 0; i < view.length; ++i) { |
| 1922 view[i] = 0xFFFF - i; | 1230 view[i] = 0xFFFF - i; |
| 1923 } | 1231 } |
| 1924 Expect.listEquals([ | 1232 Expect.listEquals([0xFFFF, 0xFFFE, 0xFFFD, 0xFFFC, 0xFFFB, |
| 1925 0xFFFF, | 1233 0xFFFA, 0xFFF9, 0xFFF8, 0xFFF7, 0xFFF6], |
| 1926 0xFFFE, | 1234 view); |
| 1927 0xFFFD, | 1235 Expect.listEquals([-1, -1, -1, -1, -2, -1, -3, -1, |
| 1928 0xFFFC, | 1236 -4, -1, -5, -1, -6, -1, -7, -1, |
| 1929 0xFFFB, | 1237 -8, -1, -9, -1, -10, -1, -1, -1], |
| 1930 0xFFFA, | 1238 array); |
| 1931 0xFFF9, | |
| 1932 0xFFF8, | |
| 1933 0xFFF7, | |
| 1934 0xFFF6 | |
| 1935 ], view); | |
| 1936 Expect.listEquals([ | |
| 1937 -1, | |
| 1938 -1, | |
| 1939 -1, | |
| 1940 -1, | |
| 1941 -2, | |
| 1942 -1, | |
| 1943 -3, | |
| 1944 -1, | |
| 1945 -4, | |
| 1946 -1, | |
| 1947 -5, | |
| 1948 -1, | |
| 1949 -6, | |
| 1950 -1, | |
| 1951 -7, | |
| 1952 -1, | |
| 1953 -8, | |
| 1954 -1, | |
| 1955 -9, | |
| 1956 -1, | |
| 1957 -10, | |
| 1958 -1, | |
| 1959 -1, | |
| 1960 -1 | |
| 1961 ], array); | |
| 1962 for (int i = 0; i < view.length; ++i) { | 1239 for (int i = 0; i < view.length; ++i) { |
| 1963 view[i] = i; | 1240 view[i] = i; |
| 1964 } | 1241 } |
| 1965 var copy = view.sublist(0, view.length); | 1242 var copy = view.sublist(0, view.length); |
| 1966 Expect.isFalse(identical(copy, view)); | 1243 Expect.isFalse(identical(copy, view)); |
| 1967 Expect.isTrue(copy is Uint16List); | 1244 Expect.isTrue(copy is Uint16List); |
| 1968 Expect.equals(10, copy.length); | 1245 Expect.equals(10, copy.length); |
| 1969 Expect.listEquals(view, copy); | 1246 Expect.listEquals(view, copy); |
| 1970 var region = view.sublist(3, view.length - 3); | 1247 var region = view.sublist(3, view.length - 3); |
| 1971 Expect.isTrue(copy is Uint16List); | 1248 Expect.isTrue(copy is Uint16List); |
| 1972 Expect.equals(4, region.length); | 1249 Expect.equals(4, region.length); |
| 1973 Expect.listEquals([3, 4, 5, 6], region); | 1250 Expect.listEquals([3, 4, 5, 6], region); |
| 1974 view.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]); | 1251 view.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]); |
| 1975 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], view); | 1252 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], |
| 1976 Expect.listEquals([ | 1253 view); |
| 1977 -1, | 1254 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, |
| 1978 -1, | 1255 1, 0, 0, 0, 1, 0, -1, -1, |
| 1979 0, | 1256 7, 0, 8, 0, 9, 0, -1, -1], |
| 1980 0, | 1257 array); |
| 1981 1, | |
| 1982 0, | |
| 1983 2, | |
| 1984 0, | |
| 1985 1, | |
| 1986 0, | |
| 1987 0, | |
| 1988 0, | |
| 1989 1, | |
| 1990 0, | |
| 1991 -1, | |
| 1992 -1, | |
| 1993 7, | |
| 1994 0, | |
| 1995 8, | |
| 1996 0, | |
| 1997 9, | |
| 1998 0, | |
| 1999 -1, | |
| 2000 -1 | |
| 2001 ], array); | |
| 2002 } | 1258 } |
| 2003 | 1259 |
| 2004 static testUint16ListView() { | 1260 static testUint16ListView() { |
| 2005 var array = new Int8List(24); | 1261 var array = new Int8List(24); |
| 2006 testUint16ListViewImpl(array); | 1262 testUint16ListViewImpl(array); |
| 2007 } | 1263 } |
| 2008 | 1264 |
| 2009 static testInt32ListView() { | 1265 static testInt32ListView() { |
| 2010 var array = new Uint8List(48); | 1266 var array = new Uint8List(48); |
| 2011 Expect.equals(48, array.length); | 1267 Expect.equals(48, array.length); |
| 2012 Expect.equals(1, array.elementSizeInBytes); | 1268 Expect.equals(1, array.elementSizeInBytes); |
| 2013 Expect.equals(48, array.lengthInBytes); | 1269 Expect.equals(48, array.lengthInBytes); |
| 2014 for (int i = 0; i < array.length; ++i) { | 1270 for (int i = 0; i < array.length; ++i) { |
| 2015 array[i] = 0xFF; | 1271 array[i] = 0xFF; |
| 2016 } | 1272 } |
| 2017 Expect.throws(() { | 1273 Expect.throws(() { new Int32List.view(array.buffer, -1); }, |
| 2018 new Int32List.view(array.buffer, -1); | 1274 (e) { return e is RangeError; }); |
| 2019 }, (e) { | 1275 Expect.throws(() { new Int32List.view(array.buffer, 0, -1); }, |
| 2020 return e is RangeError; | 1276 (e) { return e is RangeError; }); |
| 2021 }); | 1277 Expect.throws(() { new Int32List.view(array.buffer, |
| 2022 Expect.throws(() { | 1278 array.lengthInBytes + 1); }, |
| 2023 new Int32List.view(array.buffer, 0, -1); | 1279 (e) { return e is RangeError; }); |
| 2024 }, (e) { | 1280 Expect.throws(() { new Int32List.view(array.buffer, |
| 2025 return e is RangeError; | 1281 0, array.length + 1); }, |
| 2026 }); | 1282 (e) { return e is RangeError; }); |
| 2027 Expect.throws(() { | 1283 Expect.throws(() { new Int32List.view(array.buffer, |
| 2028 new Int32List.view(array.buffer, array.lengthInBytes + 1); | 1284 array.length - 1, 2); }, |
| 2029 }, (e) { | 1285 (e) { return e is RangeError; }); |
| 2030 return e is RangeError; | 1286 var empty = new Int32List.view(array.buffer, |
| 2031 }); | 1287 array.lengthInBytes); |
| 2032 Expect.throws(() { | |
| 2033 new Int32List.view(array.buffer, 0, array.length + 1); | |
| 2034 }, (e) { | |
| 2035 return e is RangeError; | |
| 2036 }); | |
| 2037 Expect.throws(() { | |
| 2038 new Int32List.view(array.buffer, array.length - 1, 2); | |
| 2039 }, (e) { | |
| 2040 return e is RangeError; | |
| 2041 }); | |
| 2042 var empty = new Int32List.view(array.buffer, array.lengthInBytes); | |
| 2043 Expect.isTrue(empty is List<int>); | 1288 Expect.isTrue(empty is List<int>); |
| 2044 Expect.isTrue(empty is Int32List); | 1289 Expect.isTrue(empty is Int32List); |
| 2045 Expect.equals(0, empty.length); | 1290 Expect.equals(0, empty.length); |
| 2046 var whole = new Int32List.view(array.buffer); | 1291 var whole = new Int32List.view(array.buffer); |
| 2047 Expect.isTrue(whole is List<int>); | 1292 Expect.isTrue(whole is List<int>); |
| 2048 Expect.isTrue(whole is Int32List); | 1293 Expect.isTrue(whole is Int32List); |
| 2049 Expect.equals(12, whole.length); | 1294 Expect.equals(12, whole.length); |
| 2050 var view = new Int32List.view(array.buffer, 4, 10); | 1295 var view = new Int32List.view(array.buffer, 4, 10); |
| 2051 Expect.isTrue(view is List<int>); | 1296 Expect.isTrue(view is List<int>); |
| 2052 Expect.isTrue(view is Int32List); | 1297 Expect.isTrue(view is Int32List); |
| 2053 Expect.equals(10, view.length); | 1298 Expect.equals(10, view.length); |
| 2054 Expect.equals(4, view.elementSizeInBytes); | 1299 Expect.equals(4, view.elementSizeInBytes); |
| 2055 Expect.equals(40, view.lengthInBytes); | 1300 Expect.equals(40, view.lengthInBytes); |
| 2056 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], view); | 1301 Expect.listEquals([-1, -1, -1, -1, -1, |
| 2057 Expect.throws(() { | 1302 -1, -1, -1, -1, -1], |
| 2058 view[-1] = 0; | 1303 view); |
| 2059 }, (e) { | 1304 Expect.throws(() { view[-1] = 0; }, |
| 2060 return e is RangeError; | 1305 (e) { return e is RangeError; }); |
| 2061 }); | 1306 Expect.throws(() { return view[-1]; }, |
| 2062 Expect.throws(() { | 1307 (e) { return e is RangeError; }); |
| 2063 return view[-1]; | 1308 Expect.throws(() { view[view.length]; }, |
| 2064 }, (e) { | 1309 (e) { return e is RangeError; }); |
| 2065 return e is RangeError; | 1310 Expect.throws(() { view[10] = 0; }, |
| 2066 }); | 1311 (e) { return e is RangeError; }); |
| 2067 Expect.throws(() { | 1312 Expect.throws(() { view.add(0); }, |
| 2068 view[view.length]; | 1313 (e) { return e is UnsupportedError; }); |
| 2069 }, (e) { | 1314 Expect.throws(() { view.addAll([0]); }, |
| 2070 return e is RangeError; | 1315 (e) { return e is UnsupportedError; }); |
| 2071 }); | 1316 Expect.throws(() { view.clear(); }, |
| 2072 Expect.throws(() { | 1317 (e) { return e is UnsupportedError; }); |
| 2073 view[10] = 0; | 1318 Expect.throws(() { view.length = 0; }, |
| 2074 }, (e) { | 1319 (e) { return e is UnsupportedError; }); |
| 2075 return e is RangeError; | 1320 Expect.throws(() { view.removeLast(); }, |
| 2076 }); | 1321 (e) { return e is UnsupportedError; }); |
| 2077 Expect.throws(() { | 1322 Expect.throws(() { view.removeRange(0, view.length - 1); }, |
| 2078 view.add(0); | 1323 (e) { return e is UnsupportedError; }); |
| 2079 }, (e) { | |
| 2080 return e is UnsupportedError; | |
| 2081 }); | |
| 2082 Expect.throws(() { | |
| 2083 view.addAll([0]); | |
| 2084 }, (e) { | |
| 2085 return e is UnsupportedError; | |
| 2086 }); | |
| 2087 Expect.throws(() { | |
| 2088 view.clear(); | |
| 2089 }, (e) { | |
| 2090 return e is UnsupportedError; | |
| 2091 }); | |
| 2092 Expect.throws(() { | |
| 2093 view.length = 0; | |
| 2094 }, (e) { | |
| 2095 return e is UnsupportedError; | |
| 2096 }); | |
| 2097 Expect.throws(() { | |
| 2098 view.removeLast(); | |
| 2099 }, (e) { | |
| 2100 return e is UnsupportedError; | |
| 2101 }); | |
| 2102 Expect.throws(() { | |
| 2103 view.removeRange(0, view.length - 1); | |
| 2104 }, (e) { | |
| 2105 return e is UnsupportedError; | |
| 2106 }); | |
| 2107 for (int i = 0; i < view.length; ++i) { | 1324 for (int i = 0; i < view.length; ++i) { |
| 2108 view[i] = 1 + i; | 1325 view[i] = 1 + i; |
| 2109 } | 1326 } |
| 2110 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); | 1327 Expect.listEquals([1, 2, 3, 4, 5, |
| 2111 Expect.listEquals([ | 1328 6, 7, 8, 9, 10], |
| 2112 0xFF, | 1329 view); |
| 2113 0xFF, | 1330 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, |
| 2114 0xFF, | 1331 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, |
| 2115 0xFF, | 1332 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, |
| 2116 0x01, | 1333 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, |
| 2117 0x00, | 1334 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, |
| 2118 0x00, | 1335 0x0A, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], |
| 2119 0x00, | 1336 array); |
| 2120 0x02, | |
| 2121 0x00, | |
| 2122 0x00, | |
| 2123 0x00, | |
| 2124 0x03, | |
| 2125 0x00, | |
| 2126 0x00, | |
| 2127 0x00, | |
| 2128 0x04, | |
| 2129 0x00, | |
| 2130 0x00, | |
| 2131 0x00, | |
| 2132 0x05, | |
| 2133 0x00, | |
| 2134 0x00, | |
| 2135 0x00, | |
| 2136 0x06, | |
| 2137 0x00, | |
| 2138 0x00, | |
| 2139 0x00, | |
| 2140 0x07, | |
| 2141 0x00, | |
| 2142 0x00, | |
| 2143 0x00, | |
| 2144 0x08, | |
| 2145 0x00, | |
| 2146 0x00, | |
| 2147 0x00, | |
| 2148 0x09, | |
| 2149 0x00, | |
| 2150 0x00, | |
| 2151 0x00, | |
| 2152 0x0A, | |
| 2153 0x00, | |
| 2154 0x00, | |
| 2155 0x00, | |
| 2156 0xFF, | |
| 2157 0xFF, | |
| 2158 0xFF, | |
| 2159 0xFF | |
| 2160 ], array); | |
| 2161 for (int i = 0; i < view.length; ++i) { | 1337 for (int i = 0; i < view.length; ++i) { |
| 2162 view[i] = 0x100000000 + i; | 1338 view[i] = 0x100000000 + i; |
| 2163 } | 1339 } |
| 2164 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); | 1340 Expect.listEquals([0, 1, 2, 3, 4, |
| 2165 Expect.listEquals([ | 1341 5, 6, 7, 8, 9], |
| 2166 0xFF, | 1342 view); |
| 2167 0xFF, | 1343 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, |
| 2168 0xFF, | 1344 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 2169 0xFF, | 1345 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, |
| 2170 0x00, | 1346 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, |
| 2171 0x00, | 1347 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, |
| 2172 0x00, | 1348 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], |
| 2173 0x00, | 1349 array); |
| 2174 0x01, | |
| 2175 0x00, | |
| 2176 0x00, | |
| 2177 0x00, | |
| 2178 0x02, | |
| 2179 0x00, | |
| 2180 0x00, | |
| 2181 0x00, | |
| 2182 0x03, | |
| 2183 0x00, | |
| 2184 0x00, | |
| 2185 0x00, | |
| 2186 0x04, | |
| 2187 0x00, | |
| 2188 0x00, | |
| 2189 0x00, | |
| 2190 0x05, | |
| 2191 0x00, | |
| 2192 0x00, | |
| 2193 0x00, | |
| 2194 0x06, | |
| 2195 0x00, | |
| 2196 0x00, | |
| 2197 0x00, | |
| 2198 0x07, | |
| 2199 0x00, | |
| 2200 0x00, | |
| 2201 0x00, | |
| 2202 0x08, | |
| 2203 0x00, | |
| 2204 0x00, | |
| 2205 0x00, | |
| 2206 0x09, | |
| 2207 0x00, | |
| 2208 0x00, | |
| 2209 0x00, | |
| 2210 0xFF, | |
| 2211 0xFF, | |
| 2212 0xFF, | |
| 2213 0xFF | |
| 2214 ], array); | |
| 2215 for (int i = 0; i < view.length; ++i) { | 1350 for (int i = 0; i < view.length; ++i) { |
| 2216 view[i] = -10 + i; | 1351 view[i] = -10 + i; |
| 2217 } | 1352 } |
| 2218 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], view); | 1353 Expect.listEquals([-10, -9, -8, -7, -6, |
| 2219 Expect.listEquals([ | 1354 -5, -4, -3, -2, -1], |
| 2220 0xFF, | 1355 view); |
| 2221 0xFF, | 1356 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0xFF, 0xFF, 0xFF, |
| 2222 0xFF, | 1357 0xF7, 0xFF, 0xFF, 0xFF, 0xF8, 0xFF, 0xFF, 0xFF, |
| 2223 0xFF, | 1358 0xF9, 0xFF, 0xFF, 0xFF, 0xFA, 0xFF, 0xFF, 0xFF, |
| 2224 0xF6, | 1359 0xFB, 0xFF, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0xFF, |
| 2225 0xFF, | 1360 0xFD, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, |
| 2226 0xFF, | 1361 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
| 2227 0xFF, | 1362 array); |
| 2228 0xF7, | |
| 2229 0xFF, | |
| 2230 0xFF, | |
| 2231 0xFF, | |
| 2232 0xF8, | |
| 2233 0xFF, | |
| 2234 0xFF, | |
| 2235 0xFF, | |
| 2236 0xF9, | |
| 2237 0xFF, | |
| 2238 0xFF, | |
| 2239 0xFF, | |
| 2240 0xFA, | |
| 2241 0xFF, | |
| 2242 0xFF, | |
| 2243 0xFF, | |
| 2244 0xFB, | |
| 2245 0xFF, | |
| 2246 0xFF, | |
| 2247 0xFF, | |
| 2248 0xFC, | |
| 2249 0xFF, | |
| 2250 0xFF, | |
| 2251 0xFF, | |
| 2252 0xFD, | |
| 2253 0xFF, | |
| 2254 0xFF, | |
| 2255 0xFF, | |
| 2256 0xFE, | |
| 2257 0xFF, | |
| 2258 0xFF, | |
| 2259 0xFF, | |
| 2260 0xFF, | |
| 2261 0xFF, | |
| 2262 0xFF, | |
| 2263 0xFF, | |
| 2264 0xFF, | |
| 2265 0xFF, | |
| 2266 0xFF, | |
| 2267 0xFF | |
| 2268 ], array); | |
| 2269 for (int i = 0; i < view.length; ++i) { | 1363 for (int i = 0; i < view.length; ++i) { |
| 2270 view[i] = 0x7FFFFFFF - i; | 1364 view[i] = 0x7FFFFFFF - i; |
| 2271 } | 1365 } |
| 2272 Expect.listEquals([ | 1366 Expect.listEquals([0x7FFFFFFF, 0x7FFFFFFE, |
| 2273 0x7FFFFFFF, | 1367 0x7FFFFFFD, 0x7FFFFFFC, |
| 2274 0x7FFFFFFE, | 1368 0x7FFFFFFB, 0x7FFFFFFA, |
| 2275 0x7FFFFFFD, | 1369 0x7FFFFFF9, 0x7FFFFFF8, |
| 2276 0x7FFFFFFC, | 1370 0x7FFFFFF7, 0x7FFFFFF6], |
| 2277 0x7FFFFFFB, | 1371 view); |
| 2278 0x7FFFFFFA, | 1372 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, |
| 2279 0x7FFFFFF9, | 1373 0xFE, 0xFF, 0xFF, 0x7F, 0xFD, 0xFF, 0xFF, 0x7F, |
| 2280 0x7FFFFFF8, | 1374 0xFC, 0xFF, 0xFF, 0x7F, 0xFB, 0xFF, 0xFF, 0x7F, |
| 2281 0x7FFFFFF7, | 1375 0xFA, 0xFF, 0xFF, 0x7F, 0xF9, 0xFF, 0xFF, 0x7F, |
| 2282 0x7FFFFFF6 | 1376 0xF8, 0xFF, 0xFF, 0x7F, 0xF7, 0xFF, 0xFF, 0x7F, |
| 2283 ], view); | 1377 0xF6, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF], |
| 2284 Expect.listEquals([ | 1378 array); |
| 2285 0xFF, | |
| 2286 0xFF, | |
| 2287 0xFF, | |
| 2288 0xFF, | |
| 2289 0xFF, | |
| 2290 0xFF, | |
| 2291 0xFF, | |
| 2292 0x7F, | |
| 2293 0xFE, | |
| 2294 0xFF, | |
| 2295 0xFF, | |
| 2296 0x7F, | |
| 2297 0xFD, | |
| 2298 0xFF, | |
| 2299 0xFF, | |
| 2300 0x7F, | |
| 2301 0xFC, | |
| 2302 0xFF, | |
| 2303 0xFF, | |
| 2304 0x7F, | |
| 2305 0xFB, | |
| 2306 0xFF, | |
| 2307 0xFF, | |
| 2308 0x7F, | |
| 2309 0xFA, | |
| 2310 0xFF, | |
| 2311 0xFF, | |
| 2312 0x7F, | |
| 2313 0xF9, | |
| 2314 0xFF, | |
| 2315 0xFF, | |
| 2316 0x7F, | |
| 2317 0xF8, | |
| 2318 0xFF, | |
| 2319 0xFF, | |
| 2320 0x7F, | |
| 2321 0xF7, | |
| 2322 0xFF, | |
| 2323 0xFF, | |
| 2324 0x7F, | |
| 2325 0xF6, | |
| 2326 0xFF, | |
| 2327 0xFF, | |
| 2328 0x7F, | |
| 2329 0xFF, | |
| 2330 0xFF, | |
| 2331 0xFF, | |
| 2332 0xFF | |
| 2333 ], array); | |
| 2334 for (int i = 0; i < view.length; ++i) { | 1379 for (int i = 0; i < view.length; ++i) { |
| 2335 view[i] = -0x80000000 + i; | 1380 view[i] = -0x80000000 + i; |
| 2336 } | 1381 } |
| 2337 Expect.listEquals([ | 1382 Expect.listEquals([-0x80000000, -0x7FFFFFFF, |
| 2338 -0x80000000, | 1383 -0x7FFFFFFE, -0x7FFFFFFD, |
| 2339 -0x7FFFFFFF, | 1384 -0x7FFFFFFC, -0x7FFFFFFB, |
| 2340 -0x7FFFFFFE, | 1385 -0x7FFFFFFA, -0x7FFFFFF9, |
| 2341 -0x7FFFFFFD, | 1386 -0x7FFFFFF8, -0x7FFFFFF7], |
| 2342 -0x7FFFFFFC, | 1387 view); |
| 2343 -0x7FFFFFFB, | 1388 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x80, |
| 2344 -0x7FFFFFFA, | 1389 0x01, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x80, |
| 2345 -0x7FFFFFF9, | 1390 0x03, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x80, |
| 2346 -0x7FFFFFF8, | 1391 0x05, 0x00, 0x00, 0x80, 0x06, 0x00, 0x00, 0x80, |
| 2347 -0x7FFFFFF7 | 1392 0x07, 0x00, 0x00, 0x80, 0x08, 0x00, 0x00, 0x80, |
| 2348 ], view); | 1393 0x09, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF], |
| 2349 Expect.listEquals([ | 1394 array); |
| 2350 0xFF, | |
| 2351 0xFF, | |
| 2352 0xFF, | |
| 2353 0xFF, | |
| 2354 0x00, | |
| 2355 0x00, | |
| 2356 0x00, | |
| 2357 0x80, | |
| 2358 0x01, | |
| 2359 0x00, | |
| 2360 0x00, | |
| 2361 0x80, | |
| 2362 0x02, | |
| 2363 0x00, | |
| 2364 0x00, | |
| 2365 0x80, | |
| 2366 0x03, | |
| 2367 0x00, | |
| 2368 0x00, | |
| 2369 0x80, | |
| 2370 0x04, | |
| 2371 0x00, | |
| 2372 0x00, | |
| 2373 0x80, | |
| 2374 0x05, | |
| 2375 0x00, | |
| 2376 0x00, | |
| 2377 0x80, | |
| 2378 0x06, | |
| 2379 0x00, | |
| 2380 0x00, | |
| 2381 0x80, | |
| 2382 0x07, | |
| 2383 0x00, | |
| 2384 0x00, | |
| 2385 0x80, | |
| 2386 0x08, | |
| 2387 0x00, | |
| 2388 0x00, | |
| 2389 0x80, | |
| 2390 0x09, | |
| 2391 0x00, | |
| 2392 0x00, | |
| 2393 0x80, | |
| 2394 0xFF, | |
| 2395 0xFF, | |
| 2396 0xFF, | |
| 2397 0xFF | |
| 2398 ], array); | |
| 2399 for (int i = 0; i < view.length; ++i) { | 1395 for (int i = 0; i < view.length; ++i) { |
| 2400 view[i] = i; | 1396 view[i] = i; |
| 2401 } | 1397 } |
| 2402 var copy = view.sublist(0, view.length); | 1398 var copy = view.sublist(0, view.length); |
| 2403 Expect.isFalse(identical(copy, view)); | 1399 Expect.isFalse(identical(copy, view)); |
| 2404 Expect.isTrue(copy is Int32List); | 1400 Expect.isTrue(copy is Int32List); |
| 2405 Expect.equals(10, copy.length); | 1401 Expect.equals(10, copy.length); |
| 2406 Expect.listEquals(view, copy); | 1402 Expect.listEquals(view, copy); |
| 2407 var region = view.sublist(3, view.length - 3); | 1403 var region = view.sublist(3, view.length - 3); |
| 2408 Expect.isTrue(copy is Int32List); | 1404 Expect.isTrue(copy is Int32List); |
| 2409 Expect.equals(4, region.length); | 1405 Expect.equals(4, region.length); |
| 2410 Expect.listEquals([3, 4, 5, 6], region); | 1406 Expect.listEquals([3, 4, 5, 6], region); |
| 2411 view.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]); | 1407 view.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]); |
| 2412 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], view); | 1408 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], |
| 2413 Expect.listEquals([ | 1409 view); |
| 2414 0xFF, | 1410 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, |
| 2415 0xFF, | 1411 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 2416 0xFF, | 1412 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, |
| 2417 0xFF, | 1413 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, |
| 2418 0x00, | 1414 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, |
| 2419 0x00, | 1415 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], |
| 2420 0x00, | 1416 array); |
| 2421 0x00, | |
| 2422 0x01, | |
| 2423 0x00, | |
| 2424 0x00, | |
| 2425 0x00, | |
| 2426 0x02, | |
| 2427 0x00, | |
| 2428 0x00, | |
| 2429 0x00, | |
| 2430 0x00, | |
| 2431 0x00, | |
| 2432 0x00, | |
| 2433 0x80, | |
| 2434 0x00, | |
| 2435 0x00, | |
| 2436 0x00, | |
| 2437 0x00, | |
| 2438 0x01, | |
| 2439 0x00, | |
| 2440 0x00, | |
| 2441 0x00, | |
| 2442 0xFF, | |
| 2443 0xFF, | |
| 2444 0xFF, | |
| 2445 0x7F, | |
| 2446 0x07, | |
| 2447 0x00, | |
| 2448 0x00, | |
| 2449 0x00, | |
| 2450 0x08, | |
| 2451 0x00, | |
| 2452 0x00, | |
| 2453 0x00, | |
| 2454 0x09, | |
| 2455 0x00, | |
| 2456 0x00, | |
| 2457 0x00, | |
| 2458 0xFF, | |
| 2459 0xFF, | |
| 2460 0xFF, | |
| 2461 0xFF | |
| 2462 ], array); | |
| 2463 } | 1417 } |
| 2464 | 1418 |
| 2465 static testUint32ListViewImpl(var array) { | 1419 static testUint32ListViewImpl(var array) { |
| 2466 Expect.isTrue(array is List<int>); | 1420 Expect.isTrue(array is List<int>); |
| 2467 Expect.equals(48, array.length); | 1421 Expect.equals(48, array.length); |
| 2468 Expect.equals(1, array.elementSizeInBytes); | 1422 Expect.equals(1, array.elementSizeInBytes); |
| 2469 Expect.equals(48, array.lengthInBytes); | 1423 Expect.equals(48, array.lengthInBytes); |
| 2470 for (int i = 0; i < array.length; ++i) { | 1424 for (int i = 0; i < array.length; ++i) { |
| 2471 array[i] = -1; | 1425 array[i] = -1; |
| 2472 } | 1426 } |
| 2473 Expect.throws(() { | 1427 Expect.throws(() { new Uint32List.view(array.buffer, -1); }, |
| 2474 new Uint32List.view(array.buffer, -1); | 1428 (e) { return e is RangeError; }); |
| 2475 }, (e) { | 1429 Expect.throws(() { new Uint32List.view(array.buffer, 0, -1); }, |
| 2476 return e is RangeError; | 1430 (e) { return e is RangeError; }); |
| 2477 }); | 1431 Expect.throws(() { new Uint32List.view(array.buffer, |
| 2478 Expect.throws(() { | 1432 array.lengthInBytes + 1); }, |
| 2479 new Uint32List.view(array.buffer, 0, -1); | 1433 (e) { return e is RangeError; }); |
| 2480 }, (e) { | 1434 Expect.throws(() { new Uint32List.view(array.buffer, |
| 2481 return e is RangeError; | 1435 0, array.length + 1); }, |
| 2482 }); | 1436 (e) { return e is RangeError; }); |
| 2483 Expect.throws(() { | 1437 Expect.throws(() { new Uint32List.view(array.buffer, |
| 2484 new Uint32List.view(array.buffer, array.lengthInBytes + 1); | 1438 array.length - 1, 2); }, |
| 2485 }, (e) { | 1439 (e) { return e is RangeError; }); |
| 2486 return e is RangeError; | 1440 var empty = new Uint32List.view(array.buffer, |
| 2487 }); | 1441 array.lengthInBytes); |
| 2488 Expect.throws(() { | |
| 2489 new Uint32List.view(array.buffer, 0, array.length + 1); | |
| 2490 }, (e) { | |
| 2491 return e is RangeError; | |
| 2492 }); | |
| 2493 Expect.throws(() { | |
| 2494 new Uint32List.view(array.buffer, array.length - 1, 2); | |
| 2495 }, (e) { | |
| 2496 return e is RangeError; | |
| 2497 }); | |
| 2498 var empty = new Uint32List.view(array.buffer, array.lengthInBytes); | |
| 2499 Expect.isTrue(empty is List<int>); | 1442 Expect.isTrue(empty is List<int>); |
| 2500 Expect.isTrue(empty is Uint32List); | 1443 Expect.isTrue(empty is Uint32List); |
| 2501 Expect.equals(0, empty.length); | 1444 Expect.equals(0, empty.length); |
| 2502 var whole = new Uint32List.view(array.buffer); | 1445 var whole = new Uint32List.view(array.buffer); |
| 2503 Expect.isTrue(whole is List<int>); | 1446 Expect.isTrue(whole is List<int>); |
| 2504 Expect.isTrue(whole is Uint32List); | 1447 Expect.isTrue(whole is Uint32List); |
| 2505 Expect.equals(12, whole.length); | 1448 Expect.equals(12, whole.length); |
| 2506 var view = new Uint32List.view(array.buffer, 4, 10); | 1449 var view = new Uint32List.view(array.buffer, 4, 10); |
| 2507 Expect.isTrue(view is List<int>); | 1450 Expect.isTrue(view is List<int>); |
| 2508 Expect.isTrue(view is Uint32List); | 1451 Expect.isTrue(view is Uint32List); |
| 2509 Expect.equals(10, view.length); | 1452 Expect.equals(10, view.length); |
| 2510 Expect.equals(4, view.elementSizeInBytes); | 1453 Expect.equals(4, view.elementSizeInBytes); |
| 2511 Expect.equals(40, view.lengthInBytes); | 1454 Expect.equals(40, view.lengthInBytes); |
| 2512 Expect.listEquals([ | 1455 Expect.listEquals([0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF
F, |
| 2513 0xFFFFFFFF, | 1456 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF
F], |
| 2514 0xFFFFFFFF, | 1457 view); |
| 2515 0xFFFFFFFF, | 1458 Expect.throws(() { view[-1] = 0; }, |
| 2516 0xFFFFFFFF, | 1459 (e) { return e is RangeError; }); |
| 2517 0xFFFFFFFF, | 1460 Expect.throws(() { return view[-1]; }, |
| 2518 0xFFFFFFFF, | 1461 (e) { return e is RangeError; }); |
| 2519 0xFFFFFFFF, | 1462 Expect.throws(() { view[view.length]; }, |
| 2520 0xFFFFFFFF, | 1463 (e) { return e is RangeError; }); |
| 2521 0xFFFFFFFF, | 1464 Expect.throws(() { view[view.length] = 0; }, |
| 2522 0xFFFFFFFF | 1465 (e) { return e is RangeError; }); |
| 2523 ], view); | 1466 Expect.throws(() { view.add(0); }, |
| 2524 Expect.throws(() { | 1467 (e) { return e is UnsupportedError; }); |
| 2525 view[-1] = 0; | 1468 Expect.throws(() { view.addAll([0]); }, |
| 2526 }, (e) { | 1469 (e) { return e is UnsupportedError; }); |
| 2527 return e is RangeError; | 1470 Expect.throws(() { view.clear(); }, |
| 2528 }); | 1471 (e) { return e is UnsupportedError; }); |
| 2529 Expect.throws(() { | 1472 Expect.throws(() { view.length = 0; }, |
| 2530 return view[-1]; | 1473 (e) { return e is UnsupportedError; }); |
| 2531 }, (e) { | 1474 Expect.throws(() { view.removeLast(); }, |
| 2532 return e is RangeError; | 1475 (e) { return e is UnsupportedError; }); |
| 2533 }); | 1476 Expect.throws(() { view.removeRange(0, view.length - 1); }, |
| 2534 Expect.throws(() { | 1477 (e) { return e is UnsupportedError; }); |
| 2535 view[view.length]; | |
| 2536 }, (e) { | |
| 2537 return e is RangeError; | |
| 2538 }); | |
| 2539 Expect.throws(() { | |
| 2540 view[view.length] = 0; | |
| 2541 }, (e) { | |
| 2542 return e is RangeError; | |
| 2543 }); | |
| 2544 Expect.throws(() { | |
| 2545 view.add(0); | |
| 2546 }, (e) { | |
| 2547 return e is UnsupportedError; | |
| 2548 }); | |
| 2549 Expect.throws(() { | |
| 2550 view.addAll([0]); | |
| 2551 }, (e) { | |
| 2552 return e is UnsupportedError; | |
| 2553 }); | |
| 2554 Expect.throws(() { | |
| 2555 view.clear(); | |
| 2556 }, (e) { | |
| 2557 return e is UnsupportedError; | |
| 2558 }); | |
| 2559 Expect.throws(() { | |
| 2560 view.length = 0; | |
| 2561 }, (e) { | |
| 2562 return e is UnsupportedError; | |
| 2563 }); | |
| 2564 Expect.throws(() { | |
| 2565 view.removeLast(); | |
| 2566 }, (e) { | |
| 2567 return e is UnsupportedError; | |
| 2568 }); | |
| 2569 Expect.throws(() { | |
| 2570 view.removeRange(0, view.length - 1); | |
| 2571 }, (e) { | |
| 2572 return e is UnsupportedError; | |
| 2573 }); | |
| 2574 for (int i = 0; i < view.length; ++i) { | 1478 for (int i = 0; i < view.length; ++i) { |
| 2575 view[i] = 1 + i; | 1479 view[i] = 1 + i; |
| 2576 } | 1480 } |
| 2577 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); | 1481 Expect.listEquals([1, 2, 3, 4, 5, |
| 2578 Expect.listEquals([ | 1482 6, 7, 8, 9, 10], |
| 2579 -1, | 1483 view); |
| 2580 -1, | 1484 Expect.listEquals([-1, -1, -1, -1, 1, 0, 0, 0, |
| 2581 -1, | 1485 2, 0, 0, 0, 3, 0, 0, 0, |
| 2582 -1, | 1486 4, 0, 0, 0, 5, 0, 0, 0, |
| 2583 1, | 1487 6, 0, 0, 0, 7, 0, 0, 0, |
| 2584 0, | 1488 8, 0, 0, 0, 9, 0, 0, 0, |
| 2585 0, | 1489 10, 0, 0, 0, -1, -1, -1, -1], |
| 2586 0, | 1490 array); |
| 2587 2, | |
| 2588 0, | |
| 2589 0, | |
| 2590 0, | |
| 2591 3, | |
| 2592 0, | |
| 2593 0, | |
| 2594 0, | |
| 2595 4, | |
| 2596 0, | |
| 2597 0, | |
| 2598 0, | |
| 2599 5, | |
| 2600 0, | |
| 2601 0, | |
| 2602 0, | |
| 2603 6, | |
| 2604 0, | |
| 2605 0, | |
| 2606 0, | |
| 2607 7, | |
| 2608 0, | |
| 2609 0, | |
| 2610 0, | |
| 2611 8, | |
| 2612 0, | |
| 2613 0, | |
| 2614 0, | |
| 2615 9, | |
| 2616 0, | |
| 2617 0, | |
| 2618 0, | |
| 2619 10, | |
| 2620 0, | |
| 2621 0, | |
| 2622 0, | |
| 2623 -1, | |
| 2624 -1, | |
| 2625 -1, | |
| 2626 -1 | |
| 2627 ], array); | |
| 2628 for (int i = 0; i < view.length; ++i) { | 1491 for (int i = 0; i < view.length; ++i) { |
| 2629 view[i] = 0x100000000 + i; | 1492 view[i] = 0x100000000 + i; |
| 2630 } | 1493 } |
| 2631 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); | 1494 Expect.listEquals([0, 1, 2, 3, 4, |
| 2632 Expect.listEquals([ | 1495 5, 6, 7, 8, 9], |
| 2633 -1, | 1496 view); |
| 2634 -1, | 1497 Expect.listEquals([-1, -1, -1, -1, 0, 0, 0, 0, |
| 2635 -1, | 1498 1, 0, 0, 0, 2, 0, 0, 0, |
| 2636 -1, | 1499 3, 0, 0, 0, 4, 0, 0, 0, |
| 2637 0, | 1500 5, 0, 0, 0, 6, 0, 0, 0, |
| 2638 0, | 1501 7, 0, 0, 0, 8, 0, 0, 0, |
| 2639 0, | 1502 9, 0, 0, 0, -1, -1, -1, -1], |
| 2640 0, | 1503 array); |
| 2641 1, | |
| 2642 0, | |
| 2643 0, | |
| 2644 0, | |
| 2645 2, | |
| 2646 0, | |
| 2647 0, | |
| 2648 0, | |
| 2649 3, | |
| 2650 0, | |
| 2651 0, | |
| 2652 0, | |
| 2653 4, | |
| 2654 0, | |
| 2655 0, | |
| 2656 0, | |
| 2657 5, | |
| 2658 0, | |
| 2659 0, | |
| 2660 0, | |
| 2661 6, | |
| 2662 0, | |
| 2663 0, | |
| 2664 0, | |
| 2665 7, | |
| 2666 0, | |
| 2667 0, | |
| 2668 0, | |
| 2669 8, | |
| 2670 0, | |
| 2671 0, | |
| 2672 0, | |
| 2673 9, | |
| 2674 0, | |
| 2675 0, | |
| 2676 0, | |
| 2677 -1, | |
| 2678 -1, | |
| 2679 -1, | |
| 2680 -1 | |
| 2681 ], array); | |
| 2682 for (int i = 0; i < view.length; ++i) { | 1504 for (int i = 0; i < view.length; ++i) { |
| 2683 view[i] = 0xFFFFFFFF - i; | 1505 view[i] = 0xFFFFFFFF - i; |
| 2684 } | 1506 } |
| 2685 Expect.listEquals([ | 1507 Expect.listEquals([0xFFFFFFFF, 0xFFFFFFFE, |
| 2686 0xFFFFFFFF, | 1508 0xFFFFFFFD, 0xFFFFFFFC, |
| 2687 0xFFFFFFFE, | 1509 0xFFFFFFFB, 0xFFFFFFFA, |
| 2688 0xFFFFFFFD, | 1510 0xFFFFFFF9, 0xFFFFFFF8, |
| 2689 0xFFFFFFFC, | 1511 0xFFFFFFF7, 0xFFFFFFF6], |
| 2690 0xFFFFFFFB, | 1512 view); |
| 2691 0xFFFFFFFA, | 1513 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, |
| 2692 0xFFFFFFF9, | 1514 -2, -1, -1, -1, -3, -1, -1, -1, |
| 2693 0xFFFFFFF8, | 1515 -4, -1, -1, -1, -5, -1, -1, -1, |
| 2694 0xFFFFFFF7, | 1516 -6, -1, -1, -1, -7, -1, -1, -1, |
| 2695 0xFFFFFFF6 | 1517 -8, -1, -1, -1, -9, -1, -1, -1, |
| 2696 ], view); | 1518 -10, -1, -1, -1, -1, -1, -1, -1], |
| 2697 Expect.listEquals([ | 1519 array); |
| 2698 -1, | |
| 2699 -1, | |
| 2700 -1, | |
| 2701 -1, | |
| 2702 -1, | |
| 2703 -1, | |
| 2704 -1, | |
| 2705 -1, | |
| 2706 -2, | |
| 2707 -1, | |
| 2708 -1, | |
| 2709 -1, | |
| 2710 -3, | |
| 2711 -1, | |
| 2712 -1, | |
| 2713 -1, | |
| 2714 -4, | |
| 2715 -1, | |
| 2716 -1, | |
| 2717 -1, | |
| 2718 -5, | |
| 2719 -1, | |
| 2720 -1, | |
| 2721 -1, | |
| 2722 -6, | |
| 2723 -1, | |
| 2724 -1, | |
| 2725 -1, | |
| 2726 -7, | |
| 2727 -1, | |
| 2728 -1, | |
| 2729 -1, | |
| 2730 -8, | |
| 2731 -1, | |
| 2732 -1, | |
| 2733 -1, | |
| 2734 -9, | |
| 2735 -1, | |
| 2736 -1, | |
| 2737 -1, | |
| 2738 -10, | |
| 2739 -1, | |
| 2740 -1, | |
| 2741 -1, | |
| 2742 -1, | |
| 2743 -1, | |
| 2744 -1, | |
| 2745 -1 | |
| 2746 ], array); | |
| 2747 for (int i = 0; i < view.length; ++i) { | 1520 for (int i = 0; i < view.length; ++i) { |
| 2748 view[i] = i; | 1521 view[i] = i; |
| 2749 } | 1522 } |
| 2750 var copy = view.sublist(0, view.length); | 1523 var copy = view.sublist(0, view.length); |
| 2751 Expect.isFalse(identical(copy, view)); | 1524 Expect.isFalse(identical(copy, view)); |
| 2752 Expect.isTrue(copy is Uint32List); | 1525 Expect.isTrue(copy is Uint32List); |
| 2753 Expect.equals(10, copy.length); | 1526 Expect.equals(10, copy.length); |
| 2754 Expect.listEquals(view, copy); | 1527 Expect.listEquals(view, copy); |
| 2755 var region = view.sublist(3, view.length - 3); | 1528 var region = view.sublist(3, view.length - 3); |
| 2756 Expect.isTrue(copy is Uint32List); | 1529 Expect.isTrue(copy is Uint32List); |
| 2757 Expect.equals(4, region.length); | 1530 Expect.equals(4, region.length); |
| 2758 Expect.listEquals([3, 4, 5, 6], region); | 1531 Expect.listEquals([3, 4, 5, 6], region); |
| 2759 view.setRange(3, 7, [0x100000001, 0, 1, 0xFFFFFFFF]); | 1532 view.setRange(3, 7, [0x100000001, 0, 1, 0xFFFFFFFF]); |
| 2760 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], view); | 1533 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], |
| 2761 Expect.listEquals([ | 1534 view); |
| 2762 -1, | 1535 Expect.listEquals([-1, -1, -1, -1, 0, 0, 0, 0, |
| 2763 -1, | 1536 1, 0, 0, 0, 2, 0, 0, 0, |
| 2764 -1, | 1537 1, 0, 0, 0, 0, 0, 0, 0, |
| 2765 -1, | 1538 1, 0, 0, 0, -1, -1, -1, -1, |
| 2766 0, | 1539 7, 0, 0, 0, 8, 0, 0, 0, |
| 2767 0, | 1540 9, 0, 0, 0, -1, -1, -1, -1], |
| 2768 0, | 1541 array); |
| 2769 0, | |
| 2770 1, | |
| 2771 0, | |
| 2772 0, | |
| 2773 0, | |
| 2774 2, | |
| 2775 0, | |
| 2776 0, | |
| 2777 0, | |
| 2778 1, | |
| 2779 0, | |
| 2780 0, | |
| 2781 0, | |
| 2782 0, | |
| 2783 0, | |
| 2784 0, | |
| 2785 0, | |
| 2786 1, | |
| 2787 0, | |
| 2788 0, | |
| 2789 0, | |
| 2790 -1, | |
| 2791 -1, | |
| 2792 -1, | |
| 2793 -1, | |
| 2794 7, | |
| 2795 0, | |
| 2796 0, | |
| 2797 0, | |
| 2798 8, | |
| 2799 0, | |
| 2800 0, | |
| 2801 0, | |
| 2802 9, | |
| 2803 0, | |
| 2804 0, | |
| 2805 0, | |
| 2806 -1, | |
| 2807 -1, | |
| 2808 -1, | |
| 2809 -1 | |
| 2810 ], array); | |
| 2811 } | 1542 } |
| 2812 | 1543 |
| 2813 static testUint32ListView() { | 1544 static testUint32ListView() { |
| 2814 var array = new Int8List(48); | 1545 var array = new Int8List(48); |
| 2815 testUint32ListViewImpl(array); | 1546 testUint32ListViewImpl(array); |
| 2816 } | 1547 } |
| 2817 | 1548 |
| 2818 static testInt64ListViewImpl(var array) { | 1549 static testInt64ListViewImpl(var array) { |
| 2819 Expect.equals(96, array.length); | 1550 Expect.equals(96, array.length); |
| 2820 Expect.equals(1, array.elementSizeInBytes); | 1551 Expect.equals(1, array.elementSizeInBytes); |
| 2821 Expect.equals(96, array.lengthInBytes); | 1552 Expect.equals(96, array.lengthInBytes); |
| 2822 for (int i = 0; i < array.length; ++i) { | 1553 for (int i = 0; i < array.length; ++i) { |
| 2823 array[i] = 0xFF; | 1554 array[i] = 0xFF; |
| 2824 } | 1555 } |
| 2825 Expect.throws(() { | 1556 Expect.throws(() { new Int64List.view(array.buffer, -1); }, |
| 2826 new Int64List.view(array.buffer, -1); | 1557 (e) { return e is RangeError; }); |
| 2827 }, (e) { | 1558 Expect.throws(() { new Int64List.view(array.buffer, 0, -1); }, |
| 2828 return e is RangeError; | 1559 (e) { return e is RangeError; }); |
| 2829 }); | 1560 Expect.throws(() { new Int64List.view(array.buffer, |
| 2830 Expect.throws(() { | 1561 array.lengthInBytes + 1); }, |
| 2831 new Int64List.view(array.buffer, 0, -1); | 1562 (e) { return e is RangeError; }); |
| 2832 }, (e) { | 1563 Expect.throws(() { new Int64List.view(array.buffer, |
| 2833 return e is RangeError; | 1564 0, array.length + 1); }, |
| 2834 }); | 1565 (e) { return e is RangeError; }); |
| 2835 Expect.throws(() { | 1566 Expect.throws(() { new Int64List.view(array.buffer, |
| 2836 new Int64List.view(array.buffer, array.lengthInBytes + 1); | 1567 array.length - 1, 2); }, |
| 2837 }, (e) { | 1568 (e) { return e is RangeError; }); |
| 2838 return e is RangeError; | 1569 var empty = new Int64List.view(array.buffer, |
| 2839 }); | 1570 array.lengthInBytes); |
| 2840 Expect.throws(() { | |
| 2841 new Int64List.view(array.buffer, 0, array.length + 1); | |
| 2842 }, (e) { | |
| 2843 return e is RangeError; | |
| 2844 }); | |
| 2845 Expect.throws(() { | |
| 2846 new Int64List.view(array.buffer, array.length - 1, 2); | |
| 2847 }, (e) { | |
| 2848 return e is RangeError; | |
| 2849 }); | |
| 2850 var empty = new Int64List.view(array.buffer, array.lengthInBytes); | |
| 2851 Expect.isTrue(empty is List<int>); | 1571 Expect.isTrue(empty is List<int>); |
| 2852 Expect.isTrue(empty is Int64List); | 1572 Expect.isTrue(empty is Int64List); |
| 2853 Expect.equals(0, empty.length); | 1573 Expect.equals(0, empty.length); |
| 2854 var whole = new Int64List.view(array.buffer); | 1574 var whole = new Int64List.view(array.buffer); |
| 2855 Expect.isTrue(whole is List<int>); | 1575 Expect.isTrue(whole is List<int>); |
| 2856 Expect.isTrue(whole is Int64List); | 1576 Expect.isTrue(whole is Int64List); |
| 2857 Expect.equals(12, whole.length); | 1577 Expect.equals(12, whole.length); |
| 2858 var view = new Int64List.view(array.buffer, 8, 10); | 1578 var view = new Int64List.view(array.buffer, 8, 10); |
| 2859 Expect.isTrue(view is List<int>); | 1579 Expect.isTrue(view is List<int>); |
| 2860 Expect.isTrue(view is Int64List); | 1580 Expect.isTrue(view is Int64List); |
| 2861 Expect.equals(10, view.length); | 1581 Expect.equals(10, view.length); |
| 2862 Expect.equals(8, view.elementSizeInBytes); | 1582 Expect.equals(8, view.elementSizeInBytes); |
| 2863 Expect.equals(80, view.lengthInBytes); | 1583 Expect.equals(80, view.lengthInBytes); |
| 2864 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], view); | 1584 Expect.listEquals([-1, -1, -1, -1, -1, |
| 2865 Expect.throws(() { | 1585 -1, -1, -1, -1, -1], |
| 2866 view[-1] = 0; | 1586 view); |
| 2867 }, (e) { | 1587 Expect.throws(() { view[-1] = 0; }, |
| 2868 return e is RangeError; | 1588 (e) { return e is RangeError; }); |
| 2869 }); | 1589 Expect.throws(() { return view[-1]; }, |
| 2870 Expect.throws(() { | 1590 (e) { return e is RangeError; }); |
| 2871 return view[-1]; | 1591 Expect.throws(() { view[view.length]; }, |
| 2872 }, (e) { | 1592 (e) { return e is RangeError; }); |
| 2873 return e is RangeError; | 1593 Expect.throws(() { view[10] = 0; }, |
| 2874 }); | 1594 (e) { return e is RangeError; }); |
| 2875 Expect.throws(() { | 1595 Expect.throws(() { view.add(0); }, |
| 2876 view[view.length]; | 1596 (e) { return e is UnsupportedError; }); |
| 2877 }, (e) { | 1597 Expect.throws(() { view.addAll([0]); }, |
| 2878 return e is RangeError; | 1598 (e) { return e is UnsupportedError; }); |
| 2879 }); | 1599 Expect.throws(() { view.clear(); }, |
| 2880 Expect.throws(() { | 1600 (e) { return e is UnsupportedError; }); |
| 2881 view[10] = 0; | 1601 Expect.throws(() { view.length = 0; }, |
| 2882 }, (e) { | 1602 (e) { return e is UnsupportedError; }); |
| 2883 return e is RangeError; | 1603 Expect.throws(() { view.removeLast(); }, |
| 2884 }); | 1604 (e) { return e is UnsupportedError; }); |
| 2885 Expect.throws(() { | 1605 Expect.throws(() { view.removeRange(0, view.length - 1); }, |
| 2886 view.add(0); | 1606 (e) { return e is UnsupportedError; }); |
| 2887 }, (e) { | |
| 2888 return e is UnsupportedError; | |
| 2889 }); | |
| 2890 Expect.throws(() { | |
| 2891 view.addAll([0]); | |
| 2892 }, (e) { | |
| 2893 return e is UnsupportedError; | |
| 2894 }); | |
| 2895 Expect.throws(() { | |
| 2896 view.clear(); | |
| 2897 }, (e) { | |
| 2898 return e is UnsupportedError; | |
| 2899 }); | |
| 2900 Expect.throws(() { | |
| 2901 view.length = 0; | |
| 2902 }, (e) { | |
| 2903 return e is UnsupportedError; | |
| 2904 }); | |
| 2905 Expect.throws(() { | |
| 2906 view.removeLast(); | |
| 2907 }, (e) { | |
| 2908 return e is UnsupportedError; | |
| 2909 }); | |
| 2910 Expect.throws(() { | |
| 2911 view.removeRange(0, view.length - 1); | |
| 2912 }, (e) { | |
| 2913 return e is UnsupportedError; | |
| 2914 }); | |
| 2915 for (int i = 0; i < view.length; ++i) { | 1607 for (int i = 0; i < view.length; ++i) { |
| 2916 view[i] = 1 + i; | 1608 view[i] = 1 + i; |
| 2917 } | 1609 } |
| 2918 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); | 1610 Expect.listEquals([1, 2, 3, 4, 5, |
| 2919 Expect.listEquals([ | 1611 6, 7, 8, 9, 10], |
| 2920 0xFF, | 1612 view); |
| 2921 0xFF, | 1613 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 2922 0xFF, | 1614 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 2923 0xFF, | 1615 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 2924 0xFF, | 1616 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 2925 0xFF, | 1617 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 2926 0xFF, | 1618 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 2927 0xFF, | 1619 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 2928 0x01, | 1620 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 2929 0x00, | 1621 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 2930 0x00, | 1622 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 2931 0x00, | 1623 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 2932 0x00, | 1624 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
| 2933 0x00, | 1625 array); |
| 2934 0x00, | |
| 2935 0x00, | |
| 2936 0x02, | |
| 2937 0x00, | |
| 2938 0x00, | |
| 2939 0x00, | |
| 2940 0x00, | |
| 2941 0x00, | |
| 2942 0x00, | |
| 2943 0x00, | |
| 2944 0x03, | |
| 2945 0x00, | |
| 2946 0x00, | |
| 2947 0x00, | |
| 2948 0x00, | |
| 2949 0x00, | |
| 2950 0x00, | |
| 2951 0x00, | |
| 2952 0x04, | |
| 2953 0x00, | |
| 2954 0x00, | |
| 2955 0x00, | |
| 2956 0x00, | |
| 2957 0x00, | |
| 2958 0x00, | |
| 2959 0x00, | |
| 2960 0x05, | |
| 2961 0x00, | |
| 2962 0x00, | |
| 2963 0x00, | |
| 2964 0x00, | |
| 2965 0x00, | |
| 2966 0x00, | |
| 2967 0x00, | |
| 2968 0x06, | |
| 2969 0x00, | |
| 2970 0x00, | |
| 2971 0x00, | |
| 2972 0x00, | |
| 2973 0x00, | |
| 2974 0x00, | |
| 2975 0x00, | |
| 2976 0x07, | |
| 2977 0x00, | |
| 2978 0x00, | |
| 2979 0x00, | |
| 2980 0x00, | |
| 2981 0x00, | |
| 2982 0x00, | |
| 2983 0x00, | |
| 2984 0x08, | |
| 2985 0x00, | |
| 2986 0x00, | |
| 2987 0x00, | |
| 2988 0x00, | |
| 2989 0x00, | |
| 2990 0x00, | |
| 2991 0x00, | |
| 2992 0x09, | |
| 2993 0x00, | |
| 2994 0x00, | |
| 2995 0x00, | |
| 2996 0x00, | |
| 2997 0x00, | |
| 2998 0x00, | |
| 2999 0x00, | |
| 3000 0x0A, | |
| 3001 0x00, | |
| 3002 0x00, | |
| 3003 0x00, | |
| 3004 0x00, | |
| 3005 0x00, | |
| 3006 0x00, | |
| 3007 0x00, | |
| 3008 0xFF, | |
| 3009 0xFF, | |
| 3010 0xFF, | |
| 3011 0xFF, | |
| 3012 0xFF, | |
| 3013 0xFF, | |
| 3014 0xFF, | |
| 3015 0xFF | |
| 3016 ], array); | |
| 3017 for (int i = 0; i < view.length; ++i) { | 1626 for (int i = 0; i < view.length; ++i) { |
| 3018 view[i] = 0x10000000000000000 + i; | 1627 view[i] = 0x10000000000000000 + i; |
| 3019 } | 1628 } |
| 3020 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); | 1629 Expect.listEquals([0, 1, 2, 3, 4, |
| 3021 Expect.listEquals([ | 1630 5, 6, 7, 8, 9], |
| 3022 0xFF, | 1631 view); |
| 3023 0xFF, | 1632 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3024 0xFF, | 1633 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3025 0xFF, | 1634 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3026 0xFF, | 1635 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3027 0xFF, | 1636 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3028 0xFF, | 1637 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3029 0xFF, | 1638 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3030 0x00, | 1639 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3031 0x00, | 1640 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3032 0x00, | 1641 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3033 0x00, | 1642 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3034 0x00, | 1643 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
| 3035 0x00, | 1644 array); |
| 3036 0x00, | |
| 3037 0x00, | |
| 3038 0x01, | |
| 3039 0x00, | |
| 3040 0x00, | |
| 3041 0x00, | |
| 3042 0x00, | |
| 3043 0x00, | |
| 3044 0x00, | |
| 3045 0x00, | |
| 3046 0x02, | |
| 3047 0x00, | |
| 3048 0x00, | |
| 3049 0x00, | |
| 3050 0x00, | |
| 3051 0x00, | |
| 3052 0x00, | |
| 3053 0x00, | |
| 3054 0x03, | |
| 3055 0x00, | |
| 3056 0x00, | |
| 3057 0x00, | |
| 3058 0x00, | |
| 3059 0x00, | |
| 3060 0x00, | |
| 3061 0x00, | |
| 3062 0x04, | |
| 3063 0x00, | |
| 3064 0x00, | |
| 3065 0x00, | |
| 3066 0x00, | |
| 3067 0x00, | |
| 3068 0x00, | |
| 3069 0x00, | |
| 3070 0x05, | |
| 3071 0x00, | |
| 3072 0x00, | |
| 3073 0x00, | |
| 3074 0x00, | |
| 3075 0x00, | |
| 3076 0x00, | |
| 3077 0x00, | |
| 3078 0x06, | |
| 3079 0x00, | |
| 3080 0x00, | |
| 3081 0x00, | |
| 3082 0x00, | |
| 3083 0x00, | |
| 3084 0x00, | |
| 3085 0x00, | |
| 3086 0x07, | |
| 3087 0x00, | |
| 3088 0x00, | |
| 3089 0x00, | |
| 3090 0x00, | |
| 3091 0x00, | |
| 3092 0x00, | |
| 3093 0x00, | |
| 3094 0x08, | |
| 3095 0x00, | |
| 3096 0x00, | |
| 3097 0x00, | |
| 3098 0x00, | |
| 3099 0x00, | |
| 3100 0x00, | |
| 3101 0x00, | |
| 3102 0x09, | |
| 3103 0x00, | |
| 3104 0x00, | |
| 3105 0x00, | |
| 3106 0x00, | |
| 3107 0x00, | |
| 3108 0x00, | |
| 3109 0x00, | |
| 3110 0xFF, | |
| 3111 0xFF, | |
| 3112 0xFF, | |
| 3113 0xFF, | |
| 3114 0xFF, | |
| 3115 0xFF, | |
| 3116 0xFF, | |
| 3117 0xFF | |
| 3118 ], array); | |
| 3119 for (int i = 0; i < view.length; ++i) { | 1645 for (int i = 0; i < view.length; ++i) { |
| 3120 view[i] = -10 + i; | 1646 view[i] = -10 + i; |
| 3121 } | 1647 } |
| 3122 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], view); | 1648 Expect.listEquals([-10, -9, -8, -7, -6, |
| 3123 Expect.listEquals([ | 1649 -5, -4, -3, -2, -1], |
| 3124 0xFF, | 1650 view); |
| 3125 0xFF, | 1651 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3126 0xFF, | 1652 0xF6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3127 0xFF, | 1653 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3128 0xFF, | 1654 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3129 0xFF, | 1655 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3130 0xFF, | 1656 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3131 0xFF, | 1657 0xFB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3132 0xF6, | 1658 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3133 0xFF, | 1659 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3134 0xFF, | 1660 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3135 0xFF, | 1661 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3136 0xFF, | 1662 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
| 3137 0xFF, | 1663 array); |
| 3138 0xFF, | |
| 3139 0xFF, | |
| 3140 0xF7, | |
| 3141 0xFF, | |
| 3142 0xFF, | |
| 3143 0xFF, | |
| 3144 0xFF, | |
| 3145 0xFF, | |
| 3146 0xFF, | |
| 3147 0xFF, | |
| 3148 0xF8, | |
| 3149 0xFF, | |
| 3150 0xFF, | |
| 3151 0xFF, | |
| 3152 0xFF, | |
| 3153 0xFF, | |
| 3154 0xFF, | |
| 3155 0xFF, | |
| 3156 0xF9, | |
| 3157 0xFF, | |
| 3158 0xFF, | |
| 3159 0xFF, | |
| 3160 0xFF, | |
| 3161 0xFF, | |
| 3162 0xFF, | |
| 3163 0xFF, | |
| 3164 0xFA, | |
| 3165 0xFF, | |
| 3166 0xFF, | |
| 3167 0xFF, | |
| 3168 0xFF, | |
| 3169 0xFF, | |
| 3170 0xFF, | |
| 3171 0xFF, | |
| 3172 0xFB, | |
| 3173 0xFF, | |
| 3174 0xFF, | |
| 3175 0xFF, | |
| 3176 0xFF, | |
| 3177 0xFF, | |
| 3178 0xFF, | |
| 3179 0xFF, | |
| 3180 0xFC, | |
| 3181 0xFF, | |
| 3182 0xFF, | |
| 3183 0xFF, | |
| 3184 0xFF, | |
| 3185 0xFF, | |
| 3186 0xFF, | |
| 3187 0xFF, | |
| 3188 0xFD, | |
| 3189 0xFF, | |
| 3190 0xFF, | |
| 3191 0xFF, | |
| 3192 0xFF, | |
| 3193 0xFF, | |
| 3194 0xFF, | |
| 3195 0xFF, | |
| 3196 0xFE, | |
| 3197 0xFF, | |
| 3198 0xFF, | |
| 3199 0xFF, | |
| 3200 0xFF, | |
| 3201 0xFF, | |
| 3202 0xFF, | |
| 3203 0xFF, | |
| 3204 0xFF, | |
| 3205 0xFF, | |
| 3206 0xFF, | |
| 3207 0xFF, | |
| 3208 0xFF, | |
| 3209 0xFF, | |
| 3210 0xFF, | |
| 3211 0xFF, | |
| 3212 0xFF, | |
| 3213 0xFF, | |
| 3214 0xFF, | |
| 3215 0xFF, | |
| 3216 0xFF, | |
| 3217 0xFF, | |
| 3218 0xFF, | |
| 3219 0xFF | |
| 3220 ], array); | |
| 3221 for (int i = 0; i < view.length; ++i) { | 1664 for (int i = 0; i < view.length; ++i) { |
| 3222 view[i] = 0x7FFFFFFFFFFFFFFF - i; | 1665 view[i] = 0x7FFFFFFFFFFFFFFF - i; |
| 3223 } | 1666 } |
| 3224 Expect.listEquals([ | 1667 Expect.listEquals([0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFE, |
| 3225 0x7FFFFFFFFFFFFFFF, | 1668 0x7FFFFFFFFFFFFFFD, 0x7FFFFFFFFFFFFFFC, |
| 3226 0x7FFFFFFFFFFFFFFE, | 1669 0x7FFFFFFFFFFFFFFB, 0x7FFFFFFFFFFFFFFA, |
| 3227 0x7FFFFFFFFFFFFFFD, | 1670 0x7FFFFFFFFFFFFFF9, 0x7FFFFFFFFFFFFFF8, |
| 3228 0x7FFFFFFFFFFFFFFC, | 1671 0x7FFFFFFFFFFFFFF7, 0x7FFFFFFFFFFFFFF6], |
| 3229 0x7FFFFFFFFFFFFFFB, | 1672 view); |
| 3230 0x7FFFFFFFFFFFFFFA, | 1673 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3231 0x7FFFFFFFFFFFFFF9, | 1674 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, |
| 3232 0x7FFFFFFFFFFFFFF8, | 1675 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, |
| 3233 0x7FFFFFFFFFFFFFF7, | 1676 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, |
| 3234 0x7FFFFFFFFFFFFFF6 | 1677 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, |
| 3235 ], view); | 1678 0xFB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, |
| 3236 Expect.listEquals([ | 1679 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, |
| 3237 0xFF, | 1680 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, |
| 3238 0xFF, | 1681 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, |
| 3239 0xFF, | 1682 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, |
| 3240 0xFF, | 1683 0xF6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, |
| 3241 0xFF, | 1684 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
| 3242 0xFF, | 1685 array); |
| 3243 0xFF, | |
| 3244 0xFF, | |
| 3245 0xFF, | |
| 3246 0xFF, | |
| 3247 0xFF, | |
| 3248 0xFF, | |
| 3249 0xFF, | |
| 3250 0xFF, | |
| 3251 0xFF, | |
| 3252 0x7F, | |
| 3253 0xFE, | |
| 3254 0xFF, | |
| 3255 0xFF, | |
| 3256 0xFF, | |
| 3257 0xFF, | |
| 3258 0xFF, | |
| 3259 0xFF, | |
| 3260 0x7F, | |
| 3261 0xFD, | |
| 3262 0xFF, | |
| 3263 0xFF, | |
| 3264 0xFF, | |
| 3265 0xFF, | |
| 3266 0xFF, | |
| 3267 0xFF, | |
| 3268 0x7F, | |
| 3269 0xFC, | |
| 3270 0xFF, | |
| 3271 0xFF, | |
| 3272 0xFF, | |
| 3273 0xFF, | |
| 3274 0xFF, | |
| 3275 0xFF, | |
| 3276 0x7F, | |
| 3277 0xFB, | |
| 3278 0xFF, | |
| 3279 0xFF, | |
| 3280 0xFF, | |
| 3281 0xFF, | |
| 3282 0xFF, | |
| 3283 0xFF, | |
| 3284 0x7F, | |
| 3285 0xFA, | |
| 3286 0xFF, | |
| 3287 0xFF, | |
| 3288 0xFF, | |
| 3289 0xFF, | |
| 3290 0xFF, | |
| 3291 0xFF, | |
| 3292 0x7F, | |
| 3293 0xF9, | |
| 3294 0xFF, | |
| 3295 0xFF, | |
| 3296 0xFF, | |
| 3297 0xFF, | |
| 3298 0xFF, | |
| 3299 0xFF, | |
| 3300 0x7F, | |
| 3301 0xF8, | |
| 3302 0xFF, | |
| 3303 0xFF, | |
| 3304 0xFF, | |
| 3305 0xFF, | |
| 3306 0xFF, | |
| 3307 0xFF, | |
| 3308 0x7F, | |
| 3309 0xF7, | |
| 3310 0xFF, | |
| 3311 0xFF, | |
| 3312 0xFF, | |
| 3313 0xFF, | |
| 3314 0xFF, | |
| 3315 0xFF, | |
| 3316 0x7F, | |
| 3317 0xF6, | |
| 3318 0xFF, | |
| 3319 0xFF, | |
| 3320 0xFF, | |
| 3321 0xFF, | |
| 3322 0xFF, | |
| 3323 0xFF, | |
| 3324 0x7F, | |
| 3325 0xFF, | |
| 3326 0xFF, | |
| 3327 0xFF, | |
| 3328 0xFF, | |
| 3329 0xFF, | |
| 3330 0xFF, | |
| 3331 0xFF, | |
| 3332 0xFF | |
| 3333 ], array); | |
| 3334 for (int i = 0; i < view.length; ++i) { | 1686 for (int i = 0; i < view.length; ++i) { |
| 3335 view[i] = -0x8000000000000000 + i; | 1687 view[i] = -0x8000000000000000 + i; |
| 3336 } | 1688 } |
| 3337 Expect.listEquals([ | 1689 Expect.listEquals([-0x8000000000000000, -0x7FFFFFFFFFFFFFFF, |
| 3338 -0x8000000000000000, | 1690 -0x7FFFFFFFFFFFFFFE, -0x7FFFFFFFFFFFFFFD, |
| 3339 -0x7FFFFFFFFFFFFFFF, | 1691 -0x7FFFFFFFFFFFFFFC, -0x7FFFFFFFFFFFFFFB, |
| 3340 -0x7FFFFFFFFFFFFFFE, | 1692 -0x7FFFFFFFFFFFFFFA, -0x7FFFFFFFFFFFFFF9, |
| 3341 -0x7FFFFFFFFFFFFFFD, | 1693 -0x7FFFFFFFFFFFFFF8, -0x7FFFFFFFFFFFFFF7], |
| 3342 -0x7FFFFFFFFFFFFFFC, | 1694 view); |
| 3343 -0x7FFFFFFFFFFFFFFB, | 1695 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3344 -0x7FFFFFFFFFFFFFFA, | 1696 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
| 3345 -0x7FFFFFFFFFFFFFF9, | 1697 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
| 3346 -0x7FFFFFFFFFFFFFF8, | 1698 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
| 3347 -0x7FFFFFFFFFFFFFF7 | 1699 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
| 3348 ], view); | 1700 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
| 3349 Expect.listEquals([ | 1701 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
| 3350 0xFF, | 1702 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
| 3351 0xFF, | 1703 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
| 3352 0xFF, | 1704 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
| 3353 0xFF, | 1705 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
| 3354 0xFF, | 1706 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
| 3355 0xFF, | 1707 array); |
| 3356 0xFF, | |
| 3357 0xFF, | |
| 3358 0x00, | |
| 3359 0x00, | |
| 3360 0x00, | |
| 3361 0x00, | |
| 3362 0x00, | |
| 3363 0x00, | |
| 3364 0x00, | |
| 3365 0x80, | |
| 3366 0x01, | |
| 3367 0x00, | |
| 3368 0x00, | |
| 3369 0x00, | |
| 3370 0x00, | |
| 3371 0x00, | |
| 3372 0x00, | |
| 3373 0x80, | |
| 3374 0x02, | |
| 3375 0x00, | |
| 3376 0x00, | |
| 3377 0x00, | |
| 3378 0x00, | |
| 3379 0x00, | |
| 3380 0x00, | |
| 3381 0x80, | |
| 3382 0x03, | |
| 3383 0x00, | |
| 3384 0x00, | |
| 3385 0x00, | |
| 3386 0x00, | |
| 3387 0x00, | |
| 3388 0x00, | |
| 3389 0x80, | |
| 3390 0x04, | |
| 3391 0x00, | |
| 3392 0x00, | |
| 3393 0x00, | |
| 3394 0x00, | |
| 3395 0x00, | |
| 3396 0x00, | |
| 3397 0x80, | |
| 3398 0x05, | |
| 3399 0x00, | |
| 3400 0x00, | |
| 3401 0x00, | |
| 3402 0x00, | |
| 3403 0x00, | |
| 3404 0x00, | |
| 3405 0x80, | |
| 3406 0x06, | |
| 3407 0x00, | |
| 3408 0x00, | |
| 3409 0x00, | |
| 3410 0x00, | |
| 3411 0x00, | |
| 3412 0x00, | |
| 3413 0x80, | |
| 3414 0x07, | |
| 3415 0x00, | |
| 3416 0x00, | |
| 3417 0x00, | |
| 3418 0x00, | |
| 3419 0x00, | |
| 3420 0x00, | |
| 3421 0x80, | |
| 3422 0x08, | |
| 3423 0x00, | |
| 3424 0x00, | |
| 3425 0x00, | |
| 3426 0x00, | |
| 3427 0x00, | |
| 3428 0x00, | |
| 3429 0x80, | |
| 3430 0x09, | |
| 3431 0x00, | |
| 3432 0x00, | |
| 3433 0x00, | |
| 3434 0x00, | |
| 3435 0x00, | |
| 3436 0x00, | |
| 3437 0x80, | |
| 3438 0xFF, | |
| 3439 0xFF, | |
| 3440 0xFF, | |
| 3441 0xFF, | |
| 3442 0xFF, | |
| 3443 0xFF, | |
| 3444 0xFF, | |
| 3445 0xFF | |
| 3446 ], array); | |
| 3447 for (int i = 0; i < view.length; ++i) { | 1708 for (int i = 0; i < view.length; ++i) { |
| 3448 view[i] = i; | 1709 view[i] = i; |
| 3449 } | 1710 } |
| 3450 var copy = view.sublist(0, view.length); | 1711 var copy = view.sublist(0, view.length); |
| 3451 Expect.isFalse(identical(copy, view)); | 1712 Expect.isFalse(identical(copy, view)); |
| 3452 Expect.isTrue(copy is Int64List); | 1713 Expect.isTrue(copy is Int64List); |
| 3453 Expect.equals(10, copy.length); | 1714 Expect.equals(10, copy.length); |
| 3454 Expect.listEquals(view, copy); | 1715 Expect.listEquals(view, copy); |
| 3455 var region = view.sublist(3, view.length - 3); | 1716 var region = view.sublist(3, view.length - 3); |
| 3456 Expect.isTrue(copy is Int64List); | 1717 Expect.isTrue(copy is Int64List); |
| 3457 Expect.equals(4, region.length); | 1718 Expect.equals(4, region.length); |
| 3458 Expect.listEquals([3, 4, 5, 6], region); | 1719 Expect.listEquals([3, 4, 5, 6], region); |
| 3459 view.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); | 1720 view.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); |
| 3460 Expect.listEquals( | 1721 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, |
| 3461 [0, 1, 2, -0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], | 1722 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], |
| 3462 view); | 1723 view); |
| 3463 Expect.listEquals([ | 1724 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 3464 0xFF, | 1725 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3465 0xFF, | 1726 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3466 0xFF, | 1727 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3467 0xFF, | 1728 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
| 3468 0xFF, | 1729 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3469 0xFF, | 1730 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3470 0xFF, | 1731 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, |
| 3471 0xFF, | 1732 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3472 0x00, | 1733 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3473 0x00, | 1734 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3474 0x00, | 1735 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], |
| 3475 0x00, | 1736 array); |
| 3476 0x00, | |
| 3477 0x00, | |
| 3478 0x00, | |
| 3479 0x00, | |
| 3480 0x01, | |
| 3481 0x00, | |
| 3482 0x00, | |
| 3483 0x00, | |
| 3484 0x00, | |
| 3485 0x00, | |
| 3486 0x00, | |
| 3487 0x00, | |
| 3488 0x02, | |
| 3489 0x00, | |
| 3490 0x00, | |
| 3491 0x00, | |
| 3492 0x00, | |
| 3493 0x00, | |
| 3494 0x00, | |
| 3495 0x00, | |
| 3496 0x00, | |
| 3497 0x00, | |
| 3498 0x00, | |
| 3499 0x00, | |
| 3500 0x00, | |
| 3501 0x00, | |
| 3502 0x00, | |
| 3503 0x80, | |
| 3504 0x00, | |
| 3505 0x00, | |
| 3506 0x00, | |
| 3507 0x00, | |
| 3508 0x00, | |
| 3509 0x00, | |
| 3510 0x00, | |
| 3511 0x00, | |
| 3512 0x01, | |
| 3513 0x00, | |
| 3514 0x00, | |
| 3515 0x00, | |
| 3516 0x00, | |
| 3517 0x00, | |
| 3518 0x00, | |
| 3519 0x00, | |
| 3520 0xFF, | |
| 3521 0xFF, | |
| 3522 0xFF, | |
| 3523 0xFF, | |
| 3524 0xFF, | |
| 3525 0xFF, | |
| 3526 0xFF, | |
| 3527 0x7F, | |
| 3528 0x07, | |
| 3529 0x00, | |
| 3530 0x00, | |
| 3531 0x00, | |
| 3532 0x00, | |
| 3533 0x00, | |
| 3534 0x00, | |
| 3535 0x00, | |
| 3536 0x08, | |
| 3537 0x00, | |
| 3538 0x00, | |
| 3539 0x00, | |
| 3540 0x00, | |
| 3541 0x00, | |
| 3542 0x00, | |
| 3543 0x00, | |
| 3544 0x09, | |
| 3545 0x00, | |
| 3546 0x00, | |
| 3547 0x00, | |
| 3548 0x00, | |
| 3549 0x00, | |
| 3550 0x00, | |
| 3551 0x00, | |
| 3552 0xFF, | |
| 3553 0xFF, | |
| 3554 0xFF, | |
| 3555 0xFF, | |
| 3556 0xFF, | |
| 3557 0xFF, | |
| 3558 0xFF, | |
| 3559 0xFF | |
| 3560 ], array); | |
| 3561 } | 1737 } |
| 3562 | 1738 |
| 3563 static testInt64ListView() { | 1739 static testInt64ListView() { |
| 3564 var array = new Uint8List(96); | 1740 var array = new Uint8List(96); |
| 3565 testInt64ListViewImpl(array); | 1741 testInt64ListViewImpl(array); |
| 3566 } | 1742 } |
| 3567 | 1743 |
| 3568 static testUint64ListViewImpl(var array) { | 1744 static testUint64ListViewImpl(var array) { |
| 3569 Expect.isTrue(array is List<int>); | 1745 Expect.isTrue(array is List<int>); |
| 3570 Expect.equals(96, array.length); | 1746 Expect.equals(96, array.length); |
| 3571 Expect.equals(1, array.elementSizeInBytes); | 1747 Expect.equals(1, array.elementSizeInBytes); |
| 3572 Expect.equals(96, array.lengthInBytes); | 1748 Expect.equals(96, array.lengthInBytes); |
| 3573 for (int i = 0; i < array.length; ++i) { | 1749 for (int i = 0; i < array.length; ++i) { |
| 3574 array[i] = -1; | 1750 array[i] = -1; |
| 3575 } | 1751 } |
| 3576 Expect.throws(() { | 1752 Expect.throws(() { new Uint64List.view(array.buffer, -1); }, |
| 3577 new Uint64List.view(array.buffer, -1); | 1753 (e) { return e is RangeError; }); |
| 3578 }, (e) { | 1754 Expect.throws(() { new Uint64List.view(array.buffer, 0, -1); }, |
| 3579 return e is RangeError; | 1755 (e) { return e is RangeError; }); |
| 3580 }); | 1756 Expect.throws(() { new Uint64List.view(array.buffer, |
| 3581 Expect.throws(() { | 1757 array.lengthInBytes + 1); }, |
| 3582 new Uint64List.view(array.buffer, 0, -1); | 1758 (e) { return e is RangeError; }); |
| 3583 }, (e) { | 1759 Expect.throws(() { new Uint64List.view(array.buffer, |
| 3584 return e is RangeError; | 1760 0, array.length + 1); }, |
| 3585 }); | 1761 (e) { return e is RangeError; }); |
| 3586 Expect.throws(() { | 1762 Expect.throws(() { new Uint64List.view(array.buffer, |
| 3587 new Uint64List.view(array.buffer, array.lengthInBytes + 1); | 1763 array.length - 1, 2); }, |
| 3588 }, (e) { | 1764 (e) { return e is RangeError; }); |
| 3589 return e is RangeError; | 1765 var empty = new Uint64List.view(array.buffer, |
| 3590 }); | 1766 array.lengthInBytes); |
| 3591 Expect.throws(() { | |
| 3592 new Uint64List.view(array.buffer, 0, array.length + 1); | |
| 3593 }, (e) { | |
| 3594 return e is RangeError; | |
| 3595 }); | |
| 3596 Expect.throws(() { | |
| 3597 new Uint64List.view(array.buffer, array.length - 1, 2); | |
| 3598 }, (e) { | |
| 3599 return e is RangeError; | |
| 3600 }); | |
| 3601 var empty = new Uint64List.view(array.buffer, array.lengthInBytes); | |
| 3602 Expect.isTrue(empty is List<int>); | 1767 Expect.isTrue(empty is List<int>); |
| 3603 Expect.isTrue(empty is Uint64List); | 1768 Expect.isTrue(empty is Uint64List); |
| 3604 Expect.equals(0, empty.length); | 1769 Expect.equals(0, empty.length); |
| 3605 var whole = new Uint64List.view(array.buffer); | 1770 var whole = new Uint64List.view(array.buffer); |
| 3606 Expect.isTrue(whole is List<int>); | 1771 Expect.isTrue(whole is List<int>); |
| 3607 Expect.isTrue(whole is Uint64List); | 1772 Expect.isTrue(whole is Uint64List); |
| 3608 Expect.equals(12, whole.length); | 1773 Expect.equals(12, whole.length); |
| 3609 var view = new Uint64List.view(array.buffer, 8, 10); | 1774 var view = new Uint64List.view(array.buffer, 8, 10); |
| 3610 Expect.isTrue(view is List<int>); | 1775 Expect.isTrue(view is List<int>); |
| 3611 Expect.isTrue(view is Uint64List); | 1776 Expect.isTrue(view is Uint64List); |
| 3612 Expect.equals(10, view.length); | 1777 Expect.equals(10, view.length); |
| 3613 Expect.equals(8, view.elementSizeInBytes); | 1778 Expect.equals(8, view.elementSizeInBytes); |
| 3614 Expect.equals(80, view.lengthInBytes); | 1779 Expect.equals(80, view.lengthInBytes); |
| 3615 Expect.listEquals([ | 1780 Expect.listEquals([0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, |
| 3616 0xFFFFFFFFFFFFFFFF, | 1781 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, |
| 3617 0xFFFFFFFFFFFFFFFF, | 1782 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, |
| 3618 0xFFFFFFFFFFFFFFFF, | 1783 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, |
| 3619 0xFFFFFFFFFFFFFFFF, | 1784 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF], |
| 3620 0xFFFFFFFFFFFFFFFF, | 1785 view); |
| 3621 0xFFFFFFFFFFFFFFFF, | 1786 Expect.throws(() { view[-1] = 0; }, |
| 3622 0xFFFFFFFFFFFFFFFF, | 1787 (e) { return e is RangeError; }); |
| 3623 0xFFFFFFFFFFFFFFFF, | 1788 Expect.throws(() { return view[-1]; }, |
| 3624 0xFFFFFFFFFFFFFFFF, | 1789 (e) { return e is RangeError; }); |
| 3625 0xFFFFFFFFFFFFFFFF | 1790 Expect.throws(() { view[view.length]; }, |
| 3626 ], view); | 1791 (e) { return e is RangeError; }); |
| 3627 Expect.throws(() { | 1792 Expect.throws(() { view[view.length] = 0; }, |
| 3628 view[-1] = 0; | 1793 (e) { return e is RangeError; }); |
| 3629 }, (e) { | 1794 Expect.throws(() { view.add(0); }, |
| 3630 return e is RangeError; | 1795 (e) { return e is UnsupportedError; }); |
| 3631 }); | 1796 Expect.throws(() { view.addAll([0]); }, |
| 3632 Expect.throws(() { | 1797 (e) { return e is UnsupportedError; }); |
| 3633 return view[-1]; | 1798 Expect.throws(() { view.clear(); }, |
| 3634 }, (e) { | 1799 (e) { return e is UnsupportedError; }); |
| 3635 return e is RangeError; | 1800 Expect.throws(() { view.length = 0; }, |
| 3636 }); | 1801 (e) { return e is UnsupportedError; }); |
| 3637 Expect.throws(() { | 1802 Expect.throws(() { view.removeLast(); }, |
| 3638 view[view.length]; | 1803 (e) { return e is UnsupportedError; }); |
| 3639 }, (e) { | 1804 Expect.throws(() { view.removeRange(0, view.length - 1); }, |
| 3640 return e is RangeError; | 1805 (e) { return e is UnsupportedError; }); |
| 3641 }); | |
| 3642 Expect.throws(() { | |
| 3643 view[view.length] = 0; | |
| 3644 }, (e) { | |
| 3645 return e is RangeError; | |
| 3646 }); | |
| 3647 Expect.throws(() { | |
| 3648 view.add(0); | |
| 3649 }, (e) { | |
| 3650 return e is UnsupportedError; | |
| 3651 }); | |
| 3652 Expect.throws(() { | |
| 3653 view.addAll([0]); | |
| 3654 }, (e) { | |
| 3655 return e is UnsupportedError; | |
| 3656 }); | |
| 3657 Expect.throws(() { | |
| 3658 view.clear(); | |
| 3659 }, (e) { | |
| 3660 return e is UnsupportedError; | |
| 3661 }); | |
| 3662 Expect.throws(() { | |
| 3663 view.length = 0; | |
| 3664 }, (e) { | |
| 3665 return e is UnsupportedError; | |
| 3666 }); | |
| 3667 Expect.throws(() { | |
| 3668 view.removeLast(); | |
| 3669 }, (e) { | |
| 3670 return e is UnsupportedError; | |
| 3671 }); | |
| 3672 Expect.throws(() { | |
| 3673 view.removeRange(0, view.length - 1); | |
| 3674 }, (e) { | |
| 3675 return e is UnsupportedError; | |
| 3676 }); | |
| 3677 for (int i = 0; i < view.length; ++i) { | 1806 for (int i = 0; i < view.length; ++i) { |
| 3678 view[i] = 1 + i; | 1807 view[i] = 1 + i; |
| 3679 } | 1808 } |
| 3680 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); | 1809 Expect.listEquals([1, 2, 3, 4, 5, |
| 3681 Expect.listEquals([ | 1810 6, 7, 8, 9, 10], |
| 3682 -1, | 1811 view); |
| 3683 -1, | 1812 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, |
| 3684 -1, | 1813 1, 0, 0, 0, 0, 0, 0, 0, |
| 3685 -1, | 1814 2, 0, 0, 0, 0, 0, 0, 0, |
| 3686 -1, | 1815 3, 0, 0, 0, 0, 0, 0, 0, |
| 3687 -1, | 1816 4, 0, 0, 0, 0, 0, 0, 0, |
| 3688 -1, | 1817 5, 0, 0, 0, 0, 0, 0, 0, |
| 3689 -1, | 1818 6, 0, 0, 0, 0, 0, 0, 0, |
| 3690 1, | 1819 7, 0, 0, 0, 0, 0, 0, 0, |
| 3691 0, | 1820 8, 0, 0, 0, 0, 0, 0, 0, |
| 3692 0, | 1821 9, 0, 0, 0, 0, 0, 0, 0, |
| 3693 0, | 1822 10, 0, 0, 0, 0, 0, 0, 0, |
| 3694 0, | 1823 -1, -1, -1, -1, -1, -1, -1, -1], |
| 3695 0, | 1824 array); |
| 3696 0, | |
| 3697 0, | |
| 3698 2, | |
| 3699 0, | |
| 3700 0, | |
| 3701 0, | |
| 3702 0, | |
| 3703 0, | |
| 3704 0, | |
| 3705 0, | |
| 3706 3, | |
| 3707 0, | |
| 3708 0, | |
| 3709 0, | |
| 3710 0, | |
| 3711 0, | |
| 3712 0, | |
| 3713 0, | |
| 3714 4, | |
| 3715 0, | |
| 3716 0, | |
| 3717 0, | |
| 3718 0, | |
| 3719 0, | |
| 3720 0, | |
| 3721 0, | |
| 3722 5, | |
| 3723 0, | |
| 3724 0, | |
| 3725 0, | |
| 3726 0, | |
| 3727 0, | |
| 3728 0, | |
| 3729 0, | |
| 3730 6, | |
| 3731 0, | |
| 3732 0, | |
| 3733 0, | |
| 3734 0, | |
| 3735 0, | |
| 3736 0, | |
| 3737 0, | |
| 3738 7, | |
| 3739 0, | |
| 3740 0, | |
| 3741 0, | |
| 3742 0, | |
| 3743 0, | |
| 3744 0, | |
| 3745 0, | |
| 3746 8, | |
| 3747 0, | |
| 3748 0, | |
| 3749 0, | |
| 3750 0, | |
| 3751 0, | |
| 3752 0, | |
| 3753 0, | |
| 3754 9, | |
| 3755 0, | |
| 3756 0, | |
| 3757 0, | |
| 3758 0, | |
| 3759 0, | |
| 3760 0, | |
| 3761 0, | |
| 3762 10, | |
| 3763 0, | |
| 3764 0, | |
| 3765 0, | |
| 3766 0, | |
| 3767 0, | |
| 3768 0, | |
| 3769 0, | |
| 3770 -1, | |
| 3771 -1, | |
| 3772 -1, | |
| 3773 -1, | |
| 3774 -1, | |
| 3775 -1, | |
| 3776 -1, | |
| 3777 -1 | |
| 3778 ], array); | |
| 3779 for (int i = 0; i < view.length; ++i) { | 1825 for (int i = 0; i < view.length; ++i) { |
| 3780 view[i] = 0x10000000000000000 + i; | 1826 view[i] = 0x10000000000000000 + i; |
| 3781 } | 1827 } |
| 3782 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); | 1828 Expect.listEquals([0, 1, 2, 3, 4, |
| 3783 Expect.listEquals([ | 1829 5, 6, 7, 8, 9], |
| 3784 -1, | 1830 view); |
| 3785 -1, | 1831 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, |
| 3786 -1, | 1832 0, 0, 0, 0, 0, 0, 0, 0, |
| 3787 -1, | 1833 1, 0, 0, 0, 0, 0, 0, 0, |
| 3788 -1, | 1834 2, 0, 0, 0, 0, 0, 0, 0, |
| 3789 -1, | 1835 3, 0, 0, 0, 0, 0, 0, 0, |
| 3790 -1, | 1836 4, 0, 0, 0, 0, 0, 0, 0, |
| 3791 -1, | 1837 5, 0, 0, 0, 0, 0, 0, 0, |
| 3792 0, | 1838 6, 0, 0, 0, 0, 0, 0, 0, |
| 3793 0, | 1839 7, 0, 0, 0, 0, 0, 0, 0, |
| 3794 0, | 1840 8, 0, 0, 0, 0, 0, 0, 0, |
| 3795 0, | 1841 9, 0, 0, 0, 0, 0, 0, 0, |
| 3796 0, | 1842 -1, -1, -1, -1, -1, -1, -1, -1], |
| 3797 0, | 1843 array); |
| 3798 0, | |
| 3799 0, | |
| 3800 1, | |
| 3801 0, | |
| 3802 0, | |
| 3803 0, | |
| 3804 0, | |
| 3805 0, | |
| 3806 0, | |
| 3807 0, | |
| 3808 2, | |
| 3809 0, | |
| 3810 0, | |
| 3811 0, | |
| 3812 0, | |
| 3813 0, | |
| 3814 0, | |
| 3815 0, | |
| 3816 3, | |
| 3817 0, | |
| 3818 0, | |
| 3819 0, | |
| 3820 0, | |
| 3821 0, | |
| 3822 0, | |
| 3823 0, | |
| 3824 4, | |
| 3825 0, | |
| 3826 0, | |
| 3827 0, | |
| 3828 0, | |
| 3829 0, | |
| 3830 0, | |
| 3831 0, | |
| 3832 5, | |
| 3833 0, | |
| 3834 0, | |
| 3835 0, | |
| 3836 0, | |
| 3837 0, | |
| 3838 0, | |
| 3839 0, | |
| 3840 6, | |
| 3841 0, | |
| 3842 0, | |
| 3843 0, | |
| 3844 0, | |
| 3845 0, | |
| 3846 0, | |
| 3847 0, | |
| 3848 7, | |
| 3849 0, | |
| 3850 0, | |
| 3851 0, | |
| 3852 0, | |
| 3853 0, | |
| 3854 0, | |
| 3855 0, | |
| 3856 8, | |
| 3857 0, | |
| 3858 0, | |
| 3859 0, | |
| 3860 0, | |
| 3861 0, | |
| 3862 0, | |
| 3863 0, | |
| 3864 9, | |
| 3865 0, | |
| 3866 0, | |
| 3867 0, | |
| 3868 0, | |
| 3869 0, | |
| 3870 0, | |
| 3871 0, | |
| 3872 -1, | |
| 3873 -1, | |
| 3874 -1, | |
| 3875 -1, | |
| 3876 -1, | |
| 3877 -1, | |
| 3878 -1, | |
| 3879 -1 | |
| 3880 ], array); | |
| 3881 for (int i = 0; i < view.length; ++i) { | 1844 for (int i = 0; i < view.length; ++i) { |
| 3882 view[i] = 0xFFFFFFFFFFFFFFFF - i; | 1845 view[i] = 0xFFFFFFFFFFFFFFFF - i; |
| 3883 } | 1846 } |
| 3884 Expect.listEquals([ | 1847 Expect.listEquals([0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFE, |
| 3885 0xFFFFFFFFFFFFFFFF, | 1848 0xFFFFFFFFFFFFFFFD, 0xFFFFFFFFFFFFFFFC, |
| 3886 0xFFFFFFFFFFFFFFFE, | 1849 0xFFFFFFFFFFFFFFFB, 0xFFFFFFFFFFFFFFFA, |
| 3887 0xFFFFFFFFFFFFFFFD, | 1850 0xFFFFFFFFFFFFFFF9, 0xFFFFFFFFFFFFFFF8, |
| 3888 0xFFFFFFFFFFFFFFFC, | 1851 0xFFFFFFFFFFFFFFF7, 0xFFFFFFFFFFFFFFF6], |
| 3889 0xFFFFFFFFFFFFFFFB, | 1852 view); |
| 3890 0xFFFFFFFFFFFFFFFA, | 1853 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, |
| 3891 0xFFFFFFFFFFFFFFF9, | 1854 -1, -1, -1, -1, -1, -1, -1, -1, |
| 3892 0xFFFFFFFFFFFFFFF8, | 1855 -2, -1, -1, -1, -1, -1, -1, -1, |
| 3893 0xFFFFFFFFFFFFFFF7, | 1856 -3, -1, -1, -1, -1, -1, -1, -1, |
| 3894 0xFFFFFFFFFFFFFFF6 | 1857 -4, -1, -1, -1, -1, -1, -1, -1, |
| 3895 ], view); | 1858 -5, -1, -1, -1, -1, -1, -1, -1, |
| 3896 Expect.listEquals([ | 1859 -6, -1, -1, -1, -1, -1, -1, -1, |
| 3897 -1, | 1860 -7, -1, -1, -1, -1, -1, -1, -1, |
| 3898 -1, | 1861 -8, -1, -1, -1, -1, -1, -1, -1, |
| 3899 -1, | 1862 -9, -1, -1, -1, -1, -1, -1, -1, |
| 3900 -1, | 1863 -10, -1, -1, -1, -1, -1, -1, -1, |
| 3901 -1, | 1864 -1, -1, -1, -1, -1, -1, -1, -1], |
| 3902 -1, | 1865 array); |
| 3903 -1, | |
| 3904 -1, | |
| 3905 -1, | |
| 3906 -1, | |
| 3907 -1, | |
| 3908 -1, | |
| 3909 -1, | |
| 3910 -1, | |
| 3911 -1, | |
| 3912 -1, | |
| 3913 -2, | |
| 3914 -1, | |
| 3915 -1, | |
| 3916 -1, | |
| 3917 -1, | |
| 3918 -1, | |
| 3919 -1, | |
| 3920 -1, | |
| 3921 -3, | |
| 3922 -1, | |
| 3923 -1, | |
| 3924 -1, | |
| 3925 -1, | |
| 3926 -1, | |
| 3927 -1, | |
| 3928 -1, | |
| 3929 -4, | |
| 3930 -1, | |
| 3931 -1, | |
| 3932 -1, | |
| 3933 -1, | |
| 3934 -1, | |
| 3935 -1, | |
| 3936 -1, | |
| 3937 -5, | |
| 3938 -1, | |
| 3939 -1, | |
| 3940 -1, | |
| 3941 -1, | |
| 3942 -1, | |
| 3943 -1, | |
| 3944 -1, | |
| 3945 -6, | |
| 3946 -1, | |
| 3947 -1, | |
| 3948 -1, | |
| 3949 -1, | |
| 3950 -1, | |
| 3951 -1, | |
| 3952 -1, | |
| 3953 -7, | |
| 3954 -1, | |
| 3955 -1, | |
| 3956 -1, | |
| 3957 -1, | |
| 3958 -1, | |
| 3959 -1, | |
| 3960 -1, | |
| 3961 -8, | |
| 3962 -1, | |
| 3963 -1, | |
| 3964 -1, | |
| 3965 -1, | |
| 3966 -1, | |
| 3967 -1, | |
| 3968 -1, | |
| 3969 -9, | |
| 3970 -1, | |
| 3971 -1, | |
| 3972 -1, | |
| 3973 -1, | |
| 3974 -1, | |
| 3975 -1, | |
| 3976 -1, | |
| 3977 -10, | |
| 3978 -1, | |
| 3979 -1, | |
| 3980 -1, | |
| 3981 -1, | |
| 3982 -1, | |
| 3983 -1, | |
| 3984 -1, | |
| 3985 -1, | |
| 3986 -1, | |
| 3987 -1, | |
| 3988 -1, | |
| 3989 -1, | |
| 3990 -1, | |
| 3991 -1, | |
| 3992 -1 | |
| 3993 ], array); | |
| 3994 for (int i = 0; i < view.length; ++i) { | 1866 for (int i = 0; i < view.length; ++i) { |
| 3995 view[i] = i; | 1867 view[i] = i; |
| 3996 } | 1868 } |
| 3997 var copy = view.sublist(0, view.length); | 1869 var copy = view.sublist(0, view.length); |
| 3998 Expect.isFalse(identical(copy, view)); | 1870 Expect.isFalse(identical(copy, view)); |
| 3999 Expect.isTrue(copy is Uint64List); | 1871 Expect.isTrue(copy is Uint64List); |
| 4000 Expect.equals(10, copy.length); | 1872 Expect.equals(10, copy.length); |
| 4001 Expect.listEquals(view, copy); | 1873 Expect.listEquals(view, copy); |
| 4002 var region = view.sublist(3, view.length - 3); | 1874 var region = view.sublist(3, view.length - 3); |
| 4003 Expect.isTrue(copy is Uint64List); | 1875 Expect.isTrue(copy is Uint64List); |
| 4004 Expect.equals(4, region.length); | 1876 Expect.equals(4, region.length); |
| 4005 Expect.listEquals([3, 4, 5, 6], region); | 1877 Expect.listEquals([3, 4, 5, 6], region); |
| 4006 view.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); | 1878 view.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); |
| 4007 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], view); | 1879 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], |
| 4008 Expect.listEquals([ | 1880 view); |
| 4009 -1, | 1881 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, |
| 4010 -1, | 1882 0, 0, 0, 0, 0, 0, 0, 0, |
| 4011 -1, | 1883 1, 0, 0, 0, 0, 0, 0, 0, |
| 4012 -1, | 1884 2, 0, 0, 0, 0, 0, 0, 0, |
| 4013 -1, | 1885 1, 0, 0, 0, 0, 0, 0, 0, |
| 4014 -1, | 1886 0, 0, 0, 0, 0, 0, 0, 0, |
| 4015 -1, | 1887 1, 0, 0, 0, 0, 0, 0, 0, |
| 4016 -1, | 1888 -1, -1, -1, -1, -1, -1, -1, -1, |
| 4017 0, | 1889 7, 0, 0, 0, 0, 0, 0, 0, |
| 4018 0, | 1890 8, 0, 0, 0, 0, 0, 0, 0, |
| 4019 0, | 1891 9, 0, 0, 0, 0, 0, 0, 0, |
| 4020 0, | 1892 -1, -1, -1, -1, -1, -1, -1, -1], |
| 4021 0, | 1893 array); |
| 4022 0, | |
| 4023 0, | |
| 4024 0, | |
| 4025 1, | |
| 4026 0, | |
| 4027 0, | |
| 4028 0, | |
| 4029 0, | |
| 4030 0, | |
| 4031 0, | |
| 4032 0, | |
| 4033 2, | |
| 4034 0, | |
| 4035 0, | |
| 4036 0, | |
| 4037 0, | |
| 4038 0, | |
| 4039 0, | |
| 4040 0, | |
| 4041 1, | |
| 4042 0, | |
| 4043 0, | |
| 4044 0, | |
| 4045 0, | |
| 4046 0, | |
| 4047 0, | |
| 4048 0, | |
| 4049 0, | |
| 4050 0, | |
| 4051 0, | |
| 4052 0, | |
| 4053 0, | |
| 4054 0, | |
| 4055 0, | |
| 4056 0, | |
| 4057 1, | |
| 4058 0, | |
| 4059 0, | |
| 4060 0, | |
| 4061 0, | |
| 4062 0, | |
| 4063 0, | |
| 4064 0, | |
| 4065 -1, | |
| 4066 -1, | |
| 4067 -1, | |
| 4068 -1, | |
| 4069 -1, | |
| 4070 -1, | |
| 4071 -1, | |
| 4072 -1, | |
| 4073 7, | |
| 4074 0, | |
| 4075 0, | |
| 4076 0, | |
| 4077 0, | |
| 4078 0, | |
| 4079 0, | |
| 4080 0, | |
| 4081 8, | |
| 4082 0, | |
| 4083 0, | |
| 4084 0, | |
| 4085 0, | |
| 4086 0, | |
| 4087 0, | |
| 4088 0, | |
| 4089 9, | |
| 4090 0, | |
| 4091 0, | |
| 4092 0, | |
| 4093 0, | |
| 4094 0, | |
| 4095 0, | |
| 4096 0, | |
| 4097 -1, | |
| 4098 -1, | |
| 4099 -1, | |
| 4100 -1, | |
| 4101 -1, | |
| 4102 -1, | |
| 4103 -1, | |
| 4104 -1 | |
| 4105 ], array); | |
| 4106 } | 1894 } |
| 4107 | 1895 |
| 4108 static testUint64ListView() { | 1896 static testUint64ListView() { |
| 4109 var array = new Int8List(96); | 1897 var array = new Int8List(96); |
| 4110 testUint64ListViewImpl(array); | 1898 testUint64ListViewImpl(array); |
| 4111 } | 1899 } |
| 4112 | 1900 |
| 4113 static testFloat32ListViewImpl(var array) { | 1901 static testFloat32ListViewImpl(var array) { |
| 4114 Expect.isTrue(array is List<int>); | 1902 Expect.isTrue(array is List<int>); |
| 4115 Expect.equals(12, array.length); | 1903 Expect.equals(12, array.length); |
| 4116 Expect.equals(4, array.elementSizeInBytes); | 1904 Expect.equals(4, array.elementSizeInBytes); |
| 4117 Expect.equals(48, array.lengthInBytes); | 1905 Expect.equals(48, array.lengthInBytes); |
| 4118 for (int i = 0; i < array.length; ++i) { | 1906 for (int i = 0; i < array.length; ++i) { |
| 4119 array[i] = 0xBF800000; | 1907 array[i] = 0xBF800000; |
| 4120 } | 1908 } |
| 4121 Expect.throws(() { | 1909 Expect.throws(() { new Float32List.view(array.buffer, -1); }, |
| 4122 new Float32List.view(array.buffer, -1); | 1910 (e) { return e is RangeError; }); |
| 4123 }, (e) { | 1911 Expect.throws(() { new Float32List.view(array.buffer, 0, -1); }, |
| 4124 return e is RangeError; | 1912 (e) { return e is RangeError; }); |
| 4125 }); | 1913 Expect.throws(() { new Float32List.view(array.buffer, |
| 4126 Expect.throws(() { | 1914 array.lengthInBytes + 1); }, |
| 4127 new Float32List.view(array.buffer, 0, -1); | 1915 (e) { return e is RangeError; }); |
| 4128 }, (e) { | 1916 Expect.throws(() { new Float32List.view(array.buffer, |
| 4129 return e is RangeError; | 1917 0, array.lengthInBytes + 1); }, |
| 4130 }); | 1918 (e) { return e is RangeError; }); |
| 4131 Expect.throws(() { | 1919 Expect.throws(() { new Float32List.view(array.buffer, |
| 4132 new Float32List.view(array.buffer, array.lengthInBytes + 1); | 1920 array.lengthInBytes - 1, 2); }, |
| 4133 }, (e) { | 1921 (e) { return e is RangeError; }); |
| 4134 return e is RangeError; | 1922 var empty = new Float32List.view(array.buffer, |
| 4135 }); | 1923 array.lengthInBytes); |
| 4136 Expect.throws(() { | |
| 4137 new Float32List.view(array.buffer, 0, array.lengthInBytes + 1); | |
| 4138 }, (e) { | |
| 4139 return e is RangeError; | |
| 4140 }); | |
| 4141 Expect.throws(() { | |
| 4142 new Float32List.view(array.buffer, array.lengthInBytes - 1, 2); | |
| 4143 }, (e) { | |
| 4144 return e is RangeError; | |
| 4145 }); | |
| 4146 var empty = new Float32List.view(array.buffer, array.lengthInBytes); | |
| 4147 Expect.isTrue(empty is List<double>); | 1924 Expect.isTrue(empty is List<double>); |
| 4148 Expect.isTrue(empty is Float32List); | 1925 Expect.isTrue(empty is Float32List); |
| 4149 Expect.equals(0, empty.length); | 1926 Expect.equals(0, empty.length); |
| 4150 var whole = new Float32List.view(array.buffer); | 1927 var whole = new Float32List.view(array.buffer); |
| 4151 Expect.isTrue(whole is List<double>); | 1928 Expect.isTrue(whole is List<double>); |
| 4152 Expect.isTrue(whole is Float32List); | 1929 Expect.isTrue(whole is Float32List); |
| 4153 Expect.equals(12, whole.length); | 1930 Expect.equals(12, whole.length); |
| 4154 var view = new Float32List.view(array.buffer, 4, 10); | 1931 var view = new Float32List.view(array.buffer, 4, 10); |
| 4155 Expect.isTrue(view is List<double>); | 1932 Expect.isTrue(view is List<double>); |
| 4156 Expect.isTrue(view is Float32List); | 1933 Expect.isTrue(view is Float32List); |
| 4157 Expect.equals(10, view.length); | 1934 Expect.equals(10, view.length); |
| 4158 Expect.equals(4, view.elementSizeInBytes); | 1935 Expect.equals(4, view.elementSizeInBytes); |
| 4159 Expect.equals(40, view.lengthInBytes); | 1936 Expect.equals(40, view.lengthInBytes); |
| 4160 Expect.listEquals( | 1937 Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0, |
| 4161 [-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0], view); | 1938 -1.0, -1.0, -1.0, -1.0, -1.0], |
| 4162 Expect.throws(() { | 1939 view); |
| 4163 view[-1] = 0.0; | 1940 Expect.throws(() { view[-1] = 0.0; }, |
| 4164 }, (e) { | 1941 (e) { return e is RangeError; }); |
| 4165 return e is RangeError; | 1942 Expect.throws(() { return view[-1]; }, |
| 4166 }); | 1943 (e) { return e is RangeError; }); |
| 4167 Expect.throws(() { | 1944 Expect.throws(() { view[10]; }, |
| 4168 return view[-1]; | 1945 (e) { return e is RangeError; }); |
| 4169 }, (e) { | 1946 Expect.throws(() { view[10] = 0.0; }, |
| 4170 return e is RangeError; | 1947 (e) { return e is RangeError; }); |
| 4171 }); | 1948 Expect.throws(() { array.add(0.0); }, |
| 4172 Expect.throws(() { | 1949 (e) { return e is UnsupportedError; }); |
| 4173 view[10]; | 1950 Expect.throws(() { array.addAll([0]); }, |
| 4174 }, (e) { | 1951 (e) { return e is UnsupportedError; }); |
| 4175 return e is RangeError; | 1952 Expect.throws(() { array.clear(); }, |
| 4176 }); | 1953 (e) { return e is UnsupportedError; }); |
| 4177 Expect.throws(() { | 1954 Expect.throws(() { array.length = 0; }, |
| 4178 view[10] = 0.0; | 1955 (e) { return e is UnsupportedError; }); |
| 4179 }, (e) { | 1956 Expect.throws(() { array.removeLast(); }, |
| 4180 return e is RangeError; | 1957 (e) { return e is UnsupportedError; }); |
| 4181 }); | 1958 Expect.throws(() { array.removeRange(0, array.length - 1); }, |
| 4182 Expect.throws(() { | 1959 (e) { return e is UnsupportedError; }); |
| 4183 array.add(0.0); | |
| 4184 }, (e) { | |
| 4185 return e is UnsupportedError; | |
| 4186 }); | |
| 4187 Expect.throws(() { | |
| 4188 array.addAll([0]); | |
| 4189 }, (e) { | |
| 4190 return e is UnsupportedError; | |
| 4191 }); | |
| 4192 Expect.throws(() { | |
| 4193 array.clear(); | |
| 4194 }, (e) { | |
| 4195 return e is UnsupportedError; | |
| 4196 }); | |
| 4197 Expect.throws(() { | |
| 4198 array.length = 0; | |
| 4199 }, (e) { | |
| 4200 return e is UnsupportedError; | |
| 4201 }); | |
| 4202 Expect.throws(() { | |
| 4203 array.removeLast(); | |
| 4204 }, (e) { | |
| 4205 return e is UnsupportedError; | |
| 4206 }); | |
| 4207 Expect.throws(() { | |
| 4208 array.removeRange(0, array.length - 1); | |
| 4209 }, (e) { | |
| 4210 return e is UnsupportedError; | |
| 4211 }); | |
| 4212 for (int i = 0; i < view.length; ++i) { | 1960 for (int i = 0; i < view.length; ++i) { |
| 4213 view[i] = 1.0 + i; | 1961 view[i] = 1.0 + i; |
| 4214 } | 1962 } |
| 4215 Expect | 1963 Expect.listEquals([1.0, 2.0, 3.0, 4.0, 5.0, |
| 4216 .listEquals([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], view); | 1964 6.0, 7.0, 8.0, 9.0, 10.0], |
| 4217 Expect.listEquals([ | 1965 view); |
| 4218 0xBF800000, | 1966 Expect.listEquals([0xBF800000, 0x3F800000, |
| 4219 0x3F800000, | 1967 0x40000000, 0x40400000, |
| 4220 0x40000000, | 1968 0x40800000, 0x40A00000, |
| 4221 0x40400000, | 1969 0x40C00000, 0x40E00000, |
| 4222 0x40800000, | 1970 0x41000000, 0x41100000, |
| 4223 0x40A00000, | 1971 0x41200000, 0xBF800000], |
| 4224 0x40C00000, | 1972 array); |
| 4225 0x40E00000, | |
| 4226 0x41000000, | |
| 4227 0x41100000, | |
| 4228 0x41200000, | |
| 4229 0xBF800000 | |
| 4230 ], array); | |
| 4231 // TODO: min, max, and round | 1973 // TODO: min, max, and round |
| 4232 for (int i = 0; i < view.length; ++i) { | 1974 for (int i = 0; i < view.length; ++i) { |
| 4233 view[i] = i * 1.0; | 1975 view[i] = i * 1.0; |
| 4234 } | 1976 } |
| 4235 var copy = view.sublist(0, view.length); | 1977 var copy = view.sublist(0, view.length); |
| 4236 Expect.isFalse(identical(copy, view)); | 1978 Expect.isFalse(identical(copy, view)); |
| 4237 Expect.isTrue(copy is Float32List); | 1979 Expect.isTrue(copy is Float32List); |
| 4238 Expect.equals(10, copy.length); | 1980 Expect.equals(10, copy.length); |
| 4239 Expect.listEquals(view, copy); | 1981 Expect.listEquals(view, copy); |
| 4240 var region = view.sublist(3, view.length - 3); | 1982 var region = view.sublist(3, view.length - 3); |
| 4241 Expect.isTrue(copy is Float32List); | 1983 Expect.isTrue(copy is Float32List); |
| 4242 Expect.equals(4, region.length); | 1984 Expect.equals(4, region.length); |
| 4243 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 1985 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
| 4244 view.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 1986 view.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
| 4245 Expect.listEquals([ | 1987 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
| 4246 0.0, | 1988 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
| 4247 1.0, | 1989 view); |
| 4248 2.0, | 1990 Expect.listEquals([0xBF800000, 0x00000000, |
| 4249 double.NEGATIVE_INFINITY, | 1991 0x3F800000, 0x40000000, |
| 4250 0.0, | 1992 0xFF800000, 0x00000000, |
| 4251 1.0, | 1993 0x3F800000, 0x7F800000, |
| 4252 double.INFINITY, | 1994 0x40E00000, 0x41000000, |
| 4253 7.0, | 1995 0x41100000, 0xBF800000], |
| 4254 8.0, | 1996 array); |
| 4255 9.0 | |
| 4256 ], view); | |
| 4257 Expect.listEquals([ | |
| 4258 0xBF800000, | |
| 4259 0x00000000, | |
| 4260 0x3F800000, | |
| 4261 0x40000000, | |
| 4262 0xFF800000, | |
| 4263 0x00000000, | |
| 4264 0x3F800000, | |
| 4265 0x7F800000, | |
| 4266 0x40E00000, | |
| 4267 0x41000000, | |
| 4268 0x41100000, | |
| 4269 0xBF800000 | |
| 4270 ], array); | |
| 4271 } | 1997 } |
| 4272 | 1998 |
| 4273 static testFloat32ListView() { | 1999 static testFloat32ListView() { |
| 4274 var array = new Uint32List(12); | 2000 var array = new Uint32List(12); |
| 4275 testFloat32ListViewImpl(array); | 2001 testFloat32ListViewImpl(array); |
| 4276 } | 2002 } |
| 4277 | 2003 |
| 4278 static testFloat64ListViewImpl(var array) { | 2004 static testFloat64ListViewImpl(var array) { |
| 4279 Expect.isTrue(array is List<int>); | 2005 Expect.isTrue(array is List<int>); |
| 4280 Expect.equals(12, array.length); | 2006 Expect.equals(12, array.length); |
| 4281 Expect.equals(8, array.elementSizeInBytes); | 2007 Expect.equals(8, array.elementSizeInBytes); |
| 4282 Expect.equals(96, array.lengthInBytes); | 2008 Expect.equals(96, array.lengthInBytes); |
| 4283 for (int i = 0; i < array.length; ++i) { | 2009 for (int i = 0; i < array.length; ++i) { |
| 4284 array[i] = 0xBFF0000000000000; | 2010 array[i] = 0xBFF0000000000000; |
| 4285 } | 2011 } |
| 4286 Expect.throws(() { | 2012 Expect.throws(() { new Float64List.view(array.buffer, -1); }, |
| 4287 new Float64List.view(array.buffer, -1); | 2013 (e) { return e is RangeError; }); |
| 4288 }, (e) { | 2014 Expect.throws(() { new Float64List.view(array.buffer, 0, -1); }, |
| 4289 return e is RangeError; | 2015 (e) { return e is RangeError; }); |
| 4290 }); | 2016 Expect.throws(() { new Float64List.view(array.buffer, |
| 4291 Expect.throws(() { | 2017 array.lengthInBytes + 1); }, |
| 4292 new Float64List.view(array.buffer, 0, -1); | 2018 (e) { return e is RangeError; }); |
| 4293 }, (e) { | 2019 Expect.throws(() { new Float64List.view(array.buffer, |
| 4294 return e is RangeError; | 2020 0, array.lengthInBytes + 1); }, |
| 4295 }); | 2021 (e) { return e is RangeError; }); |
| 4296 Expect.throws(() { | 2022 Expect.throws(() { new Float64List.view(array.buffer, |
| 4297 new Float64List.view(array.buffer, array.lengthInBytes + 1); | 2023 array.lengthInBytes - 1, 2); }, |
| 4298 }, (e) { | 2024 (e) { return e is RangeError; }); |
| 4299 return e is RangeError; | 2025 var empty = new Float64List.view(array.buffer, |
| 4300 }); | 2026 array.lengthInBytes); |
| 4301 Expect.throws(() { | |
| 4302 new Float64List.view(array.buffer, 0, array.lengthInBytes + 1); | |
| 4303 }, (e) { | |
| 4304 return e is RangeError; | |
| 4305 }); | |
| 4306 Expect.throws(() { | |
| 4307 new Float64List.view(array.buffer, array.lengthInBytes - 1, 2); | |
| 4308 }, (e) { | |
| 4309 return e is RangeError; | |
| 4310 }); | |
| 4311 var empty = new Float64List.view(array.buffer, array.lengthInBytes); | |
| 4312 Expect.isTrue(empty is List<double>); | 2027 Expect.isTrue(empty is List<double>); |
| 4313 Expect.isTrue(empty is Float64List); | 2028 Expect.isTrue(empty is Float64List); |
| 4314 Expect.equals(0, empty.length); | 2029 Expect.equals(0, empty.length); |
| 4315 var whole = new Float64List.view(array.buffer); | 2030 var whole = new Float64List.view(array.buffer); |
| 4316 Expect.isTrue(whole is List<double>); | 2031 Expect.isTrue(whole is List<double>); |
| 4317 Expect.isTrue(whole is Float64List); | 2032 Expect.isTrue(whole is Float64List); |
| 4318 Expect.equals(12, whole.length); | 2033 Expect.equals(12, whole.length); |
| 4319 var view = new Float64List.view(array.buffer, 8, 10); | 2034 var view = new Float64List.view(array.buffer, 8, 10); |
| 4320 Expect.isTrue(view is List<double>); | 2035 Expect.isTrue(view is List<double>); |
| 4321 Expect.isTrue(view is Float64List); | 2036 Expect.isTrue(view is Float64List); |
| 4322 Expect.equals(10, view.length); | 2037 Expect.equals(10, view.length); |
| 4323 Expect.equals(8, view.elementSizeInBytes); | 2038 Expect.equals(8, view.elementSizeInBytes); |
| 4324 Expect.equals(80, view.lengthInBytes); | 2039 Expect.equals(80, view.lengthInBytes); |
| 4325 Expect.listEquals( | 2040 Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0, |
| 4326 [-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0], view); | 2041 -1.0, -1.0, -1.0, -1.0, -1.0], |
| 4327 Expect.throws(() { | 2042 view); |
| 4328 view[-1] = 0.0; | 2043 Expect.throws(() { view[-1] = 0.0; }, |
| 4329 }, (e) { | 2044 (e) { return e is RangeError; }); |
| 4330 return e is RangeError; | 2045 Expect.throws(() { return view[-1]; }, |
| 4331 }); | 2046 (e) { return e is RangeError; }); |
| 4332 Expect.throws(() { | 2047 Expect.throws(() { view[10]; }, |
| 4333 return view[-1]; | 2048 (e) { return e is RangeError; }); |
| 4334 }, (e) { | 2049 Expect.throws(() { view[10] = 0.0; }, |
| 4335 return e is RangeError; | 2050 (e) { return e is RangeError; }); |
| 4336 }); | 2051 Expect.throws(() { array.add(0.0); }, |
| 4337 Expect.throws(() { | 2052 (e) { return e is UnsupportedError; }); |
| 4338 view[10]; | 2053 Expect.throws(() { array.addAll([0]); }, |
| 4339 }, (e) { | 2054 (e) { return e is UnsupportedError; }); |
| 4340 return e is RangeError; | 2055 Expect.throws(() { array.clear(); }, |
| 4341 }); | 2056 (e) { return e is UnsupportedError; }); |
| 4342 Expect.throws(() { | 2057 Expect.throws(() { array.length = 0; }, |
| 4343 view[10] = 0.0; | 2058 (e) { return e is UnsupportedError; }); |
| 4344 }, (e) { | 2059 Expect.throws(() { array.removeLast(); }, |
| 4345 return e is RangeError; | 2060 (e) { return e is UnsupportedError; }); |
| 4346 }); | 2061 Expect.throws(() { array.removeRange(0, array.length - 1); }, |
| 4347 Expect.throws(() { | 2062 (e) { return e is UnsupportedError; }); |
| 4348 array.add(0.0); | |
| 4349 }, (e) { | |
| 4350 return e is UnsupportedError; | |
| 4351 }); | |
| 4352 Expect.throws(() { | |
| 4353 array.addAll([0]); | |
| 4354 }, (e) { | |
| 4355 return e is UnsupportedError; | |
| 4356 }); | |
| 4357 Expect.throws(() { | |
| 4358 array.clear(); | |
| 4359 }, (e) { | |
| 4360 return e is UnsupportedError; | |
| 4361 }); | |
| 4362 Expect.throws(() { | |
| 4363 array.length = 0; | |
| 4364 }, (e) { | |
| 4365 return e is UnsupportedError; | |
| 4366 }); | |
| 4367 Expect.throws(() { | |
| 4368 array.removeLast(); | |
| 4369 }, (e) { | |
| 4370 return e is UnsupportedError; | |
| 4371 }); | |
| 4372 Expect.throws(() { | |
| 4373 array.removeRange(0, array.length - 1); | |
| 4374 }, (e) { | |
| 4375 return e is UnsupportedError; | |
| 4376 }); | |
| 4377 for (int i = 0; i < view.length; ++i) { | 2063 for (int i = 0; i < view.length; ++i) { |
| 4378 view[i] = 1.0 + i; | 2064 view[i] = 1.0 + i; |
| 4379 } | 2065 } |
| 4380 Expect | 2066 Expect.listEquals([1.0, 2.0, 3.0, 4.0, 5.0, |
| 4381 .listEquals([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], view); | 2067 6.0, 7.0, 8.0, 9.0, 10.0], |
| 4382 Expect.listEquals([ | 2068 view); |
| 4383 0xBFF0000000000000, | 2069 Expect.listEquals([0xBFF0000000000000, 0x3FF0000000000000, |
| 4384 0x3FF0000000000000, | 2070 0x4000000000000000, 0x4008000000000000, |
| 4385 0x4000000000000000, | 2071 0x4010000000000000, 0x4014000000000000, |
| 4386 0x4008000000000000, | 2072 0x4018000000000000, 0x401C000000000000, |
| 4387 0x4010000000000000, | 2073 0x4020000000000000, 0x4022000000000000, |
| 4388 0x4014000000000000, | 2074 0x4024000000000000, 0xBFF0000000000000], |
| 4389 0x4018000000000000, | 2075 array); |
| 4390 0x401C000000000000, | |
| 4391 0x4020000000000000, | |
| 4392 0x4022000000000000, | |
| 4393 0x4024000000000000, | |
| 4394 0xBFF0000000000000 | |
| 4395 ], array); | |
| 4396 // TODO: min, max | 2076 // TODO: min, max |
| 4397 for (int i = 0; i < view.length; ++i) { | 2077 for (int i = 0; i < view.length; ++i) { |
| 4398 view[i] = i * 1.0; | 2078 view[i] = i * 1.0; |
| 4399 } | 2079 } |
| 4400 var copy = view.sublist(0, view.length); | 2080 var copy = view.sublist(0, view.length); |
| 4401 Expect.isFalse(identical(copy, view)); | 2081 Expect.isFalse(identical(copy, view)); |
| 4402 Expect.isTrue(copy is Float64List); | 2082 Expect.isTrue(copy is Float64List); |
| 4403 Expect.equals(10, copy.length); | 2083 Expect.equals(10, copy.length); |
| 4404 Expect.listEquals(view, copy); | 2084 Expect.listEquals(view, copy); |
| 4405 var region = view.sublist(3, view.length - 3); | 2085 var region = view.sublist(3, view.length - 3); |
| 4406 Expect.isTrue(copy is Float64List); | 2086 Expect.isTrue(copy is Float64List); |
| 4407 Expect.equals(4, region.length); | 2087 Expect.equals(4, region.length); |
| 4408 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 2088 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
| 4409 view.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 2089 view.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
| 4410 Expect.listEquals([ | 2090 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, |
| 4411 0.0, | 2091 1.0, double.INFINITY, 7.0, 8.0, 9.0], |
| 4412 1.0, | 2092 view); |
| 4413 2.0, | 2093 Expect.listEquals([0xBFF0000000000000, 0x0000000000000000, |
| 4414 double.NEGATIVE_INFINITY, | 2094 0x3FF0000000000000, 0x4000000000000000, |
| 4415 0.0, | 2095 0xFFF0000000000000, 0x0000000000000000, |
| 4416 1.0, | 2096 0x3FF0000000000000, 0x7FF0000000000000, |
| 4417 double.INFINITY, | 2097 0x401C000000000000, 0x4020000000000000, |
| 4418 7.0, | 2098 0x4022000000000000, 0xBFF0000000000000], |
| 4419 8.0, | 2099 array); |
| 4420 9.0 | |
| 4421 ], view); | |
| 4422 Expect.listEquals([ | |
| 4423 0xBFF0000000000000, | |
| 4424 0x0000000000000000, | |
| 4425 0x3FF0000000000000, | |
| 4426 0x4000000000000000, | |
| 4427 0xFFF0000000000000, | |
| 4428 0x0000000000000000, | |
| 4429 0x3FF0000000000000, | |
| 4430 0x7FF0000000000000, | |
| 4431 0x401C000000000000, | |
| 4432 0x4020000000000000, | |
| 4433 0x4022000000000000, | |
| 4434 0xBFF0000000000000 | |
| 4435 ], array); | |
| 4436 } | 2100 } |
| 4437 | 2101 |
| 4438 static testFloat64ListView() { | 2102 static testFloat64ListView() { |
| 4439 var array = new Uint64List(12); | 2103 var array = new Uint64List(12); |
| 4440 testFloat64ListViewImpl(array); | 2104 testFloat64ListViewImpl(array); |
| 4441 } | 2105 } |
| 4442 | 2106 |
| 4443 static testMain() { | 2107 static testMain() { |
| 4444 testInt8List(); | 2108 testInt8List(); |
| 4445 testUint8List(); | 2109 testUint8List(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4459 testInt32ListView(); | 2123 testInt32ListView(); |
| 4460 testUint32ListView(); | 2124 testUint32ListView(); |
| 4461 testInt64ListView(); | 2125 testInt64ListView(); |
| 4462 testUint64ListView(); | 2126 testUint64ListView(); |
| 4463 testFloat32ListView(); | 2127 testFloat32ListView(); |
| 4464 testFloat64ListView(); | 2128 testFloat64ListView(); |
| 4465 } | 2129 } |
| 4466 } | 2130 } |
| 4467 | 2131 |
| 4468 main() { | 2132 main() { |
| 4469 for (var i = 0; i < 20; i++) { | 2133 for (var i=0; i<20; i++) { |
| 4470 OptimizedByteArrayTest.testMain(); | 2134 OptimizedByteArrayTest.testMain(); |
| 4471 } | 2135 } |
| 4472 } | 2136 } |
| OLD | NEW |