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, | 20 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); |
21 0, 0, 0, 0, 0], | 21 Expect.throws(() { |
22 array); | 22 array[-1] = 0; |
23 Expect.throws(() { array[-1] = 0; }, | 23 }, (e) { |
24 (e) { return e is RangeError; }); | 24 return e is RangeError; |
25 Expect.throws(() { return array[-1]; }, | 25 }); |
26 (e) { return e is RangeError; }); | 26 Expect.throws(() { |
27 Expect.throws(() { array[10]; }, | 27 return array[-1]; |
28 (e) { return e is RangeError; }); | 28 }, (e) { |
29 Expect.throws(() { array[10] = 0; }, | 29 return e is RangeError; |
30 (e) { return e is RangeError; }); | 30 }); |
31 Expect.throws(() { array.add(0); }, | 31 Expect.throws(() { |
32 (e) { return e is UnsupportedError; }); | 32 array[10]; |
33 Expect.throws(() { array.addAll([0]); }, | 33 }, (e) { |
34 (e) { return e is UnsupportedError; }); | 34 return e is RangeError; |
35 Expect.throws(() { array.clear(); }, | 35 }); |
36 (e) { return e is UnsupportedError; }); | 36 Expect.throws(() { |
37 Expect.throws(() { array.length = 0; }, | 37 array[10] = 0; |
38 (e) { return e is UnsupportedError; }); | 38 }, (e) { |
39 Expect.throws(() { array.removeLast(); }, | 39 return e is RangeError; |
40 (e) { return e is UnsupportedError; }); | 40 }); |
41 Expect.throws(() { array.removeRange(0, array.length - 1); }, | 41 Expect.throws(() { |
42 (e) { return e is UnsupportedError; }); | 42 array.add(0); |
| 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 }); |
43 for (int i = 0; i < array.length; ++i) { | 71 for (int i = 0; i < array.length; ++i) { |
44 array[i] = 1 + i; | 72 array[i] = 1 + i; |
45 } | 73 } |
46 Expect.listEquals([1, 2, 3, 4, 5, | 74 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); |
47 6, 7, 8, 9, 10], | |
48 array); | |
49 for (int i = 0; i < array.length; ++i) { | 75 for (int i = 0; i < array.length; ++i) { |
50 array[i] = 0x100 + i; | 76 array[i] = 0x100 + i; |
51 } | 77 } |
52 Expect.listEquals([0, 1, 2, 3, 4, | 78 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); |
53 5, 6, 7, 8, 9], | |
54 array); | |
55 for (int i = 0; i < array.length; ++i) { | 79 for (int i = 0; i < array.length; ++i) { |
56 array[i] = -10 + i; | 80 array[i] = -10 + i; |
57 } | 81 } |
58 Expect.listEquals([-10, -9, -8, -7, -6, | 82 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], array); |
59 -5, -4, -3, -2, -1], | |
60 array); | |
61 for (int i = 0; i < array.length; ++i) { | 83 for (int i = 0; i < array.length; ++i) { |
62 array[i] = 0x7F - i; | 84 array[i] = 0x7F - i; |
63 } | 85 } |
64 Expect.listEquals([127, 126, 125, 124, 123, | 86 Expect |
65 122, 121, 120, 119, 118], | 87 .listEquals([127, 126, 125, 124, 123, 122, 121, 120, 119, 118], array); |
66 array); | |
67 for (int i = 0; i < array.length; ++i) { | 88 for (int i = 0; i < array.length; ++i) { |
68 array[i] = -0x80 + i; | 89 array[i] = -0x80 + i; |
69 } | 90 } |
70 Expect.listEquals([-128, -127, -126, -125, -124, | 91 Expect.listEquals( |
71 -123, -122, -121, -120, -119], | 92 [-128, -127, -126, -125, -124, -123, -122, -121, -120, -119], array); |
72 array); | |
73 for (int i = 0; i < array.length; ++i) { | 93 for (int i = 0; i < array.length; ++i) { |
74 array[i] = i; | 94 array[i] = i; |
75 } | 95 } |
76 var copy = array.sublist(0, array.length); | 96 var copy = array.sublist(0, array.length); |
77 Expect.isFalse(identical(copy, array)); | 97 Expect.isFalse(identical(copy, array)); |
78 Expect.isTrue(copy is Int8List); | 98 Expect.isTrue(copy is Int8List); |
79 Expect.equals(10, copy.length); | 99 Expect.equals(10, copy.length); |
80 Expect.listEquals(array, copy); | 100 Expect.listEquals(array, copy); |
81 var empty = array.sublist(array.length, array.length); | 101 var empty = array.sublist(array.length, array.length); |
82 Expect.equals(0, empty.length); | 102 Expect.equals(0, empty.length); |
83 var region = array.sublist(3, array.length - 3); | 103 var region = array.sublist(3, array.length - 3); |
84 Expect.isTrue(copy is Int8List); | 104 Expect.isTrue(copy is Int8List); |
85 Expect.equals(4, region.length); | 105 Expect.equals(4, region.length); |
86 Expect.listEquals([3, 4, 5, 6], region); | 106 Expect.listEquals([3, 4, 5, 6], region); |
87 array.setRange(3, 7, [-128, 0, 1, 127]); | 107 array.setRange(3, 7, [-128, 0, 1, 127]); |
88 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], | 108 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], array); |
89 array); | |
90 } | 109 } |
| 110 |
91 static testInt8List() { | 111 static testInt8List() { |
92 Expect.throws(() { new Int8List(-1); }, | 112 Expect.throws(() { |
93 (e) { return e is ArgumentError; }); | 113 new Int8List(-1); |
| 114 }, (e) { |
| 115 return e is ArgumentError; |
| 116 }); |
94 var array = new Int8List(10); | 117 var array = new Int8List(10); |
95 testInt8ListImpl(array); | 118 testInt8ListImpl(array); |
96 } | 119 } |
97 | 120 |
98 static testUint8ListImpl(Uint8List array) { | 121 static testUint8ListImpl(Uint8List array) { |
99 Expect.isTrue(array is List<int>); | 122 Expect.isTrue(array is List<int>); |
100 Expect.equals(10, array.length); | 123 Expect.equals(10, array.length); |
101 Expect.equals(1, array.elementSizeInBytes); | 124 Expect.equals(1, array.elementSizeInBytes); |
102 Expect.equals(10, array.lengthInBytes); | 125 Expect.equals(10, array.lengthInBytes); |
103 Expect.listEquals([0, 0, 0, 0, 0, | 126 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); |
104 0, 0, 0, 0, 0], | 127 Expect.throws(() { |
105 array); | 128 array[-1] = 0; |
106 Expect.throws(() { array[-1] = 0; }, | 129 }, (e) { |
107 (e) { return e is RangeError; }); | 130 return e is RangeError; |
108 Expect.throws(() { return array[-1]; }, | 131 }); |
109 (e) { return e is RangeError; }); | 132 Expect.throws(() { |
110 Expect.throws(() { array[10]; }, | 133 return array[-1]; |
111 (e) { return e is RangeError; }); | 134 }, (e) { |
112 Expect.throws(() { array[10] = 0; }, | 135 return e is RangeError; |
113 (e) { return e is RangeError; }); | 136 }); |
114 Expect.throws(() { array.add(0); }, | 137 Expect.throws(() { |
115 (e) { return e is UnsupportedError; }); | 138 array[10]; |
116 Expect.throws(() { array.addAll([0]); }, | 139 }, (e) { |
117 (e) { return e is UnsupportedError; }); | 140 return e is RangeError; |
118 Expect.throws(() { array.clear(); }, | 141 }); |
119 (e) { return e is UnsupportedError; }); | 142 Expect.throws(() { |
120 Expect.throws(() { array.length = 0; }, | 143 array[10] = 0; |
121 (e) { return e is UnsupportedError; }); | 144 }, (e) { |
122 Expect.throws(() { array.removeLast(); }, | 145 return e is RangeError; |
123 (e) { return e is UnsupportedError; }); | 146 }); |
124 Expect.throws(() { array.removeRange(0, array.length - 1); }, | 147 Expect.throws(() { |
125 (e) { return e is UnsupportedError; }); | 148 array.add(0); |
| 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 }); |
126 for (int i = 0; i < array.length; ++i) { | 177 for (int i = 0; i < array.length; ++i) { |
127 array[i] = 1 + i; | 178 array[i] = 1 + i; |
128 } | 179 } |
129 Expect.listEquals([1, 2, 3, 4, 5, | 180 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); |
130 6, 7, 8, 9, 10], | |
131 array); | |
132 for (int i = 0; i < array.length; ++i) { | 181 for (int i = 0; i < array.length; ++i) { |
133 array[i] = 0x100 + i; | 182 array[i] = 0x100 + i; |
134 } | 183 } |
135 Expect.listEquals([0, 1, 2, 3, 4, | 184 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); |
136 5, 6, 7, 8, 9], | |
137 array); | |
138 for (int i = 0; i < array.length; ++i) { | 185 for (int i = 0; i < array.length; ++i) { |
139 array[i] = 0xFF - i; | 186 array[i] = 0xFF - i; |
140 } | 187 } |
141 Expect.listEquals([0xFF, 0xFE, 0xFD, 0xFC, 0xFB, | 188 Expect.listEquals( |
142 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], | 189 [0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], array); |
143 array); | |
144 for (int i = 0; i < array.length; ++i) { | 190 for (int i = 0; i < array.length; ++i) { |
145 array[i] = i; | 191 array[i] = i; |
146 } | 192 } |
147 var copy = array.sublist(0, array.length); | 193 var copy = array.sublist(0, array.length); |
148 Expect.isFalse(identical(copy, array)); | 194 Expect.isFalse(identical(copy, array)); |
149 Expect.isTrue(copy is Uint8List); | 195 Expect.isTrue(copy is Uint8List); |
150 Expect.equals(10, copy.length); | 196 Expect.equals(10, copy.length); |
151 Expect.listEquals(array, copy); | 197 Expect.listEquals(array, copy); |
152 var empty = array.sublist(array.length, array.length); | 198 var empty = array.sublist(array.length, array.length); |
153 Expect.equals(0, empty.length); | 199 Expect.equals(0, empty.length); |
154 var region = array.sublist(3, array.length - 3); | 200 var region = array.sublist(3, array.length - 3); |
155 Expect.isTrue(copy is Uint8List); | 201 Expect.isTrue(copy is Uint8List); |
156 Expect.equals(4, region.length); | 202 Expect.equals(4, region.length); |
157 Expect.listEquals([3, 4, 5, 6], region); | 203 Expect.listEquals([3, 4, 5, 6], region); |
158 array.setRange(3, 7, [257, 0, 1, 255]); | 204 array.setRange(3, 7, [257, 0, 1, 255]); |
159 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], | 205 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], array); |
160 array); | |
161 } | 206 } |
162 | 207 |
163 static testUint8List() { | 208 static testUint8List() { |
164 Expect.throws(() { new Uint8List(-1); }, | 209 Expect.throws(() { |
165 (e) { return e is ArgumentError; }); | 210 new Uint8List(-1); |
| 211 }, (e) { |
| 212 return e is ArgumentError; |
| 213 }); |
166 var array = new Uint8List(10); | 214 var array = new Uint8List(10); |
167 testUint8ListImpl(array); | 215 testUint8ListImpl(array); |
168 } | 216 } |
169 | 217 |
170 static testInt16ListImpl(Int16List array) { | 218 static testInt16ListImpl(Int16List array) { |
171 Expect.isTrue(array is List<int>); | 219 Expect.isTrue(array is List<int>); |
172 Expect.equals(10, array.length); | 220 Expect.equals(10, array.length); |
173 Expect.equals(2, array.elementSizeInBytes); | 221 Expect.equals(2, array.elementSizeInBytes); |
174 Expect.equals(20, array.lengthInBytes); | 222 Expect.equals(20, array.lengthInBytes); |
175 Expect.listEquals([0, 0, 0, 0, 0, | 223 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); |
176 0, 0, 0, 0, 0], | 224 Expect.throws(() { |
177 array); | 225 array[-1] = 0; |
178 Expect.throws(() { array[-1] = 0; }, | 226 }, (e) { |
179 (e) { return e is RangeError; }); | 227 return e is RangeError; |
180 Expect.throws(() { return array[-1]; }, | 228 }); |
181 (e) { return e is RangeError; }); | 229 Expect.throws(() { |
182 Expect.throws(() { array[10]; }, | 230 return array[-1]; |
183 (e) { return e is RangeError; }); | 231 }, (e) { |
184 Expect.throws(() { array[10] = 0; }, | 232 return e is RangeError; |
185 (e) { return e is RangeError; }); | 233 }); |
186 Expect.throws(() { array.add(0); }, | 234 Expect.throws(() { |
187 (e) { return e is UnsupportedError; }); | 235 array[10]; |
188 Expect.throws(() { array.addAll([0]); }, | 236 }, (e) { |
189 (e) { return e is UnsupportedError; }); | 237 return e is RangeError; |
190 Expect.throws(() { array.clear(); }, | 238 }); |
191 (e) { return e is UnsupportedError; }); | 239 Expect.throws(() { |
192 Expect.throws(() { array.length = 0; }, | 240 array[10] = 0; |
193 (e) { return e is UnsupportedError; }); | 241 }, (e) { |
194 Expect.throws(() { array.removeLast(); }, | 242 return e is RangeError; |
195 (e) { return e is UnsupportedError; }); | 243 }); |
196 Expect.throws(() { array.removeRange(0, array.length - 1); }, | 244 Expect.throws(() { |
197 (e) { return e is UnsupportedError; }); | 245 array.add(0); |
| 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 }); |
198 for (int i = 0; i < array.length; ++i) { | 274 for (int i = 0; i < array.length; ++i) { |
199 array[i] = 1 + i; | 275 array[i] = 1 + i; |
200 } | 276 } |
201 Expect.listEquals([1, 2, 3, 4, 5, | 277 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); |
202 6, 7, 8, 9, 10], | |
203 array); | |
204 for (int i = 0; i < array.length; ++i) { | 278 for (int i = 0; i < array.length; ++i) { |
205 array[i] = 0x10000 + i; | 279 array[i] = 0x10000 + i; |
206 } | 280 } |
207 Expect.listEquals([0, 1, 2, 3, 4, | 281 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); |
208 5, 6, 7, 8, 9], | |
209 array); | |
210 for (int i = 0; i < array.length; ++i) { | 282 for (int i = 0; i < array.length; ++i) { |
211 array[i] = -10 + i; | 283 array[i] = -10 + i; |
212 } | 284 } |
213 Expect.listEquals([-10, -9, -8, -7, -6, | 285 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], array); |
214 -5, -4, -3, -2, -1], | |
215 array); | |
216 for (int i = 0; i < array.length; ++i) { | 286 for (int i = 0; i < array.length; ++i) { |
217 array[i] = 0x7FFF - i; | 287 array[i] = 0x7FFF - i; |
218 } | 288 } |
219 Expect.listEquals([0x7FFF, 0x7FFE, 0x7FFD, 0x7FFC, 0x7FFB, | 289 Expect.listEquals([ |
220 0x7FFA, 0x7FF9, 0x7FF8, 0x7FF7, 0x7FF6], | 290 0x7FFF, |
221 array); | 291 0x7FFE, |
| 292 0x7FFD, |
| 293 0x7FFC, |
| 294 0x7FFB, |
| 295 0x7FFA, |
| 296 0x7FF9, |
| 297 0x7FF8, |
| 298 0x7FF7, |
| 299 0x7FF6 |
| 300 ], array); |
222 for (int i = 0; i < array.length; ++i) { | 301 for (int i = 0; i < array.length; ++i) { |
223 array[i] = -0x8000 + i; | 302 array[i] = -0x8000 + i; |
224 } | 303 } |
225 Expect.listEquals([-0x8000, -0x7FFF, -0x7FFE, -0x7FFD, -0x7FFC, | 304 Expect.listEquals([ |
226 -0x7FFB, -0x7FFA, -0x7FF9, -0x7FF8, -0x7FF7], | 305 -0x8000, |
227 array); | 306 -0x7FFF, |
| 307 -0x7FFE, |
| 308 -0x7FFD, |
| 309 -0x7FFC, |
| 310 -0x7FFB, |
| 311 -0x7FFA, |
| 312 -0x7FF9, |
| 313 -0x7FF8, |
| 314 -0x7FF7 |
| 315 ], array); |
228 for (int i = 0; i < array.length; ++i) { | 316 for (int i = 0; i < array.length; ++i) { |
229 array[i] = i; | 317 array[i] = i; |
230 } | 318 } |
231 var copy = array.sublist(0, array.length); | 319 var copy = array.sublist(0, array.length); |
232 Expect.isFalse(identical(copy, array)); | 320 Expect.isFalse(identical(copy, array)); |
233 Expect.isTrue(copy is Int16List); | 321 Expect.isTrue(copy is Int16List); |
234 Expect.equals(10, copy.length); | 322 Expect.equals(10, copy.length); |
235 Expect.listEquals(array, copy); | 323 Expect.listEquals(array, copy); |
236 var empty = array.sublist(array.length, array.length); | 324 var empty = array.sublist(array.length, array.length); |
237 Expect.equals(0, empty.length); | 325 Expect.equals(0, empty.length); |
238 var region = array.sublist(3, array.length - 3); | 326 var region = array.sublist(3, array.length - 3); |
239 Expect.isTrue(copy is Int16List); | 327 Expect.isTrue(copy is Int16List); |
240 Expect.equals(4, region.length); | 328 Expect.equals(4, region.length); |
241 Expect.listEquals([3, 4, 5, 6], region); | 329 Expect.listEquals([3, 4, 5, 6], region); |
242 array.setRange(3, 7, [-32768, 0, 1, 32767]); | 330 array.setRange(3, 7, [-32768, 0, 1, 32767]); |
243 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], | 331 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], array); |
244 array); | |
245 } | 332 } |
246 | 333 |
247 static testInt16List() { | 334 static testInt16List() { |
248 Expect.throws(() { new Int16List(-1); }, | 335 Expect.throws(() { |
249 (e) { return e is ArgumentError; }); | 336 new Int16List(-1); |
| 337 }, (e) { |
| 338 return e is ArgumentError; |
| 339 }); |
250 var array = new Int16List(10); | 340 var array = new Int16List(10); |
251 testInt16ListImpl(array); | 341 testInt16ListImpl(array); |
252 } | 342 } |
253 | 343 |
254 static testUint16ListImpl(Uint16List array) { | 344 static testUint16ListImpl(Uint16List array) { |
255 Expect.isTrue(array is List<int>); | 345 Expect.isTrue(array is List<int>); |
256 Expect.equals(10, array.length); | 346 Expect.equals(10, array.length); |
257 Expect.equals(2, array.elementSizeInBytes); | 347 Expect.equals(2, array.elementSizeInBytes); |
258 Expect.equals(20, array.lengthInBytes); | 348 Expect.equals(20, array.lengthInBytes); |
259 Expect.listEquals([0, 0, 0, 0, 0, | 349 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); |
260 0, 0, 0, 0, 0], | 350 Expect.throws(() { |
261 array); | 351 array[-1] = 0; |
262 Expect.throws(() { array[-1] = 0; }, | 352 }, (e) { |
263 (e) { return e is RangeError; }); | 353 return e is RangeError; |
264 Expect.throws(() { return array[-1]; }, | 354 }); |
265 (e) { return e is RangeError; }); | 355 Expect.throws(() { |
266 Expect.throws(() { array[10]; }, | 356 return array[-1]; |
267 (e) { return e is RangeError; }); | 357 }, (e) { |
268 Expect.throws(() { array[10] = 0; }, | 358 return e is RangeError; |
269 (e) { return e is RangeError; }); | 359 }); |
270 Expect.throws(() { array.add(0); }, | 360 Expect.throws(() { |
271 (e) { return e is UnsupportedError; }); | 361 array[10]; |
272 Expect.throws(() { array.addAll([0]); }, | 362 }, (e) { |
273 (e) { return e is UnsupportedError; }); | 363 return e is RangeError; |
274 Expect.throws(() { array.clear(); }, | 364 }); |
275 (e) { return e is UnsupportedError; }); | 365 Expect.throws(() { |
276 Expect.throws(() { array.length = 0; }, | 366 array[10] = 0; |
277 (e) { return e is UnsupportedError; }); | 367 }, (e) { |
278 Expect.throws(() { array.removeLast(); }, | 368 return e is RangeError; |
279 (e) { return e is UnsupportedError; }); | 369 }); |
280 Expect.throws(() { array.removeRange(0, array.length - 1); }, | 370 Expect.throws(() { |
281 (e) { return e is UnsupportedError; }); | 371 array.add(0); |
| 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 }); |
282 for (int i = 0; i < array.length; ++i) { | 400 for (int i = 0; i < array.length; ++i) { |
283 array[i] = 1 + i; | 401 array[i] = 1 + i; |
284 } | 402 } |
285 Expect.listEquals([1, 2, 3, 4, 5, | 403 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); |
286 6, 7, 8, 9, 10], | |
287 array); | |
288 for (int i = 0; i < array.length; ++i) { | 404 for (int i = 0; i < array.length; ++i) { |
289 array[i] = 0x10000 + i; | 405 array[i] = 0x10000 + i; |
290 } | 406 } |
291 Expect.listEquals([0, 1, 2, 3, 4, | 407 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); |
292 5, 6, 7, 8, 9], | |
293 array); | |
294 for (int i = 0; i < array.length; ++i) { | 408 for (int i = 0; i < array.length; ++i) { |
295 array[i] = 0xFFFF - i; | 409 array[i] = 0xFFFF - i; |
296 } | 410 } |
297 Expect.listEquals([0xFFFF, 0xFFFE, 0xFFFD, 0xFFFC, 0xFFFB, | 411 Expect.listEquals([ |
298 0xFFFA, 0xFFF9, 0xFFF8, 0xFFF7, 0xFFF6], | 412 0xFFFF, |
299 array); | 413 0xFFFE, |
| 414 0xFFFD, |
| 415 0xFFFC, |
| 416 0xFFFB, |
| 417 0xFFFA, |
| 418 0xFFF9, |
| 419 0xFFF8, |
| 420 0xFFF7, |
| 421 0xFFF6 |
| 422 ], array); |
300 for (int i = 0; i < array.length; ++i) { | 423 for (int i = 0; i < array.length; ++i) { |
301 array[i] = i; | 424 array[i] = i; |
302 } | 425 } |
303 var copy = array.sublist(0, array.length); | 426 var copy = array.sublist(0, array.length); |
304 Expect.isFalse(identical(copy, array)); | 427 Expect.isFalse(identical(copy, array)); |
305 Expect.isTrue(copy is Uint16List); | 428 Expect.isTrue(copy is Uint16List); |
306 Expect.equals(10, copy.length); | 429 Expect.equals(10, copy.length); |
307 Expect.listEquals(array, copy); | 430 Expect.listEquals(array, copy); |
308 var empty = array.sublist(array.length, array.length); | 431 var empty = array.sublist(array.length, array.length); |
309 Expect.equals(0, empty.length); | 432 Expect.equals(0, empty.length); |
310 var region = array.sublist(3, array.length - 3); | 433 var region = array.sublist(3, array.length - 3); |
311 Expect.isTrue(copy is Uint16List); | 434 Expect.isTrue(copy is Uint16List); |
312 Expect.equals(4, region.length); | 435 Expect.equals(4, region.length); |
313 Expect.listEquals([3, 4, 5, 6], region); | 436 Expect.listEquals([3, 4, 5, 6], region); |
314 array.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]); | 437 array.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]); |
315 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], | 438 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], array); |
316 array); | |
317 } | 439 } |
318 | 440 |
319 static testUint16List() { | 441 static testUint16List() { |
320 Expect.throws(() { new Uint16List(-1); }, | 442 Expect.throws(() { |
321 (e) { return e is ArgumentError; }); | 443 new Uint16List(-1); |
| 444 }, (e) { |
| 445 return e is ArgumentError; |
| 446 }); |
322 var array = new Uint16List(10); | 447 var array = new Uint16List(10); |
323 testUint16ListImpl(array); | 448 testUint16ListImpl(array); |
324 } | 449 } |
325 | 450 |
326 static testInt32ListImpl(Int32List array) { | 451 static testInt32ListImpl(Int32List array) { |
327 Expect.isTrue(array is List<int>); | 452 Expect.isTrue(array is List<int>); |
328 Expect.equals(10, array.length); | 453 Expect.equals(10, array.length); |
329 Expect.equals(4, array.elementSizeInBytes); | 454 Expect.equals(4, array.elementSizeInBytes); |
330 Expect.equals(40, array.lengthInBytes); | 455 Expect.equals(40, array.lengthInBytes); |
331 Expect.listEquals([0, 0, 0, 0, 0, | 456 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); |
332 0, 0, 0, 0, 0], | 457 Expect.throws(() { |
333 array); | 458 array[-1] = 0; |
334 Expect.throws(() { array[-1] = 0; }, | 459 }, (e) { |
335 (e) { return e is RangeError; }); | 460 return e is RangeError; |
336 Expect.throws(() { return array[-1]; }, | 461 }); |
337 (e) { return e is RangeError; }); | 462 Expect.throws(() { |
338 Expect.throws(() { array[10]; }, | 463 return array[-1]; |
339 (e) { return e is RangeError; }); | 464 }, (e) { |
340 Expect.throws(() { array[10] = 0; }, | 465 return e is RangeError; |
341 (e) { return e is RangeError; }); | 466 }); |
342 Expect.throws(() { array.add(0); }, | 467 Expect.throws(() { |
343 (e) { return e is UnsupportedError; }); | 468 array[10]; |
344 Expect.throws(() { array.addAll([0]); }, | 469 }, (e) { |
345 (e) { return e is UnsupportedError; }); | 470 return e is RangeError; |
346 Expect.throws(() { array.clear(); }, | 471 }); |
347 (e) { return e is UnsupportedError; }); | 472 Expect.throws(() { |
348 Expect.throws(() { array.length = 0; }, | 473 array[10] = 0; |
349 (e) { return e is UnsupportedError; }); | 474 }, (e) { |
350 Expect.throws(() { array.removeLast(); }, | 475 return e is RangeError; |
351 (e) { return e is UnsupportedError; }); | 476 }); |
352 Expect.throws(() { array.removeRange(0, array.length - 1); }, | 477 Expect.throws(() { |
353 (e) { return e is UnsupportedError; }); | 478 array.add(0); |
| 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 }); |
354 for (int i = 0; i < array.length; ++i) { | 507 for (int i = 0; i < array.length; ++i) { |
355 array[i] = 1 + i; | 508 array[i] = 1 + i; |
356 } | 509 } |
357 Expect.listEquals([1, 2, 3, 4, 5, | 510 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); |
358 6, 7, 8, 9, 10], | |
359 array); | |
360 for (int i = 0; i < array.length; ++i) { | 511 for (int i = 0; i < array.length; ++i) { |
361 array[i] = 0x100000000 + i; | 512 array[i] = 0x100000000 + i; |
362 } | 513 } |
363 Expect.listEquals([0, 1, 2, 3, 4, | 514 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); |
364 5, 6, 7, 8, 9], | |
365 array); | |
366 for (int i = 0; i < array.length; ++i) { | 515 for (int i = 0; i < array.length; ++i) { |
367 array[i] = -10 + i; | 516 array[i] = -10 + i; |
368 } | 517 } |
369 Expect.listEquals([-10, -9, -8, -7, -6, | 518 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], array); |
370 -5, -4, -3, -2, -1], | |
371 array); | |
372 for (int i = 0; i < array.length; ++i) { | 519 for (int i = 0; i < array.length; ++i) { |
373 array[i] = 0x7FFFFFFF - i; | 520 array[i] = 0x7FFFFFFF - i; |
374 } | 521 } |
375 Expect.listEquals([0x7FFFFFFF, 0x7FFFFFFE, | 522 Expect.listEquals([ |
376 0x7FFFFFFD, 0x7FFFFFFC, | 523 0x7FFFFFFF, |
377 0x7FFFFFFB, 0x7FFFFFFA, | 524 0x7FFFFFFE, |
378 0x7FFFFFF9, 0x7FFFFFF8, | 525 0x7FFFFFFD, |
379 0x7FFFFFF7, 0x7FFFFFF6], | 526 0x7FFFFFFC, |
380 array); | 527 0x7FFFFFFB, |
| 528 0x7FFFFFFA, |
| 529 0x7FFFFFF9, |
| 530 0x7FFFFFF8, |
| 531 0x7FFFFFF7, |
| 532 0x7FFFFFF6 |
| 533 ], array); |
381 for (int i = 0; i < array.length; ++i) { | 534 for (int i = 0; i < array.length; ++i) { |
382 array[i] = -0x80000000 + i; | 535 array[i] = -0x80000000 + i; |
383 } | 536 } |
384 Expect.listEquals([-0x80000000, -0x7FFFFFFF, | 537 Expect.listEquals([ |
385 -0x7FFFFFFE, -0x7FFFFFFD, | 538 -0x80000000, |
386 -0x7FFFFFFC, -0x7FFFFFFB, | 539 -0x7FFFFFFF, |
387 -0x7FFFFFFA, -0x7FFFFFF9, | 540 -0x7FFFFFFE, |
388 -0x7FFFFFF8, -0x7FFFFFF7], | 541 -0x7FFFFFFD, |
389 array); | 542 -0x7FFFFFFC, |
| 543 -0x7FFFFFFB, |
| 544 -0x7FFFFFFA, |
| 545 -0x7FFFFFF9, |
| 546 -0x7FFFFFF8, |
| 547 -0x7FFFFFF7 |
| 548 ], array); |
390 for (int i = 0; i < array.length; ++i) { | 549 for (int i = 0; i < array.length; ++i) { |
391 array[i] = i; | 550 array[i] = i; |
392 } | 551 } |
393 var copy = array.sublist(0, array.length); | 552 var copy = array.sublist(0, array.length); |
394 Expect.isFalse(identical(copy, array)); | 553 Expect.isFalse(identical(copy, array)); |
395 Expect.isTrue(copy is Int32List); | 554 Expect.isTrue(copy is Int32List); |
396 Expect.equals(10, copy.length); | 555 Expect.equals(10, copy.length); |
397 Expect.listEquals(array, copy); | 556 Expect.listEquals(array, copy); |
398 var empty = array.sublist(array.length, array.length); | 557 var empty = array.sublist(array.length, array.length); |
399 Expect.equals(0, empty.length); | 558 Expect.equals(0, empty.length); |
400 var region = array.sublist(3, array.length - 3); | 559 var region = array.sublist(3, array.length - 3); |
401 Expect.isTrue(copy is Int32List); | 560 Expect.isTrue(copy is Int32List); |
402 Expect.equals(4, region.length); | 561 Expect.equals(4, region.length); |
403 Expect.listEquals([3, 4, 5, 6], region); | 562 Expect.listEquals([3, 4, 5, 6], region); |
404 array.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]); | 563 array.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]); |
405 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], | 564 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], array); |
406 array); | |
407 } | 565 } |
408 | 566 |
409 static testInt32List() { | 567 static testInt32List() { |
410 Expect.throws(() { new Int32List(-1); }, | 568 Expect.throws(() { |
411 (e) { return e is ArgumentError; }); | 569 new Int32List(-1); |
| 570 }, (e) { |
| 571 return e is ArgumentError; |
| 572 }); |
412 var array = new Int32List(10); | 573 var array = new Int32List(10); |
413 testInt32ListImpl(array); | 574 testInt32ListImpl(array); |
414 } | 575 } |
415 | 576 |
416 static testUint32ListImpl(Uint32List array) { | 577 static testUint32ListImpl(Uint32List array) { |
417 Expect.isTrue(array is List<int>); | 578 Expect.isTrue(array is List<int>); |
418 Expect.equals(10, array.length); | 579 Expect.equals(10, array.length); |
419 Expect.equals(4, array.elementSizeInBytes); | 580 Expect.equals(4, array.elementSizeInBytes); |
420 Expect.equals(40, array.lengthInBytes); | 581 Expect.equals(40, array.lengthInBytes); |
421 Expect.listEquals([0, 0, 0, 0, 0, | 582 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); |
422 0, 0, 0, 0, 0], | 583 Expect.throws(() { |
423 array); | 584 array[-1] = 0; |
424 Expect.throws(() { array[-1] = 0; }, | 585 }, (e) { |
425 (e) { return e is RangeError; }); | 586 return e is RangeError; |
426 Expect.throws(() { return array[-1]; }, | 587 }); |
427 (e) { return e is RangeError; }); | 588 Expect.throws(() { |
428 Expect.throws(() { array[10]; }, | 589 return array[-1]; |
429 (e) { return e is RangeError; }); | 590 }, (e) { |
430 Expect.throws(() { array[10] = 0; }, | 591 return e is RangeError; |
431 (e) { return e is RangeError; }); | 592 }); |
432 Expect.throws(() { array.add(0); }, | 593 Expect.throws(() { |
433 (e) { return e is UnsupportedError; }); | 594 array[10]; |
434 Expect.throws(() { array.addAll([0]); }, | 595 }, (e) { |
435 (e) { return e is UnsupportedError; }); | 596 return e is RangeError; |
436 Expect.throws(() { array.clear(); }, | 597 }); |
437 (e) { return e is UnsupportedError; }); | 598 Expect.throws(() { |
438 Expect.throws(() { array.length = 0; }, | 599 array[10] = 0; |
439 (e) { return e is UnsupportedError; }); | 600 }, (e) { |
440 Expect.throws(() { array.removeLast(); }, | 601 return e is RangeError; |
441 (e) { return e is UnsupportedError; }); | 602 }); |
442 Expect.throws(() { array.removeRange(0, array.length - 1); }, | 603 Expect.throws(() { |
443 (e) { return e is UnsupportedError; }); | 604 array.add(0); |
| 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 }); |
444 for (int i = 0; i < array.length; ++i) { | 633 for (int i = 0; i < array.length; ++i) { |
445 array[i] = 1 + i; | 634 array[i] = 1 + i; |
446 } | 635 } |
447 Expect.listEquals([1, 2, 3, 4, 5, | 636 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); |
448 6, 7, 8, 9, 10], | |
449 array); | |
450 for (int i = 0; i < array.length; ++i) { | 637 for (int i = 0; i < array.length; ++i) { |
451 array[i] = 0x100000000 + i; | 638 array[i] = 0x100000000 + i; |
452 } | 639 } |
453 Expect.listEquals([0, 1, 2, 3, 4, | 640 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); |
454 5, 6, 7, 8, 9], | |
455 array); | |
456 for (int i = 0; i < array.length; ++i) { | 641 for (int i = 0; i < array.length; ++i) { |
457 array[i] = 0xFFFFFFFF - i; | 642 array[i] = 0xFFFFFFFF - i; |
458 } | 643 } |
459 Expect.listEquals([0xFFFFFFFF, 0xFFFFFFFE, | 644 Expect.listEquals([ |
460 0xFFFFFFFD, 0xFFFFFFFC, | 645 0xFFFFFFFF, |
461 0xFFFFFFFB, 0xFFFFFFFA, | 646 0xFFFFFFFE, |
462 0xFFFFFFF9, 0xFFFFFFF8, | 647 0xFFFFFFFD, |
463 0xFFFFFFF7, 0xFFFFFFF6], | 648 0xFFFFFFFC, |
464 array); | 649 0xFFFFFFFB, |
| 650 0xFFFFFFFA, |
| 651 0xFFFFFFF9, |
| 652 0xFFFFFFF8, |
| 653 0xFFFFFFF7, |
| 654 0xFFFFFFF6 |
| 655 ], array); |
465 for (int i = 0; i < array.length; ++i) { | 656 for (int i = 0; i < array.length; ++i) { |
466 array[i] = i; | 657 array[i] = i; |
467 } | 658 } |
468 var copy = array.sublist(0, array.length); | 659 var copy = array.sublist(0, array.length); |
469 Expect.isFalse(identical(copy, array)); | 660 Expect.isFalse(identical(copy, array)); |
470 Expect.isTrue(copy is Uint32List); | 661 Expect.isTrue(copy is Uint32List); |
471 Expect.equals(10, copy.length); | 662 Expect.equals(10, copy.length); |
472 Expect.listEquals(array, copy); | 663 Expect.listEquals(array, copy); |
473 var empty = array.sublist(array.length, array.length); | 664 var empty = array.sublist(array.length, array.length); |
474 Expect.equals(0, empty.length); | 665 Expect.equals(0, empty.length); |
475 var region = array.sublist(3, array.length - 3); | 666 var region = array.sublist(3, array.length - 3); |
476 Expect.isTrue(copy is Uint32List); | 667 Expect.isTrue(copy is Uint32List); |
477 Expect.equals(4, region.length); | 668 Expect.equals(4, region.length); |
478 Expect.listEquals([3, 4, 5, 6], region); | 669 Expect.listEquals([3, 4, 5, 6], region); |
479 array.setRange(3, 7, [0x100000001, 0, 1, 0xFFFFFFFF]); | 670 array.setRange(3, 7, [0x100000001, 0, 1, 0xFFFFFFFF]); |
480 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], | 671 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], array); |
481 array); | |
482 } | 672 } |
483 | 673 |
484 static testUint32List() { | 674 static testUint32List() { |
485 Expect.throws(() { new Uint32List(-1); }, | 675 Expect.throws(() { |
486 (e) { return e is ArgumentError; }); | 676 new Uint32List(-1); |
487 Expect.throws(() { new Uint32List(-1); }, | 677 }, (e) { |
488 (e) { return e is ArgumentError; }); | 678 return e is ArgumentError; |
| 679 }); |
| 680 Expect.throws(() { |
| 681 new Uint32List(-1); |
| 682 }, (e) { |
| 683 return e is ArgumentError; |
| 684 }); |
489 var array = new Uint32List(10); | 685 var array = new Uint32List(10); |
490 testUint32ListImpl(array); | 686 testUint32ListImpl(array); |
491 | |
492 } | 687 } |
493 | 688 |
494 static testInt64ListImpl(Int64List array) { | 689 static testInt64ListImpl(Int64List array) { |
495 Expect.isTrue(array is List<int>); | 690 Expect.isTrue(array is List<int>); |
496 Expect.equals(10, array.length); | 691 Expect.equals(10, array.length); |
497 Expect.equals(8, array.elementSizeInBytes); | 692 Expect.equals(8, array.elementSizeInBytes); |
498 Expect.equals(80, array.lengthInBytes); | 693 Expect.equals(80, array.lengthInBytes); |
499 Expect.listEquals([0, 0, 0, 0, 0, | 694 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); |
500 0, 0, 0, 0, 0], | 695 Expect.throws(() { |
501 array); | 696 array[-1] = 0; |
502 Expect.throws(() { array[-1] = 0; }, | 697 }, (e) { |
503 (e) { return e is RangeError; }); | 698 return e is RangeError; |
504 Expect.throws(() { return array[-1]; }, | 699 }); |
505 (e) { return e is RangeError; }); | 700 Expect.throws(() { |
506 Expect.throws(() { array[10]; }, | 701 return array[-1]; |
507 (e) { return e is RangeError; }); | 702 }, (e) { |
508 Expect.throws(() { array[10] = 0; }, | 703 return e is RangeError; |
509 (e) { return e is RangeError; }); | 704 }); |
510 Expect.throws(() { array.add(0); }, | 705 Expect.throws(() { |
511 (e) { return e is UnsupportedError; }); | 706 array[10]; |
512 Expect.throws(() { array.addAll([0]); }, | 707 }, (e) { |
513 (e) { return e is UnsupportedError; }); | 708 return e is RangeError; |
514 Expect.throws(() { array.clear(); }, | 709 }); |
515 (e) { return e is UnsupportedError; }); | 710 Expect.throws(() { |
516 Expect.throws(() { array.length = 0; }, | 711 array[10] = 0; |
517 (e) { return e is UnsupportedError; }); | 712 }, (e) { |
518 Expect.throws(() { array.removeLast(); }, | 713 return e is RangeError; |
519 (e) { return e is UnsupportedError; }); | 714 }); |
520 Expect.throws(() { array.removeRange(0, array.length - 1); }, | 715 Expect.throws(() { |
521 (e) { return e is UnsupportedError; }); | 716 array.add(0); |
| 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 }); |
522 for (int i = 0; i < array.length; ++i) { | 745 for (int i = 0; i < array.length; ++i) { |
523 array[i] = 1 + i; | 746 array[i] = 1 + i; |
524 } | 747 } |
525 Expect.listEquals([1, 2, 3, 4, 5, | 748 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); |
526 6, 7, 8, 9, 10], | |
527 array); | |
528 for (int i = 0; i < array.length; ++i) { | 749 for (int i = 0; i < array.length; ++i) { |
529 array[i] = 0x10000000000000000 + i; | 750 array[i] = 0x10000000000000000 + i; |
530 } | 751 } |
531 Expect.listEquals([0, 1, 2, 3, 4, | 752 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); |
532 5, 6, 7, 8, 9], | |
533 array); | |
534 for (int i = 0; i < array.length; ++i) { | 753 for (int i = 0; i < array.length; ++i) { |
535 array[i] = -10 + i; | 754 array[i] = -10 + i; |
536 } | 755 } |
537 Expect.listEquals([-10, -9, -8, -7, -6, | 756 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], array); |
538 -5, -4, -3, -2, -1], | |
539 array); | |
540 for (int i = 0; i < array.length; ++i) { | 757 for (int i = 0; i < array.length; ++i) { |
541 array[i] = 0x7FFFFFFFFFFFFFFF - i; | 758 array[i] = 0x7FFFFFFFFFFFFFFF - i; |
542 } | 759 } |
543 Expect.listEquals([0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFE, | 760 Expect.listEquals([ |
544 0x7FFFFFFFFFFFFFFD, 0x7FFFFFFFFFFFFFFC, | 761 0x7FFFFFFFFFFFFFFF, |
545 0x7FFFFFFFFFFFFFFB, 0x7FFFFFFFFFFFFFFA, | 762 0x7FFFFFFFFFFFFFFE, |
546 0x7FFFFFFFFFFFFFF9, 0x7FFFFFFFFFFFFFF8, | 763 0x7FFFFFFFFFFFFFFD, |
547 0x7FFFFFFFFFFFFFF7, 0x7FFFFFFFFFFFFFF6], | 764 0x7FFFFFFFFFFFFFFC, |
548 array); | 765 0x7FFFFFFFFFFFFFFB, |
| 766 0x7FFFFFFFFFFFFFFA, |
| 767 0x7FFFFFFFFFFFFFF9, |
| 768 0x7FFFFFFFFFFFFFF8, |
| 769 0x7FFFFFFFFFFFFFF7, |
| 770 0x7FFFFFFFFFFFFFF6 |
| 771 ], array); |
549 for (int i = 0; i < array.length; ++i) { | 772 for (int i = 0; i < array.length; ++i) { |
550 array[i] = -0x8000000000000000 + i; | 773 array[i] = -0x8000000000000000 + i; |
551 } | 774 } |
552 Expect.listEquals([-0x8000000000000000, -0x7FFFFFFFFFFFFFFF, | 775 Expect.listEquals([ |
553 -0x7FFFFFFFFFFFFFFE, -0x7FFFFFFFFFFFFFFD, | 776 -0x8000000000000000, |
554 -0x7FFFFFFFFFFFFFFC, -0x7FFFFFFFFFFFFFFB, | 777 -0x7FFFFFFFFFFFFFFF, |
555 -0x7FFFFFFFFFFFFFFA, -0x7FFFFFFFFFFFFFF9, | 778 -0x7FFFFFFFFFFFFFFE, |
556 -0x7FFFFFFFFFFFFFF8, -0x7FFFFFFFFFFFFFF7], | 779 -0x7FFFFFFFFFFFFFFD, |
557 array); | 780 -0x7FFFFFFFFFFFFFFC, |
| 781 -0x7FFFFFFFFFFFFFFB, |
| 782 -0x7FFFFFFFFFFFFFFA, |
| 783 -0x7FFFFFFFFFFFFFF9, |
| 784 -0x7FFFFFFFFFFFFFF8, |
| 785 -0x7FFFFFFFFFFFFFF7 |
| 786 ], array); |
558 for (int i = 0; i < array.length; ++i) { | 787 for (int i = 0; i < array.length; ++i) { |
559 array[i] = i; | 788 array[i] = i; |
560 } | 789 } |
561 var copy = array.sublist(0, array.length); | 790 var copy = array.sublist(0, array.length); |
562 Expect.isFalse(identical(copy, array)); | 791 Expect.isFalse(identical(copy, array)); |
563 Expect.isTrue(copy is Int64List); | 792 Expect.isTrue(copy is Int64List); |
564 Expect.equals(10, copy.length); | 793 Expect.equals(10, copy.length); |
565 Expect.listEquals(array, copy); | 794 Expect.listEquals(array, copy); |
566 var empty = array.sublist(array.length, array.length); | 795 var empty = array.sublist(array.length, array.length); |
567 Expect.equals(0, empty.length); | 796 Expect.equals(0, empty.length); |
568 var region = array.sublist(3, array.length - 3); | 797 var region = array.sublist(3, array.length - 3); |
569 Expect.isTrue(copy is Int64List); | 798 Expect.isTrue(copy is Int64List); |
570 Expect.equals(4, region.length); | 799 Expect.equals(4, region.length); |
571 Expect.listEquals([3, 4, 5, 6], region); | 800 Expect.listEquals([3, 4, 5, 6], region); |
572 array.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); | 801 array.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); |
573 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, | 802 Expect.listEquals( |
574 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], | 803 [0, 1, 2, -0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], |
575 array); | 804 array); |
576 } | 805 } |
577 | 806 |
578 static testInt64List() { | 807 static testInt64List() { |
579 Expect.throws(() { new Int64List(-1); }, | 808 Expect.throws(() { |
580 (e) { return e is ArgumentError; }); | 809 new Int64List(-1); |
| 810 }, (e) { |
| 811 return e is ArgumentError; |
| 812 }); |
581 var array = new Int64List(10); | 813 var array = new Int64List(10); |
582 testInt64ListImpl(array); | 814 testInt64ListImpl(array); |
583 } | 815 } |
584 | 816 |
585 static testUint64ListImpl(Uint64List array) { | 817 static testUint64ListImpl(Uint64List array) { |
586 Expect.isTrue(array is List<int>); | 818 Expect.isTrue(array is List<int>); |
587 Expect.equals(10, array.length); | 819 Expect.equals(10, array.length); |
588 Expect.equals(8, array.elementSizeInBytes); | 820 Expect.equals(8, array.elementSizeInBytes); |
589 Expect.equals(80, array.lengthInBytes); | 821 Expect.equals(80, array.lengthInBytes); |
590 Expect.listEquals([0, 0, 0, 0, 0, | 822 Expect.listEquals([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], array); |
591 0, 0, 0, 0, 0], | 823 Expect.throws(() { |
592 array); | 824 array[-1] = 0; |
593 Expect.throws(() { array[-1] = 0; }, | 825 }, (e) { |
594 (e) { return e is RangeError; }); | 826 return e is RangeError; |
595 Expect.throws(() { return array[-1]; }, | 827 }); |
596 (e) { return e is RangeError; }); | 828 Expect.throws(() { |
597 Expect.throws(() { array[10]; }, | 829 return array[-1]; |
598 (e) { return e is RangeError; }); | 830 }, (e) { |
599 Expect.throws(() { array[10] = 0; }, | 831 return e is RangeError; |
600 (e) { return e is RangeError; }); | 832 }); |
601 Expect.throws(() { array.add(0); }, | 833 Expect.throws(() { |
602 (e) { return e is UnsupportedError; }); | 834 array[10]; |
603 Expect.throws(() { array.addAll([0]); }, | 835 }, (e) { |
604 (e) { return e is UnsupportedError; }); | 836 return e is RangeError; |
605 Expect.throws(() { array.clear(); }, | 837 }); |
606 (e) { return e is UnsupportedError; }); | 838 Expect.throws(() { |
607 Expect.throws(() { array.length = 0; }, | 839 array[10] = 0; |
608 (e) { return e is UnsupportedError; }); | 840 }, (e) { |
609 Expect.throws(() { array.removeLast(); }, | 841 return e is RangeError; |
610 (e) { return e is UnsupportedError; }); | 842 }); |
611 Expect.throws(() { array.removeRange(0, array.length - 1); }, | 843 Expect.throws(() { |
612 (e) { return e is UnsupportedError; }); | 844 array.add(0); |
| 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 }); |
613 for (int i = 0; i < array.length; ++i) { | 873 for (int i = 0; i < array.length; ++i) { |
614 array[i] = 1 + i; | 874 array[i] = 1 + i; |
615 } | 875 } |
616 Expect.listEquals([1, 2, 3, 4, 5, | 876 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], array); |
617 6, 7, 8, 9, 10], | |
618 array); | |
619 for (int i = 0; i < array.length; ++i) { | 877 for (int i = 0; i < array.length; ++i) { |
620 array[i] = 0x10000000000000000 + i; | 878 array[i] = 0x10000000000000000 + i; |
621 } | 879 } |
622 Expect.listEquals([0, 1, 2, 3, 4, | 880 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], array); |
623 5, 6, 7, 8, 9], | |
624 array); | |
625 for (int i = 0; i < array.length; ++i) { | 881 for (int i = 0; i < array.length; ++i) { |
626 array[i] = 0xFFFFFFFFFFFFFFFF - i; | 882 array[i] = 0xFFFFFFFFFFFFFFFF - i; |
627 } | 883 } |
628 Expect.listEquals([0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFE, | 884 Expect.listEquals([ |
629 0xFFFFFFFFFFFFFFFD, 0xFFFFFFFFFFFFFFFC, | 885 0xFFFFFFFFFFFFFFFF, |
630 0xFFFFFFFFFFFFFFFB, 0xFFFFFFFFFFFFFFFA, | 886 0xFFFFFFFFFFFFFFFE, |
631 0xFFFFFFFFFFFFFFF9, 0xFFFFFFFFFFFFFFF8, | 887 0xFFFFFFFFFFFFFFFD, |
632 0xFFFFFFFFFFFFFFF7, 0xFFFFFFFFFFFFFFF6], | 888 0xFFFFFFFFFFFFFFFC, |
633 array); | 889 0xFFFFFFFFFFFFFFFB, |
| 890 0xFFFFFFFFFFFFFFFA, |
| 891 0xFFFFFFFFFFFFFFF9, |
| 892 0xFFFFFFFFFFFFFFF8, |
| 893 0xFFFFFFFFFFFFFFF7, |
| 894 0xFFFFFFFFFFFFFFF6 |
| 895 ], array); |
634 for (int i = 0; i < array.length; ++i) { | 896 for (int i = 0; i < array.length; ++i) { |
635 array[i] = i; | 897 array[i] = i; |
636 } | 898 } |
637 var copy = array.sublist(0, array.length); | 899 var copy = array.sublist(0, array.length); |
638 Expect.isFalse(identical(copy, array)); | 900 Expect.isFalse(identical(copy, array)); |
639 Expect.isTrue(copy is Uint64List); | 901 Expect.isTrue(copy is Uint64List); |
640 Expect.equals(10, copy.length); | 902 Expect.equals(10, copy.length); |
641 Expect.listEquals(array, copy); | 903 Expect.listEquals(array, copy); |
642 var empty = array.sublist(array.length, array.length); | 904 var empty = array.sublist(array.length, array.length); |
643 Expect.equals(0, empty.length); | 905 Expect.equals(0, empty.length); |
644 var region = array.sublist(3, array.length - 3); | 906 var region = array.sublist(3, array.length - 3); |
645 Expect.isTrue(copy is Uint64List); | 907 Expect.isTrue(copy is Uint64List); |
646 Expect.equals(4, region.length); | 908 Expect.equals(4, region.length); |
647 Expect.listEquals([3, 4, 5, 6], region); | 909 Expect.listEquals([3, 4, 5, 6], region); |
648 array.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); | 910 array.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); |
649 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], | 911 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], array); |
650 array); | |
651 } | 912 } |
652 | 913 |
653 static testUint64List() { | 914 static testUint64List() { |
654 Expect.throws(() { new Uint64List(-1); }, | 915 Expect.throws(() { |
655 (e) { return e is ArgumentError; }); | 916 new Uint64List(-1); |
| 917 }, (e) { |
| 918 return e is ArgumentError; |
| 919 }); |
656 var array = new Uint64List(10); | 920 var array = new Uint64List(10); |
657 testUint64ListImpl(array); | 921 testUint64ListImpl(array); |
658 } | 922 } |
659 | 923 |
660 static testFloat32ListImpl(Float32List array) { | 924 static testFloat32ListImpl(Float32List array) { |
661 Expect.isTrue(array is List<double>); | 925 Expect.isTrue(array is List<double>); |
662 Expect.equals(10, array.length); | 926 Expect.equals(10, array.length); |
663 Expect.equals(4, array.elementSizeInBytes); | 927 Expect.equals(4, array.elementSizeInBytes); |
664 Expect.equals(40, array.lengthInBytes); | 928 Expect.equals(40, array.lengthInBytes); |
665 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, | 929 Expect |
666 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); |
667 array); | 931 Expect.throws(() { |
668 Expect.throws(() { array[-1] = 0.0; }, | 932 array[-1] = 0.0; |
669 (e) { return e is RangeError; }); | 933 }, (e) { |
670 Expect.throws(() { return array[-1]; }, | 934 return e is RangeError; |
671 (e) { return e is RangeError; }); | 935 }); |
672 Expect.throws(() { array[10]; }, | 936 Expect.throws(() { |
673 (e) { return e is RangeError; }); | 937 return array[-1]; |
674 Expect.throws(() { array[10] = 0.0; }, | 938 }, (e) { |
675 (e) { return e is RangeError; }); | 939 return e is RangeError; |
676 Expect.throws(() { array.add(0.0); }, | 940 }); |
677 (e) { return e is UnsupportedError; }); | 941 Expect.throws(() { |
678 Expect.throws(() { array.addAll([0]); }, | 942 array[10]; |
679 (e) { return e is UnsupportedError; }); | 943 }, (e) { |
680 Expect.throws(() { array.clear(); }, | 944 return e is RangeError; |
681 (e) { return e is UnsupportedError; }); | 945 }); |
682 Expect.throws(() { array.length = 0; }, | 946 Expect.throws(() { |
683 (e) { return e is UnsupportedError; }); | 947 array[10] = 0.0; |
684 Expect.throws(() { array.removeLast(); }, | 948 }, (e) { |
685 (e) { return e is UnsupportedError; }); | 949 return e is RangeError; |
686 Expect.throws(() { array.removeRange(0, array.length - 1); }, | 950 }); |
687 (e) { return e is UnsupportedError; }); | 951 Expect.throws(() { |
| 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 }); |
688 for (int i = 0; i < array.length; ++i) { | 981 for (int i = 0; i < array.length; ++i) { |
689 array[i] = 1.0 + i; | 982 array[i] = 1.0 + i; |
690 } | 983 } |
691 Expect.listEquals([1.0, 2.0, 3.0, 4.0, 5.0, | 984 Expect |
692 6.0, 7.0, 8.0, 9.0, 10.0], | 985 .listEquals([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], array); |
693 array); | |
694 // TODO: min, max, and round | 986 // TODO: min, max, and round |
695 for (int i = 0; i < array.length; ++i) { | 987 for (int i = 0; i < array.length; ++i) { |
696 array[i] = i * 1.0; | 988 array[i] = i * 1.0; |
697 } | 989 } |
698 var copy = array.sublist(0, array.length); | 990 var copy = array.sublist(0, array.length); |
699 Expect.isFalse(identical(copy, array)); | 991 Expect.isFalse(identical(copy, array)); |
700 Expect.isTrue(copy is Float32List); | 992 Expect.isTrue(copy is Float32List); |
701 Expect.equals(10, copy.length); | 993 Expect.equals(10, copy.length); |
702 Expect.listEquals(array, copy); | 994 Expect.listEquals(array, copy); |
703 var empty = array.sublist(array.length, array.length); | 995 var empty = array.sublist(array.length, array.length); |
704 Expect.equals(0, empty.length); | 996 Expect.equals(0, empty.length); |
705 var region = array.sublist(3, array.length - 3); | 997 var region = array.sublist(3, array.length - 3); |
706 Expect.isTrue(copy is Float32List); | 998 Expect.isTrue(copy is Float32List); |
707 Expect.equals(4, region.length); | 999 Expect.equals(4, region.length); |
708 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 1000 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
709 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 1001 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
710 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 1002 Expect.listEquals([ |
711 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 1003 0.0, |
712 array); | 1004 1.0, |
| 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); |
713 } | 1014 } |
714 | 1015 |
715 static testFloat32List() { | 1016 static testFloat32List() { |
716 Expect.throws(() { new Float32List(-1); }, | 1017 Expect.throws(() { |
717 (e) { return e is ArgumentError; }); | 1018 new Float32List(-1); |
| 1019 }, (e) { |
| 1020 return e is ArgumentError; |
| 1021 }); |
718 var array = new Float32List(10); | 1022 var array = new Float32List(10); |
719 testFloat32ListImpl(array); | 1023 testFloat32ListImpl(array); |
720 } | 1024 } |
721 | 1025 |
722 static testFloat64ListImpl(Float64List array) { | 1026 static testFloat64ListImpl(Float64List array) { |
723 Expect.isTrue(array is List<double>); | 1027 Expect.isTrue(array is List<double>); |
724 Expect.equals(10, array.length); | 1028 Expect.equals(10, array.length); |
725 Expect.equals(8, array.elementSizeInBytes); | 1029 Expect.equals(8, array.elementSizeInBytes); |
726 Expect.equals(80, array.lengthInBytes); | 1030 Expect.equals(80, array.lengthInBytes); |
727 Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0, | 1031 Expect |
728 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); |
729 array); | 1033 Expect.throws(() { |
730 Expect.throws(() { array[-1] = 0.0; }, | 1034 array[-1] = 0.0; |
731 (e) { return e is RangeError; }); | 1035 }, (e) { |
732 Expect.throws(() { return array[-1]; }, | 1036 return e is RangeError; |
733 (e) { return e is RangeError; }); | 1037 }); |
734 Expect.throws(() { array[10]; }, | 1038 Expect.throws(() { |
735 (e) { return e is RangeError; }); | 1039 return array[-1]; |
736 Expect.throws(() { array[10] = 0.0; }, | 1040 }, (e) { |
737 (e) { return e is RangeError; }); | 1041 return e is RangeError; |
738 Expect.throws(() { array.add(0.0); }, | 1042 }); |
739 (e) { return e is UnsupportedError; }); | 1043 Expect.throws(() { |
740 Expect.throws(() { array.addAll([0]); }, | 1044 array[10]; |
741 (e) { return e is UnsupportedError; }); | 1045 }, (e) { |
742 Expect.throws(() { array.clear(); }, | 1046 return e is RangeError; |
743 (e) { return e is UnsupportedError; }); | 1047 }); |
744 Expect.throws(() { array.length = 0; }, | 1048 Expect.throws(() { |
745 (e) { return e is UnsupportedError; }); | 1049 array[10] = 0.0; |
746 Expect.throws(() { array.removeLast(); }, | 1050 }, (e) { |
747 (e) { return e is UnsupportedError; }); | 1051 return e is RangeError; |
748 Expect.throws(() { array.removeRange(0, array.length - 1); }, | 1052 }); |
749 (e) { return e is UnsupportedError; }); | 1053 Expect.throws(() { |
| 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 }); |
750 for (int i = 0; i < array.length; ++i) { | 1083 for (int i = 0; i < array.length; ++i) { |
751 array[i] = 1.0 + i; | 1084 array[i] = 1.0 + i; |
752 } | 1085 } |
753 Expect.listEquals([1.0, 2.0, 3.0, 4.0, 5.0, | 1086 Expect |
754 6.0, 7.0, 8.0, 9.0, 10.0], | 1087 .listEquals([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], array); |
755 array); | |
756 // TODO: min, max | 1088 // TODO: min, max |
757 for (int i = 0; i < array.length; ++i) { | 1089 for (int i = 0; i < array.length; ++i) { |
758 array[i] = i * 1.0; | 1090 array[i] = i * 1.0; |
759 } | 1091 } |
760 var copy = array.sublist(0, array.length); | 1092 var copy = array.sublist(0, array.length); |
761 Expect.isFalse(identical(copy, array)); | 1093 Expect.isFalse(identical(copy, array)); |
762 Expect.isTrue(copy is Float64List); | 1094 Expect.isTrue(copy is Float64List); |
763 Expect.equals(10, copy.length); | 1095 Expect.equals(10, copy.length); |
764 Expect.listEquals(array, copy); | 1096 Expect.listEquals(array, copy); |
765 var empty = array.sublist(array.length, array.length); | 1097 var empty = array.sublist(array.length, array.length); |
766 Expect.equals(0, empty.length); | 1098 Expect.equals(0, empty.length); |
767 var region = array.sublist(3, array.length - 3); | 1099 var region = array.sublist(3, array.length - 3); |
768 Expect.isTrue(copy is Float64List); | 1100 Expect.isTrue(copy is Float64List); |
769 Expect.equals(4, region.length); | 1101 Expect.equals(4, region.length); |
770 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 1102 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
771 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 1103 array.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
772 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 1104 Expect.listEquals([ |
773 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 1105 0.0, |
774 array); | 1106 1.0, |
| 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); |
775 } | 1116 } |
776 | 1117 |
777 static testFloat64List() { | 1118 static testFloat64List() { |
778 Expect.throws(() { new Float64List(-1); }, | 1119 Expect.throws(() { |
779 (e) { return e is ArgumentError; }); | 1120 new Float64List(-1); |
| 1121 }, (e) { |
| 1122 return e is ArgumentError; |
| 1123 }); |
780 var array = new Float64List(10); | 1124 var array = new Float64List(10); |
781 testFloat64ListImpl(array); | 1125 testFloat64ListImpl(array); |
782 } | 1126 } |
783 | 1127 |
784 static testInt8ListViewImpl(var array) { | 1128 static testInt8ListViewImpl(var array) { |
785 Expect.equals(12, array.length); | 1129 Expect.equals(12, array.length); |
786 Expect.equals(1, array.elementSizeInBytes); | 1130 Expect.equals(1, array.elementSizeInBytes); |
787 Expect.equals(12, array.lengthInBytes); | 1131 Expect.equals(12, array.lengthInBytes); |
788 for (int i = 0; i < array.length; ++i) { | 1132 for (int i = 0; i < array.length; ++i) { |
789 array[i] = 0xFF; | 1133 array[i] = 0xFF; |
790 } | 1134 } |
791 Expect.throws(() { new Int8List.view(array.buffer, -1); }, | 1135 Expect.throws(() { |
792 (e) { return e is RangeError; }); | 1136 new Int8List.view(array.buffer, -1); |
793 Expect.throws(() { new Int8List.view(array.buffer, 0, -1); }, | 1137 }, (e) { |
794 (e) { return e is RangeError; }); | 1138 return e is RangeError; |
795 Expect.throws(() { new Int8List.view(array.buffer, | 1139 }); |
796 array.lengthInBytes + 1); }, | 1140 Expect.throws(() { |
797 (e) { return e is RangeError; }); | 1141 new Int8List.view(array.buffer, 0, -1); |
798 Expect.throws(() { new Int8List.view(array.buffer, | 1142 }, (e) { |
799 0, array.length + 1); }, | 1143 return e is RangeError; |
800 (e) { return e is RangeError; }); | 1144 }); |
801 Expect.throws(() { new Int8List.view(array.buffer, | 1145 Expect.throws(() { |
802 array.length - 1, 2); }, | 1146 new Int8List.view(array.buffer, array.lengthInBytes + 1); |
803 (e) { return e is RangeError; }); | 1147 }, (e) { |
804 var empty = new Int8List.view(array.buffer, | 1148 return e is RangeError; |
805 array.lengthInBytes); | 1149 }); |
| 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); |
806 Expect.isTrue(empty is List<int>); | 1161 Expect.isTrue(empty is List<int>); |
807 Expect.isTrue(empty is Int8List); | 1162 Expect.isTrue(empty is Int8List); |
808 Expect.equals(0, empty.length); | 1163 Expect.equals(0, empty.length); |
809 var whole = new Int8List.view(array.buffer); | 1164 var whole = new Int8List.view(array.buffer); |
810 Expect.isTrue(whole is List<int>); | 1165 Expect.isTrue(whole is List<int>); |
811 Expect.isTrue(whole is Int8List); | 1166 Expect.isTrue(whole is Int8List); |
812 Expect.equals(12, whole.length); | 1167 Expect.equals(12, whole.length); |
813 var view = new Int8List.view(array.buffer, 1, array.length - 2); | 1168 var view = new Int8List.view(array.buffer, 1, array.length - 2); |
814 Expect.isTrue(view is List<int>); | 1169 Expect.isTrue(view is List<int>); |
815 Expect.isTrue(view is Int8List); | 1170 Expect.isTrue(view is Int8List); |
816 Expect.equals(10, view.length); | 1171 Expect.equals(10, view.length); |
817 Expect.equals(1, view.elementSizeInBytes); | 1172 Expect.equals(1, view.elementSizeInBytes); |
818 Expect.equals(10, view.lengthInBytes); | 1173 Expect.equals(10, view.lengthInBytes); |
819 Expect.listEquals([-1, -1, -1, -1, -1, | 1174 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], view); |
820 -1, -1, -1, -1, -1], | 1175 Expect.throws(() { |
821 view); | 1176 view[-1] = 0; |
822 Expect.throws(() { view[-1] = 0; }, | 1177 }, (e) { |
823 (e) { return e is RangeError; }); | 1178 return e is RangeError; |
824 Expect.throws(() { return view[-1]; }, | 1179 }); |
825 (e) { return e is RangeError; }); | 1180 Expect.throws(() { |
826 Expect.throws(() { view[view.length]; }, | 1181 return view[-1]; |
827 (e) { return e is RangeError; }); | 1182 }, (e) { |
828 Expect.throws(() { view[10] = 0; }, | 1183 return e is RangeError; |
829 (e) { return e is RangeError; }); | 1184 }); |
830 Expect.throws(() { view.add(0); }, | 1185 Expect.throws(() { |
831 (e) { return e is UnsupportedError; }); | 1186 view[view.length]; |
832 Expect.throws(() { view.addAll([0]); }, | 1187 }, (e) { |
833 (e) { return e is UnsupportedError; }); | 1188 return e is RangeError; |
834 Expect.throws(() { view.clear(); }, | 1189 }); |
835 (e) { return e is UnsupportedError; }); | 1190 Expect.throws(() { |
836 Expect.throws(() { view.length = 0; }, | 1191 view[10] = 0; |
837 (e) { return e is UnsupportedError; }); | 1192 }, (e) { |
838 Expect.throws(() { view.removeLast(); }, | 1193 return e is RangeError; |
839 (e) { return e is UnsupportedError; }); | 1194 }); |
840 Expect.throws(() { view.removeRange(0, view.length - 1); }, | 1195 Expect.throws(() { |
841 (e) { return e is UnsupportedError; }); | 1196 view.add(0); |
| 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 }); |
842 for (int i = 0; i < view.length; ++i) { | 1225 for (int i = 0; i < view.length; ++i) { |
843 view[i] = 1 + i; | 1226 view[i] = 1 + i; |
844 } | 1227 } |
845 Expect.listEquals([1, 2, 3, 4, 5, | 1228 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); |
846 6, 7, 8, 9, 10], | 1229 Expect.listEquals([0xFF, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0xFF], array); |
847 view); | |
848 Expect.listEquals([0xFF, 1, 2, 3, 4, 5, | |
849 6, 7, 8, 9, 10, 0xFF], | |
850 array); | |
851 for (int i = 0; i < view.length; ++i) { | 1230 for (int i = 0; i < view.length; ++i) { |
852 view[i] = 0x100 + i; | 1231 view[i] = 0x100 + i; |
853 } | 1232 } |
854 Expect.listEquals([0, 1, 2, 3, 4, | 1233 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); |
855 5, 6, 7, 8, 9], | 1234 Expect.listEquals([0xFF, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xFF], array); |
856 view); | |
857 Expect.listEquals([0xFF, 0, 1, 2, 3, 4, | |
858 5, 6, 7, 8, 9, 0xFF], | |
859 array); | |
860 for (int i = 0; i < view.length; ++i) { | 1235 for (int i = 0; i < view.length; ++i) { |
861 view[i] = -10 + i; | 1236 view[i] = -10 + i; |
862 } | 1237 } |
863 Expect.listEquals([-10, -9, -8, -7, -6, | 1238 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], view); |
864 -5, -4, -3, -2, -1], | 1239 Expect.listEquals([ |
865 view); | 1240 0xFF, |
866 Expect.listEquals([0xFF, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, | 1241 0xF6, |
867 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0xFF], | 1242 0xF7, |
868 array); | 1243 0xF8, |
| 1244 0xF9, |
| 1245 0xFA, |
| 1246 0xFB, |
| 1247 0xFC, |
| 1248 0xFD, |
| 1249 0xFE, |
| 1250 0xFF, |
| 1251 0xFF |
| 1252 ], array); |
869 for (int i = 0; i < view.length; ++i) { | 1253 for (int i = 0; i < view.length; ++i) { |
870 view[i] = 0x7F - i; | 1254 view[i] = 0x7F - i; |
871 } | 1255 } |
872 Expect.listEquals([127, 126, 125, 124, 123, | 1256 Expect.listEquals([127, 126, 125, 124, 123, 122, 121, 120, 119, 118], view); |
873 122, 121, 120, 119, 118], | 1257 Expect.listEquals( |
874 view); | 1258 [0xFF, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 0xFF], array); |
875 Expect.listEquals([0xFF, 127, 126, 125, 124, 123, | |
876 122, 121, 120, 119, 118, 0xFF], | |
877 array); | |
878 for (int i = 0; i < view.length; ++i) { | 1259 for (int i = 0; i < view.length; ++i) { |
879 view[i] = -0x80 + i; | 1260 view[i] = -0x80 + i; |
880 } | 1261 } |
881 Expect.listEquals([-128, -127, -126, -125, -124, | 1262 Expect.listEquals( |
882 -123, -122, -121, -120, -119], | 1263 [-128, -127, -126, -125, -124, -123, -122, -121, -120, -119], view); |
883 view); | 1264 Expect.listEquals([ |
884 Expect.listEquals([0xFF, 0x80, 0x81, 0x82, 0x83, 0x84, | 1265 0xFF, |
885 0x85, 0x86, 0x87, 0x88, 0x89, 0xFF], | 1266 0x80, |
886 array); | 1267 0x81, |
| 1268 0x82, |
| 1269 0x83, |
| 1270 0x84, |
| 1271 0x85, |
| 1272 0x86, |
| 1273 0x87, |
| 1274 0x88, |
| 1275 0x89, |
| 1276 0xFF |
| 1277 ], array); |
887 for (int i = 0; i < view.length; ++i) { | 1278 for (int i = 0; i < view.length; ++i) { |
888 view[i] = i; | 1279 view[i] = i; |
889 } | 1280 } |
890 var copy = view.sublist(0, view.length); | 1281 var copy = view.sublist(0, view.length); |
891 Expect.isFalse(identical(copy, view)); | 1282 Expect.isFalse(identical(copy, view)); |
892 Expect.isTrue(copy is Int8List); | 1283 Expect.isTrue(copy is Int8List); |
893 Expect.equals(10, copy.length); | 1284 Expect.equals(10, copy.length); |
894 Expect.listEquals(view, copy); | 1285 Expect.listEquals(view, copy); |
895 var region = view.sublist(3, view.length - 3); | 1286 var region = view.sublist(3, view.length - 3); |
896 Expect.isTrue(copy is Int8List); | 1287 Expect.isTrue(copy is Int8List); |
897 Expect.equals(4, region.length); | 1288 Expect.equals(4, region.length); |
898 Expect.listEquals([3, 4, 5, 6], region); | 1289 Expect.listEquals([3, 4, 5, 6], region); |
899 view.setRange(3, 7, [-128, 0, 1, 127]); | 1290 view.setRange(3, 7, [-128, 0, 1, 127]); |
900 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], | 1291 Expect.listEquals([0, 1, 2, -128, 0, 1, 127, 7, 8, 9], view); |
901 view); | 1292 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF], array); |
902 Expect.listEquals([0xFF, 0, 1, 2, 128, 0, 1, 127, 7, 8, 9, 0xFF], | |
903 array); | |
904 } | 1293 } |
| 1294 |
905 static testInt8ListView() { | 1295 static testInt8ListView() { |
906 var array = new Uint8List(12); | 1296 var array = new Uint8List(12); |
907 testInt8ListViewImpl(array); | 1297 testInt8ListViewImpl(array); |
908 } | 1298 } |
909 | 1299 |
910 static testUint8ListViewImpl(var array) { | 1300 static testUint8ListViewImpl(var array) { |
911 Expect.isTrue(array is List<int>); | 1301 Expect.isTrue(array is List<int>); |
912 Expect.equals(12, array.length); | 1302 Expect.equals(12, array.length); |
913 Expect.equals(1, array.elementSizeInBytes); | 1303 Expect.equals(1, array.elementSizeInBytes); |
914 Expect.equals(12, array.lengthInBytes); | 1304 Expect.equals(12, array.lengthInBytes); |
915 for (int i = 0; i < array.length; ++i) { | 1305 for (int i = 0; i < array.length; ++i) { |
916 array[i] = -1; | 1306 array[i] = -1; |
917 } | 1307 } |
918 Expect.throws(() { new Uint8List.view(array.buffer, -1); }, | 1308 Expect.throws(() { |
919 (e) { return e is RangeError; }); | 1309 new Uint8List.view(array.buffer, -1); |
920 Expect.throws(() { new Uint8List.view(array.buffer, 0, -1); }, | 1310 }, (e) { |
921 (e) { return e is RangeError; }); | 1311 return e is RangeError; |
922 Expect.throws(() { new Uint8List.view(array.buffer, | 1312 }); |
923 array.lengthInBytes + 1); }, | 1313 Expect.throws(() { |
924 (e) { return e is RangeError; }); | 1314 new Uint8List.view(array.buffer, 0, -1); |
925 Expect.throws(() { new Uint8List.view(array.buffer, | 1315 }, (e) { |
926 0, array.length + 1); }, | 1316 return e is RangeError; |
927 (e) { return e is RangeError; }); | 1317 }); |
928 Expect.throws(() { new Uint8List.view(array.buffer, | 1318 Expect.throws(() { |
929 array.length - 1, 2); }, | 1319 new Uint8List.view(array.buffer, array.lengthInBytes + 1); |
930 (e) { return e is RangeError; }); | 1320 }, (e) { |
931 var empty = new Uint8List.view(array.buffer, | 1321 return e is RangeError; |
932 array.lengthInBytes); | 1322 }); |
| 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); |
933 Expect.isTrue(empty is List<int>); | 1334 Expect.isTrue(empty is List<int>); |
934 Expect.isTrue(empty is Uint8List); | 1335 Expect.isTrue(empty is Uint8List); |
935 Expect.equals(0, empty.length); | 1336 Expect.equals(0, empty.length); |
936 var whole = new Uint8List.view(array.buffer); | 1337 var whole = new Uint8List.view(array.buffer); |
937 Expect.isTrue(whole is List<int>); | 1338 Expect.isTrue(whole is List<int>); |
938 Expect.isTrue(whole is Uint8List); | 1339 Expect.isTrue(whole is Uint8List); |
939 Expect.equals(12, whole.length); | 1340 Expect.equals(12, whole.length); |
940 var view = new Uint8List.view(array.buffer, 1, array.length - 2); | 1341 var view = new Uint8List.view(array.buffer, 1, array.length - 2); |
941 Expect.isTrue(view is List<int>); | 1342 Expect.isTrue(view is List<int>); |
942 Expect.isTrue(view is Uint8List); | 1343 Expect.isTrue(view is Uint8List); |
943 Expect.equals(10, view.length); | 1344 Expect.equals(10, view.length); |
944 Expect.equals(1, view.elementSizeInBytes); | 1345 Expect.equals(1, view.elementSizeInBytes); |
945 Expect.equals(10, view.lengthInBytes); | 1346 Expect.equals(10, view.lengthInBytes); |
946 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 1347 Expect.listEquals( |
947 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 1348 [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], view); |
948 view); | 1349 Expect.throws(() { |
949 Expect.throws(() { view[-1] = 0; }, | 1350 view[-1] = 0; |
950 (e) { return e is RangeError; }); | 1351 }, (e) { |
951 Expect.throws(() { return view[-1]; }, | 1352 return e is RangeError; |
952 (e) { return e is RangeError; }); | 1353 }); |
953 Expect.throws(() { view[view.length]; }, | 1354 Expect.throws(() { |
954 (e) { return e is RangeError; }); | 1355 return view[-1]; |
955 Expect.throws(() { view[view.length] = 0; }, | 1356 }, (e) { |
956 (e) { return e is RangeError; }); | 1357 return e is RangeError; |
957 Expect.throws(() { view.add(0); }, | 1358 }); |
958 (e) { return e is UnsupportedError; }); | 1359 Expect.throws(() { |
959 Expect.throws(() { view.addAll([0]); }, | 1360 view[view.length]; |
960 (e) { return e is UnsupportedError; }); | 1361 }, (e) { |
961 Expect.throws(() { view.clear(); }, | 1362 return e is RangeError; |
962 (e) { return e is UnsupportedError; }); | 1363 }); |
963 Expect.throws(() { view.length = 0; }, | 1364 Expect.throws(() { |
964 (e) { return e is UnsupportedError; }); | 1365 view[view.length] = 0; |
965 Expect.throws(() { view.removeLast(); }, | 1366 }, (e) { |
966 (e) { return e is UnsupportedError; }); | 1367 return e is RangeError; |
967 Expect.throws(() { view.removeRange(0, view.length - 1); }, | 1368 }); |
968 (e) { return e is UnsupportedError; }); | 1369 Expect.throws(() { |
| 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 }); |
969 for (int i = 0; i < view.length; ++i) { | 1399 for (int i = 0; i < view.length; ++i) { |
970 view[i] = 1 + i; | 1400 view[i] = 1 + i; |
971 } | 1401 } |
972 Expect.listEquals([1, 2, 3, 4, 5, | 1402 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); |
973 6, 7, 8, 9, 10], | 1403 Expect.listEquals([-1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1], array); |
974 view); | |
975 Expect.listEquals([-1, 1, 2, 3, 4, 5, | |
976 6, 7, 8, 9, 10, -1], | |
977 array); | |
978 for (int i = 0; i < view.length; ++i) { | 1404 for (int i = 0; i < view.length; ++i) { |
979 view[i] = 0x100 + i; | 1405 view[i] = 0x100 + i; |
980 } | 1406 } |
981 Expect.listEquals([0, 1, 2, 3, 4, | 1407 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); |
982 5, 6, 7, 8, 9], | 1408 Expect.listEquals([-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1], array); |
983 view); | |
984 Expect.listEquals([-1, 0, 1, 2, 3, 4, | |
985 5, 6, 7, 8, 9, -1], | |
986 array); | |
987 for (int i = 0; i < view.length; ++i) { | 1409 for (int i = 0; i < view.length; ++i) { |
988 view[i] = 0xFF - i; | 1410 view[i] = 0xFF - i; |
989 } | 1411 } |
990 Expect.listEquals([0xFF, 0xFE, 0xFD, 0xFC, 0xFB, | 1412 Expect.listEquals( |
991 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], | 1413 [0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8, 0xF7, 0xF6], view); |
992 view); | 1414 Expect.listEquals([-1, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -1], array); |
993 Expect.listEquals([-1, -1, -2, -3, -4, -5, | |
994 -6, -7, -8, -9, -10, -1], | |
995 array); | |
996 for (int i = 0; i < view.length; ++i) { | 1415 for (int i = 0; i < view.length; ++i) { |
997 view[i] = i; | 1416 view[i] = i; |
998 } | 1417 } |
999 var copy = view.sublist(0, view.length); | 1418 var copy = view.sublist(0, view.length); |
1000 Expect.isFalse(identical(copy, view)); | 1419 Expect.isFalse(identical(copy, view)); |
1001 Expect.isTrue(copy is Uint8List); | 1420 Expect.isTrue(copy is Uint8List); |
1002 Expect.equals(10, copy.length); | 1421 Expect.equals(10, copy.length); |
1003 Expect.listEquals(view, copy); | 1422 Expect.listEquals(view, copy); |
1004 var region = view.sublist(3, view.length - 3); | 1423 var region = view.sublist(3, view.length - 3); |
1005 Expect.isTrue(copy is Uint8List); | 1424 Expect.isTrue(copy is Uint8List); |
1006 Expect.equals(4, region.length); | 1425 Expect.equals(4, region.length); |
1007 Expect.listEquals([3, 4, 5, 6], region); | 1426 Expect.listEquals([3, 4, 5, 6], region); |
1008 view.setRange(3, 7, [257, 0, 1, 255]); | 1427 view.setRange(3, 7, [257, 0, 1, 255]); |
1009 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], | 1428 Expect.listEquals([0, 1, 2, 1, 0, 1, 255, 7, 8, 9], view); |
1010 view); | |
1011 } | 1429 } |
1012 | 1430 |
1013 static testUint8ListView() { | 1431 static testUint8ListView() { |
1014 var array = new Int8List(12); | 1432 var array = new Int8List(12); |
1015 testUint8ListViewImpl(array); | 1433 testUint8ListViewImpl(array); |
1016 } | 1434 } |
1017 | 1435 |
1018 static testInt16ListViewImpl(var array) { | 1436 static testInt16ListViewImpl(var array) { |
1019 Expect.equals(24, array.length); | 1437 Expect.equals(24, array.length); |
1020 Expect.equals(1, array.elementSizeInBytes); | 1438 Expect.equals(1, array.elementSizeInBytes); |
1021 Expect.equals(24, array.lengthInBytes); | 1439 Expect.equals(24, array.lengthInBytes); |
1022 for (int i = 0; i < array.length; ++i) { | 1440 for (int i = 0; i < array.length; ++i) { |
1023 array[i] = 0xFF; | 1441 array[i] = 0xFF; |
1024 } | 1442 } |
1025 Expect.throws(() { new Int16List.view(array.buffer, -1); }, | 1443 Expect.throws(() { |
1026 (e) { return e is RangeError; }); | 1444 new Int16List.view(array.buffer, -1); |
1027 Expect.throws(() { new Int16List.view(array.buffer, 0, -1); }, | 1445 }, (e) { |
1028 (e) { return e is RangeError; }); | 1446 return e is RangeError; |
1029 Expect.throws(() { new Int16List.view(array.buffer, | 1447 }); |
1030 array.lengthInBytes + 1); }, | 1448 Expect.throws(() { |
1031 (e) { return e is RangeError; }); | 1449 new Int16List.view(array.buffer, 0, -1); |
1032 Expect.throws(() { new Int16List.view(array.buffer, | 1450 }, (e) { |
1033 0, array.length + 1); }, | 1451 return e is RangeError; |
1034 (e) { return e is RangeError; }); | 1452 }); |
1035 Expect.throws(() { new Int16List.view(array.buffer, | 1453 Expect.throws(() { |
1036 array.length - 1, 2); }, | 1454 new Int16List.view(array.buffer, array.lengthInBytes + 1); |
1037 (e) { return e is RangeError; }); | 1455 }, (e) { |
1038 var empty = new Int16List.view(array.buffer, | 1456 return e is RangeError; |
1039 array.lengthInBytes); | 1457 }); |
| 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); |
1040 Expect.isTrue(empty is List<int>); | 1469 Expect.isTrue(empty is List<int>); |
1041 Expect.isTrue(empty is Int16List); | 1470 Expect.isTrue(empty is Int16List); |
1042 Expect.equals(0, empty.length); | 1471 Expect.equals(0, empty.length); |
1043 var whole = new Int16List.view(array.buffer); | 1472 var whole = new Int16List.view(array.buffer); |
1044 Expect.isTrue(whole is List<int>); | 1473 Expect.isTrue(whole is List<int>); |
1045 Expect.isTrue(whole is Int16List); | 1474 Expect.isTrue(whole is Int16List); |
1046 Expect.equals(12, whole.length); | 1475 Expect.equals(12, whole.length); |
1047 var view = new Int16List.view(array.buffer, 2, 10); | 1476 var view = new Int16List.view(array.buffer, 2, 10); |
1048 Expect.isTrue(view is List<int>); | 1477 Expect.isTrue(view is List<int>); |
1049 Expect.isTrue(view is Int16List); | 1478 Expect.isTrue(view is Int16List); |
1050 Expect.equals(10, view.length); | 1479 Expect.equals(10, view.length); |
1051 Expect.equals(2, view.elementSizeInBytes); | 1480 Expect.equals(2, view.elementSizeInBytes); |
1052 Expect.equals(20, view.lengthInBytes); | 1481 Expect.equals(20, view.lengthInBytes); |
1053 Expect.listEquals([-1, -1, -1, -1, -1, | 1482 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], view); |
1054 -1, -1, -1, -1, -1], | 1483 Expect.throws(() { |
1055 view); | 1484 view[-1] = 0; |
1056 Expect.throws(() { view[-1] = 0; }, | 1485 }, (e) { |
1057 (e) { return e is RangeError; }); | 1486 return e is RangeError; |
1058 Expect.throws(() { return view[-1]; }, | 1487 }); |
1059 (e) { return e is RangeError; }); | 1488 Expect.throws(() { |
1060 Expect.throws(() { view[view.length]; }, | 1489 return view[-1]; |
1061 (e) { return e is RangeError; }); | 1490 }, (e) { |
1062 Expect.throws(() { view[10] = 0; }, | 1491 return e is RangeError; |
1063 (e) { return e is RangeError; }); | 1492 }); |
1064 Expect.throws(() { view.add(0); }, | 1493 Expect.throws(() { |
1065 (e) { return e is UnsupportedError; }); | 1494 view[view.length]; |
1066 Expect.throws(() { view.addAll([0]); }, | 1495 }, (e) { |
1067 (e) { return e is UnsupportedError; }); | 1496 return e is RangeError; |
1068 Expect.throws(() { view.clear(); }, | 1497 }); |
1069 (e) { return e is UnsupportedError; }); | 1498 Expect.throws(() { |
1070 Expect.throws(() { view.length = 0; }, | 1499 view[10] = 0; |
1071 (e) { return e is UnsupportedError; }); | 1500 }, (e) { |
1072 Expect.throws(() { view.removeLast(); }, | 1501 return e is RangeError; |
1073 (e) { return e is UnsupportedError; }); | 1502 }); |
1074 Expect.throws(() { view.removeRange(0, view.length - 1); }, | 1503 Expect.throws(() { |
1075 (e) { return e is UnsupportedError; }); | 1504 view.add(0); |
| 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 }); |
1076 for (int i = 0; i < view.length; ++i) { | 1533 for (int i = 0; i < view.length; ++i) { |
1077 view[i] = 1 + i; | 1534 view[i] = 1 + i; |
1078 } | 1535 } |
1079 Expect.listEquals([1, 2, 3, 4, 5, | 1536 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); |
1080 6, 7, 8, 9, 10], | 1537 Expect.listEquals([ |
1081 view); | 1538 0xFF, |
1082 Expect.listEquals([0xFF, 0xFF, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, | 1539 0xFF, |
1083 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, | 1540 0x01, |
1084 0x08, 0x00, 0x09, 0x00, 0x0A, 0x00, 0xFF, 0xFF], | 1541 0x00, |
1085 array); | 1542 0x02, |
| 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); |
1086 for (int i = 0; i < view.length; ++i) { | 1563 for (int i = 0; i < view.length; ++i) { |
1087 view[i] = 0x10000 + i; | 1564 view[i] = 0x10000 + i; |
1088 } | 1565 } |
1089 Expect.listEquals([0, 1, 2, 3, 4, | 1566 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); |
1090 5, 6, 7, 8, 9], | 1567 Expect.listEquals([ |
1091 view); | 1568 0xFF, |
1092 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, | 1569 0xFF, |
1093 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, | 1570 0x00, |
1094 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], | 1571 0x00, |
1095 array); | 1572 0x01, |
| 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); |
1096 for (int i = 0; i < view.length; ++i) { | 1593 for (int i = 0; i < view.length; ++i) { |
1097 view[i] = -10 + i; | 1594 view[i] = -10 + i; |
1098 } | 1595 } |
1099 Expect.listEquals([-10, -9, -8, -7, -6, | 1596 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], view); |
1100 -5, -4, -3, -2, -1], | 1597 Expect.listEquals([ |
1101 view); | 1598 0xFF, |
1102 Expect.listEquals([0xFF, 0xFF, 0xF6, 0xFF, 0xF7, 0xFF, 0xF8, 0xFF, | 1599 0xFF, |
1103 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, | 1600 0xF6, |
1104 0xFD, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 1601 0xFF, |
1105 array); | 1602 0xF7, |
| 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); |
1106 for (int i = 0; i < view.length; ++i) { | 1623 for (int i = 0; i < view.length; ++i) { |
1107 view[i] = 0x7FFF - i; | 1624 view[i] = 0x7FFF - i; |
1108 } | 1625 } |
1109 Expect.listEquals([0x7FFF, 0x7FFE, 0x7FFD, 0x7FFC, 0x7FFB, | 1626 Expect.listEquals([ |
1110 0x7FFA, 0x7FF9, 0x7FF8, 0x7FF7, 0x7FF6], | 1627 0x7FFF, |
1111 view); | 1628 0x7FFE, |
1112 Expect.listEquals([0xFF, 0xFF, 0xFF, 0x7F, 0xFE, 0x7F, 0xFD, 0x7F, | 1629 0x7FFD, |
1113 0xFC, 0x7F, 0xFB, 0x7F, 0xFA, 0x7F, 0xF9, 0x7F, | 1630 0x7FFC, |
1114 0xF8, 0x7F, 0xF7, 0x7F, 0xF6, 0x7F, 0xFF, 0xFF], | 1631 0x7FFB, |
1115 array); | 1632 0x7FFA, |
| 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); |
1116 for (int i = 0; i < view.length; ++i) { | 1664 for (int i = 0; i < view.length; ++i) { |
1117 view[i] = -0x8000 + i; | 1665 view[i] = -0x8000 + i; |
1118 } | 1666 } |
1119 Expect.listEquals([-0x8000, -0x7FFF, -0x7FFE, -0x7FFD, -0x7FFC, | 1667 Expect.listEquals([ |
1120 -0x7FFB, -0x7FFA, -0x7FF9, -0x7FF8, -0x7FF7], | 1668 -0x8000, |
1121 view); | 1669 -0x7FFF, |
1122 Expect.listEquals([0xFF, 0xFF, 0x00, 0x80, 0x01, 0x80, 0x02, 0x80, | 1670 -0x7FFE, |
1123 0x03, 0x80, 0x04, 0x80, 0x05, 0x80, 0x06, 0x80, | 1671 -0x7FFD, |
1124 0x07, 0x80, 0x08, 0x80, 0x09, 0x80, 0xFF, 0xFF], | 1672 -0x7FFC, |
1125 array); | 1673 -0x7FFB, |
| 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); |
1126 for (int i = 0; i < view.length; ++i) { | 1705 for (int i = 0; i < view.length; ++i) { |
1127 view[i] = i; | 1706 view[i] = i; |
1128 } | 1707 } |
1129 var copy = view.sublist(0, view.length); | 1708 var copy = view.sublist(0, view.length); |
1130 Expect.isFalse(identical(copy, view)); | 1709 Expect.isFalse(identical(copy, view)); |
1131 Expect.isTrue(copy is Int16List); | 1710 Expect.isTrue(copy is Int16List); |
1132 Expect.equals(10, copy.length); | 1711 Expect.equals(10, copy.length); |
1133 Expect.listEquals(view, copy); | 1712 Expect.listEquals(view, copy); |
1134 var region = view.sublist(3, view.length - 3); | 1713 var region = view.sublist(3, view.length - 3); |
1135 Expect.isTrue(copy is Int16List); | 1714 Expect.isTrue(copy is Int16List); |
1136 Expect.equals(4, region.length); | 1715 Expect.equals(4, region.length); |
1137 Expect.listEquals([3, 4, 5, 6], region); | 1716 Expect.listEquals([3, 4, 5, 6], region); |
1138 view.setRange(3, 7, [-32768, 0, 1, 32767]); | 1717 view.setRange(3, 7, [-32768, 0, 1, 32767]); |
1139 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], | 1718 Expect.listEquals([0, 1, 2, -32768, 0, 1, 32767, 7, 8, 9], view); |
1140 view); | 1719 Expect.listEquals([ |
1141 Expect.listEquals([0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, | 1720 0xFF, |
1142 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0xFF, 0x7F, | 1721 0xFF, |
1143 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0xFF, 0xFF], | 1722 0x00, |
1144 array); | 1723 0x00, |
| 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); |
1145 } | 1745 } |
1146 | 1746 |
1147 static testInt16ListView() { | 1747 static testInt16ListView() { |
1148 var array = new Uint8List(24); | 1748 var array = new Uint8List(24); |
1149 testInt16ListViewImpl(array); | 1749 testInt16ListViewImpl(array); |
1150 } | 1750 } |
1151 | 1751 |
1152 static testUint16ListViewImpl(var array) { | 1752 static testUint16ListViewImpl(var array) { |
1153 Expect.isTrue(array is List<int>); | 1753 Expect.isTrue(array is List<int>); |
1154 Expect.equals(24, array.length); | 1754 Expect.equals(24, array.length); |
1155 Expect.equals(1, array.elementSizeInBytes); | 1755 Expect.equals(1, array.elementSizeInBytes); |
1156 Expect.equals(24, array.lengthInBytes); | 1756 Expect.equals(24, array.lengthInBytes); |
1157 for (int i = 0; i < array.length; ++i) { | 1757 for (int i = 0; i < array.length; ++i) { |
1158 array[i] = -1; | 1758 array[i] = -1; |
1159 } | 1759 } |
1160 Expect.throws(() { new Uint16List.view(array.buffer, -1); }, | 1760 Expect.throws(() { |
1161 (e) { return e is RangeError; }); | 1761 new Uint16List.view(array.buffer, -1); |
1162 Expect.throws(() { new Uint16List.view(array.buffer, 0, -1); }, | 1762 }, (e) { |
1163 (e) { return e is RangeError; }); | 1763 return e is RangeError; |
1164 Expect.throws(() { new Uint16List.view(array.buffer, | 1764 }); |
1165 array.lengthInBytes + 1); }, | 1765 Expect.throws(() { |
1166 (e) { return e is RangeError; }); | 1766 new Uint16List.view(array.buffer, 0, -1); |
1167 Expect.throws(() { new Uint16List.view(array.buffer, | 1767 }, (e) { |
1168 0, array.length + 1); }, | 1768 return e is RangeError; |
1169 (e) { return e is RangeError; }); | 1769 }); |
1170 Expect.throws(() { new Uint16List.view(array.buffer, | 1770 Expect.throws(() { |
1171 array.length - 1, 2); }, | 1771 new Uint16List.view(array.buffer, array.lengthInBytes + 1); |
1172 (e) { return e is RangeError; }); | 1772 }, (e) { |
1173 var empty = new Uint16List.view(array.buffer, | 1773 return e is RangeError; |
1174 array.lengthInBytes); | 1774 }); |
| 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); |
1175 Expect.isTrue(empty is List<int>); | 1786 Expect.isTrue(empty is List<int>); |
1176 Expect.isTrue(empty is Uint16List); | 1787 Expect.isTrue(empty is Uint16List); |
1177 Expect.equals(0, empty.length); | 1788 Expect.equals(0, empty.length); |
1178 var whole = new Uint16List.view(array.buffer); | 1789 var whole = new Uint16List.view(array.buffer); |
1179 Expect.isTrue(whole is List<int>); | 1790 Expect.isTrue(whole is List<int>); |
1180 Expect.isTrue(whole is Uint16List); | 1791 Expect.isTrue(whole is Uint16List); |
1181 Expect.equals(12, whole.length); | 1792 Expect.equals(12, whole.length); |
1182 var view = new Uint16List.view(array.buffer, 2, 10); | 1793 var view = new Uint16List.view(array.buffer, 2, 10); |
1183 Expect.isTrue(view is List<int>); | 1794 Expect.isTrue(view is List<int>); |
1184 Expect.isTrue(view is Uint16List); | 1795 Expect.isTrue(view is Uint16List); |
1185 Expect.equals(10, view.length); | 1796 Expect.equals(10, view.length); |
1186 Expect.equals(2, view.elementSizeInBytes); | 1797 Expect.equals(2, view.elementSizeInBytes); |
1187 Expect.equals(20, view.lengthInBytes); | 1798 Expect.equals(20, view.lengthInBytes); |
1188 Expect.listEquals([0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, | 1799 Expect.listEquals([ |
1189 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF], | 1800 0xFFFF, |
1190 view); | 1801 0xFFFF, |
1191 Expect.throws(() { view[-1] = 0; }, | 1802 0xFFFF, |
1192 (e) { return e is RangeError; }); | 1803 0xFFFF, |
1193 Expect.throws(() { return view[-1]; }, | 1804 0xFFFF, |
1194 (e) { return e is RangeError; }); | 1805 0xFFFF, |
1195 Expect.throws(() { view[view.length]; }, | 1806 0xFFFF, |
1196 (e) { return e is RangeError; }); | 1807 0xFFFF, |
1197 Expect.throws(() { view[view.length] = 0; }, | 1808 0xFFFF, |
1198 (e) { return e is RangeError; }); | 1809 0xFFFF |
1199 Expect.throws(() { view.add(0); }, | 1810 ], view); |
1200 (e) { return e is UnsupportedError; }); | 1811 Expect.throws(() { |
1201 Expect.throws(() { view.addAll([0]); }, | 1812 view[-1] = 0; |
1202 (e) { return e is UnsupportedError; }); | 1813 }, (e) { |
1203 Expect.throws(() { view.clear(); }, | 1814 return e is RangeError; |
1204 (e) { return e is UnsupportedError; }); | 1815 }); |
1205 Expect.throws(() { view.length = 0; }, | 1816 Expect.throws(() { |
1206 (e) { return e is UnsupportedError; }); | 1817 return view[-1]; |
1207 Expect.throws(() { view.removeLast(); }, | 1818 }, (e) { |
1208 (e) { return e is UnsupportedError; }); | 1819 return e is RangeError; |
1209 Expect.throws(() { view.removeRange(0, view.length - 1); }, | 1820 }); |
1210 (e) { return e is UnsupportedError; }); | 1821 Expect.throws(() { |
| 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 }); |
1211 for (int i = 0; i < view.length; ++i) { | 1861 for (int i = 0; i < view.length; ++i) { |
1212 view[i] = 1 + i; | 1862 view[i] = 1 + i; |
1213 } | 1863 } |
1214 Expect.listEquals([1, 2, 3, 4, 5, | 1864 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); |
1215 6, 7, 8, 9, 10], | 1865 Expect.listEquals([ |
1216 view); | 1866 -1, |
1217 Expect.listEquals([-1, -1, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, | 1867 -1, |
1218 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, -1, -1], | 1868 1, |
1219 array); | 1869 0, |
| 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); |
1220 for (int i = 0; i < view.length; ++i) { | 1891 for (int i = 0; i < view.length; ++i) { |
1221 view[i] = 0x10000 + i; | 1892 view[i] = 0x10000 + i; |
1222 } | 1893 } |
1223 Expect.listEquals([0, 1, 2, 3, 4, | 1894 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); |
1224 5, 6, 7, 8, 9], | 1895 Expect.listEquals([ |
1225 view); | 1896 -1, |
1226 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, | 1897 -1, |
1227 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, -1, -1], | 1898 0, |
1228 array); | 1899 0, |
| 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); |
1229 for (int i = 0; i < view.length; ++i) { | 1921 for (int i = 0; i < view.length; ++i) { |
1230 view[i] = 0xFFFF - i; | 1922 view[i] = 0xFFFF - i; |
1231 } | 1923 } |
1232 Expect.listEquals([0xFFFF, 0xFFFE, 0xFFFD, 0xFFFC, 0xFFFB, | 1924 Expect.listEquals([ |
1233 0xFFFA, 0xFFF9, 0xFFF8, 0xFFF7, 0xFFF6], | 1925 0xFFFF, |
1234 view); | 1926 0xFFFE, |
1235 Expect.listEquals([-1, -1, -1, -1, -2, -1, -3, -1, | 1927 0xFFFD, |
1236 -4, -1, -5, -1, -6, -1, -7, -1, | 1928 0xFFFC, |
1237 -8, -1, -9, -1, -10, -1, -1, -1], | 1929 0xFFFB, |
1238 array); | 1930 0xFFFA, |
| 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); |
1239 for (int i = 0; i < view.length; ++i) { | 1962 for (int i = 0; i < view.length; ++i) { |
1240 view[i] = i; | 1963 view[i] = i; |
1241 } | 1964 } |
1242 var copy = view.sublist(0, view.length); | 1965 var copy = view.sublist(0, view.length); |
1243 Expect.isFalse(identical(copy, view)); | 1966 Expect.isFalse(identical(copy, view)); |
1244 Expect.isTrue(copy is Uint16List); | 1967 Expect.isTrue(copy is Uint16List); |
1245 Expect.equals(10, copy.length); | 1968 Expect.equals(10, copy.length); |
1246 Expect.listEquals(view, copy); | 1969 Expect.listEquals(view, copy); |
1247 var region = view.sublist(3, view.length - 3); | 1970 var region = view.sublist(3, view.length - 3); |
1248 Expect.isTrue(copy is Uint16List); | 1971 Expect.isTrue(copy is Uint16List); |
1249 Expect.equals(4, region.length); | 1972 Expect.equals(4, region.length); |
1250 Expect.listEquals([3, 4, 5, 6], region); | 1973 Expect.listEquals([3, 4, 5, 6], region); |
1251 view.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]); | 1974 view.setRange(3, 7, [0x10001, 0, 1, 0xFFFF]); |
1252 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], | 1975 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFF, 7, 8, 9], view); |
1253 view); | 1976 Expect.listEquals([ |
1254 Expect.listEquals([-1, -1, 0, 0, 1, 0, 2, 0, | 1977 -1, |
1255 1, 0, 0, 0, 1, 0, -1, -1, | 1978 -1, |
1256 7, 0, 8, 0, 9, 0, -1, -1], | 1979 0, |
1257 array); | 1980 0, |
| 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); |
1258 } | 2002 } |
1259 | 2003 |
1260 static testUint16ListView() { | 2004 static testUint16ListView() { |
1261 var array = new Int8List(24); | 2005 var array = new Int8List(24); |
1262 testUint16ListViewImpl(array); | 2006 testUint16ListViewImpl(array); |
1263 } | 2007 } |
1264 | 2008 |
1265 static testInt32ListView() { | 2009 static testInt32ListView() { |
1266 var array = new Uint8List(48); | 2010 var array = new Uint8List(48); |
1267 Expect.equals(48, array.length); | 2011 Expect.equals(48, array.length); |
1268 Expect.equals(1, array.elementSizeInBytes); | 2012 Expect.equals(1, array.elementSizeInBytes); |
1269 Expect.equals(48, array.lengthInBytes); | 2013 Expect.equals(48, array.lengthInBytes); |
1270 for (int i = 0; i < array.length; ++i) { | 2014 for (int i = 0; i < array.length; ++i) { |
1271 array[i] = 0xFF; | 2015 array[i] = 0xFF; |
1272 } | 2016 } |
1273 Expect.throws(() { new Int32List.view(array.buffer, -1); }, | 2017 Expect.throws(() { |
1274 (e) { return e is RangeError; }); | 2018 new Int32List.view(array.buffer, -1); |
1275 Expect.throws(() { new Int32List.view(array.buffer, 0, -1); }, | 2019 }, (e) { |
1276 (e) { return e is RangeError; }); | 2020 return e is RangeError; |
1277 Expect.throws(() { new Int32List.view(array.buffer, | 2021 }); |
1278 array.lengthInBytes + 1); }, | 2022 Expect.throws(() { |
1279 (e) { return e is RangeError; }); | 2023 new Int32List.view(array.buffer, 0, -1); |
1280 Expect.throws(() { new Int32List.view(array.buffer, | 2024 }, (e) { |
1281 0, array.length + 1); }, | 2025 return e is RangeError; |
1282 (e) { return e is RangeError; }); | 2026 }); |
1283 Expect.throws(() { new Int32List.view(array.buffer, | 2027 Expect.throws(() { |
1284 array.length - 1, 2); }, | 2028 new Int32List.view(array.buffer, array.lengthInBytes + 1); |
1285 (e) { return e is RangeError; }); | 2029 }, (e) { |
1286 var empty = new Int32List.view(array.buffer, | 2030 return e is RangeError; |
1287 array.lengthInBytes); | 2031 }); |
| 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); |
1288 Expect.isTrue(empty is List<int>); | 2043 Expect.isTrue(empty is List<int>); |
1289 Expect.isTrue(empty is Int32List); | 2044 Expect.isTrue(empty is Int32List); |
1290 Expect.equals(0, empty.length); | 2045 Expect.equals(0, empty.length); |
1291 var whole = new Int32List.view(array.buffer); | 2046 var whole = new Int32List.view(array.buffer); |
1292 Expect.isTrue(whole is List<int>); | 2047 Expect.isTrue(whole is List<int>); |
1293 Expect.isTrue(whole is Int32List); | 2048 Expect.isTrue(whole is Int32List); |
1294 Expect.equals(12, whole.length); | 2049 Expect.equals(12, whole.length); |
1295 var view = new Int32List.view(array.buffer, 4, 10); | 2050 var view = new Int32List.view(array.buffer, 4, 10); |
1296 Expect.isTrue(view is List<int>); | 2051 Expect.isTrue(view is List<int>); |
1297 Expect.isTrue(view is Int32List); | 2052 Expect.isTrue(view is Int32List); |
1298 Expect.equals(10, view.length); | 2053 Expect.equals(10, view.length); |
1299 Expect.equals(4, view.elementSizeInBytes); | 2054 Expect.equals(4, view.elementSizeInBytes); |
1300 Expect.equals(40, view.lengthInBytes); | 2055 Expect.equals(40, view.lengthInBytes); |
1301 Expect.listEquals([-1, -1, -1, -1, -1, | 2056 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], view); |
1302 -1, -1, -1, -1, -1], | 2057 Expect.throws(() { |
1303 view); | 2058 view[-1] = 0; |
1304 Expect.throws(() { view[-1] = 0; }, | 2059 }, (e) { |
1305 (e) { return e is RangeError; }); | 2060 return e is RangeError; |
1306 Expect.throws(() { return view[-1]; }, | 2061 }); |
1307 (e) { return e is RangeError; }); | 2062 Expect.throws(() { |
1308 Expect.throws(() { view[view.length]; }, | 2063 return view[-1]; |
1309 (e) { return e is RangeError; }); | 2064 }, (e) { |
1310 Expect.throws(() { view[10] = 0; }, | 2065 return e is RangeError; |
1311 (e) { return e is RangeError; }); | 2066 }); |
1312 Expect.throws(() { view.add(0); }, | 2067 Expect.throws(() { |
1313 (e) { return e is UnsupportedError; }); | 2068 view[view.length]; |
1314 Expect.throws(() { view.addAll([0]); }, | 2069 }, (e) { |
1315 (e) { return e is UnsupportedError; }); | 2070 return e is RangeError; |
1316 Expect.throws(() { view.clear(); }, | 2071 }); |
1317 (e) { return e is UnsupportedError; }); | 2072 Expect.throws(() { |
1318 Expect.throws(() { view.length = 0; }, | 2073 view[10] = 0; |
1319 (e) { return e is UnsupportedError; }); | 2074 }, (e) { |
1320 Expect.throws(() { view.removeLast(); }, | 2075 return e is RangeError; |
1321 (e) { return e is UnsupportedError; }); | 2076 }); |
1322 Expect.throws(() { view.removeRange(0, view.length - 1); }, | 2077 Expect.throws(() { |
1323 (e) { return e is UnsupportedError; }); | 2078 view.add(0); |
| 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 }); |
1324 for (int i = 0; i < view.length; ++i) { | 2107 for (int i = 0; i < view.length; ++i) { |
1325 view[i] = 1 + i; | 2108 view[i] = 1 + i; |
1326 } | 2109 } |
1327 Expect.listEquals([1, 2, 3, 4, 5, | 2110 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); |
1328 6, 7, 8, 9, 10], | 2111 Expect.listEquals([ |
1329 view); | 2112 0xFF, |
1330 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, | 2113 0xFF, |
1331 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, | 2114 0xFF, |
1332 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, | 2115 0xFF, |
1333 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, | 2116 0x01, |
1334 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, | 2117 0x00, |
1335 0x0A, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], | 2118 0x00, |
1336 array); | 2119 0x00, |
| 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); |
1337 for (int i = 0; i < view.length; ++i) { | 2161 for (int i = 0; i < view.length; ++i) { |
1338 view[i] = 0x100000000 + i; | 2162 view[i] = 0x100000000 + i; |
1339 } | 2163 } |
1340 Expect.listEquals([0, 1, 2, 3, 4, | 2164 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); |
1341 5, 6, 7, 8, 9], | 2165 Expect.listEquals([ |
1342 view); | 2166 0xFF, |
1343 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, | 2167 0xFF, |
1344 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, | 2168 0xFF, |
1345 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, | 2169 0xFF, |
1346 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, | 2170 0x00, |
1347 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, | 2171 0x00, |
1348 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], | 2172 0x00, |
1349 array); | 2173 0x00, |
| 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); |
1350 for (int i = 0; i < view.length; ++i) { | 2215 for (int i = 0; i < view.length; ++i) { |
1351 view[i] = -10 + i; | 2216 view[i] = -10 + i; |
1352 } | 2217 } |
1353 Expect.listEquals([-10, -9, -8, -7, -6, | 2218 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], view); |
1354 -5, -4, -3, -2, -1], | 2219 Expect.listEquals([ |
1355 view); | 2220 0xFF, |
1356 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xF6, 0xFF, 0xFF, 0xFF, | 2221 0xFF, |
1357 0xF7, 0xFF, 0xFF, 0xFF, 0xF8, 0xFF, 0xFF, 0xFF, | 2222 0xFF, |
1358 0xF9, 0xFF, 0xFF, 0xFF, 0xFA, 0xFF, 0xFF, 0xFF, | 2223 0xFF, |
1359 0xFB, 0xFF, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0xFF, | 2224 0xF6, |
1360 0xFD, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, | 2225 0xFF, |
1361 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 2226 0xFF, |
1362 array); | 2227 0xFF, |
| 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); |
1363 for (int i = 0; i < view.length; ++i) { | 2269 for (int i = 0; i < view.length; ++i) { |
1364 view[i] = 0x7FFFFFFF - i; | 2270 view[i] = 0x7FFFFFFF - i; |
1365 } | 2271 } |
1366 Expect.listEquals([0x7FFFFFFF, 0x7FFFFFFE, | 2272 Expect.listEquals([ |
1367 0x7FFFFFFD, 0x7FFFFFFC, | 2273 0x7FFFFFFF, |
1368 0x7FFFFFFB, 0x7FFFFFFA, | 2274 0x7FFFFFFE, |
1369 0x7FFFFFF9, 0x7FFFFFF8, | 2275 0x7FFFFFFD, |
1370 0x7FFFFFF7, 0x7FFFFFF6], | 2276 0x7FFFFFFC, |
1371 view); | 2277 0x7FFFFFFB, |
1372 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, | 2278 0x7FFFFFFA, |
1373 0xFE, 0xFF, 0xFF, 0x7F, 0xFD, 0xFF, 0xFF, 0x7F, | 2279 0x7FFFFFF9, |
1374 0xFC, 0xFF, 0xFF, 0x7F, 0xFB, 0xFF, 0xFF, 0x7F, | 2280 0x7FFFFFF8, |
1375 0xFA, 0xFF, 0xFF, 0x7F, 0xF9, 0xFF, 0xFF, 0x7F, | 2281 0x7FFFFFF7, |
1376 0xF8, 0xFF, 0xFF, 0x7F, 0xF7, 0xFF, 0xFF, 0x7F, | 2282 0x7FFFFFF6 |
1377 0xF6, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF], | 2283 ], view); |
1378 array); | 2284 Expect.listEquals([ |
| 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); |
1379 for (int i = 0; i < view.length; ++i) { | 2334 for (int i = 0; i < view.length; ++i) { |
1380 view[i] = -0x80000000 + i; | 2335 view[i] = -0x80000000 + i; |
1381 } | 2336 } |
1382 Expect.listEquals([-0x80000000, -0x7FFFFFFF, | 2337 Expect.listEquals([ |
1383 -0x7FFFFFFE, -0x7FFFFFFD, | 2338 -0x80000000, |
1384 -0x7FFFFFFC, -0x7FFFFFFB, | 2339 -0x7FFFFFFF, |
1385 -0x7FFFFFFA, -0x7FFFFFF9, | 2340 -0x7FFFFFFE, |
1386 -0x7FFFFFF8, -0x7FFFFFF7], | 2341 -0x7FFFFFFD, |
1387 view); | 2342 -0x7FFFFFFC, |
1388 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x80, | 2343 -0x7FFFFFFB, |
1389 0x01, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x80, | 2344 -0x7FFFFFFA, |
1390 0x03, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x80, | 2345 -0x7FFFFFF9, |
1391 0x05, 0x00, 0x00, 0x80, 0x06, 0x00, 0x00, 0x80, | 2346 -0x7FFFFFF8, |
1392 0x07, 0x00, 0x00, 0x80, 0x08, 0x00, 0x00, 0x80, | 2347 -0x7FFFFFF7 |
1393 0x09, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF], | 2348 ], view); |
1394 array); | 2349 Expect.listEquals([ |
| 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); |
1395 for (int i = 0; i < view.length; ++i) { | 2399 for (int i = 0; i < view.length; ++i) { |
1396 view[i] = i; | 2400 view[i] = i; |
1397 } | 2401 } |
1398 var copy = view.sublist(0, view.length); | 2402 var copy = view.sublist(0, view.length); |
1399 Expect.isFalse(identical(copy, view)); | 2403 Expect.isFalse(identical(copy, view)); |
1400 Expect.isTrue(copy is Int32List); | 2404 Expect.isTrue(copy is Int32List); |
1401 Expect.equals(10, copy.length); | 2405 Expect.equals(10, copy.length); |
1402 Expect.listEquals(view, copy); | 2406 Expect.listEquals(view, copy); |
1403 var region = view.sublist(3, view.length - 3); | 2407 var region = view.sublist(3, view.length - 3); |
1404 Expect.isTrue(copy is Int32List); | 2408 Expect.isTrue(copy is Int32List); |
1405 Expect.equals(4, region.length); | 2409 Expect.equals(4, region.length); |
1406 Expect.listEquals([3, 4, 5, 6], region); | 2410 Expect.listEquals([3, 4, 5, 6], region); |
1407 view.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]); | 2411 view.setRange(3, 7, [-0x80000000, 0, 1, 0x7FFFFFFF]); |
1408 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], | 2412 Expect.listEquals([0, 1, 2, -0x80000000, 0, 1, 0x7FFFFFFF, 7, 8, 9], view); |
1409 view); | 2413 Expect.listEquals([ |
1410 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, | 2414 0xFF, |
1411 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, | 2415 0xFF, |
1412 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, | 2416 0xFF, |
1413 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, | 2417 0xFF, |
1414 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, | 2418 0x00, |
1415 0x09, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF], | 2419 0x00, |
1416 array); | 2420 0x00, |
| 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); |
1417 } | 2463 } |
1418 | 2464 |
1419 static testUint32ListViewImpl(var array) { | 2465 static testUint32ListViewImpl(var array) { |
1420 Expect.isTrue(array is List<int>); | 2466 Expect.isTrue(array is List<int>); |
1421 Expect.equals(48, array.length); | 2467 Expect.equals(48, array.length); |
1422 Expect.equals(1, array.elementSizeInBytes); | 2468 Expect.equals(1, array.elementSizeInBytes); |
1423 Expect.equals(48, array.lengthInBytes); | 2469 Expect.equals(48, array.lengthInBytes); |
1424 for (int i = 0; i < array.length; ++i) { | 2470 for (int i = 0; i < array.length; ++i) { |
1425 array[i] = -1; | 2471 array[i] = -1; |
1426 } | 2472 } |
1427 Expect.throws(() { new Uint32List.view(array.buffer, -1); }, | 2473 Expect.throws(() { |
1428 (e) { return e is RangeError; }); | 2474 new Uint32List.view(array.buffer, -1); |
1429 Expect.throws(() { new Uint32List.view(array.buffer, 0, -1); }, | 2475 }, (e) { |
1430 (e) { return e is RangeError; }); | 2476 return e is RangeError; |
1431 Expect.throws(() { new Uint32List.view(array.buffer, | 2477 }); |
1432 array.lengthInBytes + 1); }, | 2478 Expect.throws(() { |
1433 (e) { return e is RangeError; }); | 2479 new Uint32List.view(array.buffer, 0, -1); |
1434 Expect.throws(() { new Uint32List.view(array.buffer, | 2480 }, (e) { |
1435 0, array.length + 1); }, | 2481 return e is RangeError; |
1436 (e) { return e is RangeError; }); | 2482 }); |
1437 Expect.throws(() { new Uint32List.view(array.buffer, | 2483 Expect.throws(() { |
1438 array.length - 1, 2); }, | 2484 new Uint32List.view(array.buffer, array.lengthInBytes + 1); |
1439 (e) { return e is RangeError; }); | 2485 }, (e) { |
1440 var empty = new Uint32List.view(array.buffer, | 2486 return e is RangeError; |
1441 array.lengthInBytes); | 2487 }); |
| 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); |
1442 Expect.isTrue(empty is List<int>); | 2499 Expect.isTrue(empty is List<int>); |
1443 Expect.isTrue(empty is Uint32List); | 2500 Expect.isTrue(empty is Uint32List); |
1444 Expect.equals(0, empty.length); | 2501 Expect.equals(0, empty.length); |
1445 var whole = new Uint32List.view(array.buffer); | 2502 var whole = new Uint32List.view(array.buffer); |
1446 Expect.isTrue(whole is List<int>); | 2503 Expect.isTrue(whole is List<int>); |
1447 Expect.isTrue(whole is Uint32List); | 2504 Expect.isTrue(whole is Uint32List); |
1448 Expect.equals(12, whole.length); | 2505 Expect.equals(12, whole.length); |
1449 var view = new Uint32List.view(array.buffer, 4, 10); | 2506 var view = new Uint32List.view(array.buffer, 4, 10); |
1450 Expect.isTrue(view is List<int>); | 2507 Expect.isTrue(view is List<int>); |
1451 Expect.isTrue(view is Uint32List); | 2508 Expect.isTrue(view is Uint32List); |
1452 Expect.equals(10, view.length); | 2509 Expect.equals(10, view.length); |
1453 Expect.equals(4, view.elementSizeInBytes); | 2510 Expect.equals(4, view.elementSizeInBytes); |
1454 Expect.equals(40, view.lengthInBytes); | 2511 Expect.equals(40, view.lengthInBytes); |
1455 Expect.listEquals([0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF
F, | 2512 Expect.listEquals([ |
1456 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFF
F], | 2513 0xFFFFFFFF, |
1457 view); | 2514 0xFFFFFFFF, |
1458 Expect.throws(() { view[-1] = 0; }, | 2515 0xFFFFFFFF, |
1459 (e) { return e is RangeError; }); | 2516 0xFFFFFFFF, |
1460 Expect.throws(() { return view[-1]; }, | 2517 0xFFFFFFFF, |
1461 (e) { return e is RangeError; }); | 2518 0xFFFFFFFF, |
1462 Expect.throws(() { view[view.length]; }, | 2519 0xFFFFFFFF, |
1463 (e) { return e is RangeError; }); | 2520 0xFFFFFFFF, |
1464 Expect.throws(() { view[view.length] = 0; }, | 2521 0xFFFFFFFF, |
1465 (e) { return e is RangeError; }); | 2522 0xFFFFFFFF |
1466 Expect.throws(() { view.add(0); }, | 2523 ], view); |
1467 (e) { return e is UnsupportedError; }); | 2524 Expect.throws(() { |
1468 Expect.throws(() { view.addAll([0]); }, | 2525 view[-1] = 0; |
1469 (e) { return e is UnsupportedError; }); | 2526 }, (e) { |
1470 Expect.throws(() { view.clear(); }, | 2527 return e is RangeError; |
1471 (e) { return e is UnsupportedError; }); | 2528 }); |
1472 Expect.throws(() { view.length = 0; }, | 2529 Expect.throws(() { |
1473 (e) { return e is UnsupportedError; }); | 2530 return view[-1]; |
1474 Expect.throws(() { view.removeLast(); }, | 2531 }, (e) { |
1475 (e) { return e is UnsupportedError; }); | 2532 return e is RangeError; |
1476 Expect.throws(() { view.removeRange(0, view.length - 1); }, | 2533 }); |
1477 (e) { return e is UnsupportedError; }); | 2534 Expect.throws(() { |
| 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 }); |
1478 for (int i = 0; i < view.length; ++i) { | 2574 for (int i = 0; i < view.length; ++i) { |
1479 view[i] = 1 + i; | 2575 view[i] = 1 + i; |
1480 } | 2576 } |
1481 Expect.listEquals([1, 2, 3, 4, 5, | 2577 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); |
1482 6, 7, 8, 9, 10], | 2578 Expect.listEquals([ |
1483 view); | 2579 -1, |
1484 Expect.listEquals([-1, -1, -1, -1, 1, 0, 0, 0, | 2580 -1, |
1485 2, 0, 0, 0, 3, 0, 0, 0, | 2581 -1, |
1486 4, 0, 0, 0, 5, 0, 0, 0, | 2582 -1, |
1487 6, 0, 0, 0, 7, 0, 0, 0, | 2583 1, |
1488 8, 0, 0, 0, 9, 0, 0, 0, | 2584 0, |
1489 10, 0, 0, 0, -1, -1, -1, -1], | 2585 0, |
1490 array); | 2586 0, |
| 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); |
1491 for (int i = 0; i < view.length; ++i) { | 2628 for (int i = 0; i < view.length; ++i) { |
1492 view[i] = 0x100000000 + i; | 2629 view[i] = 0x100000000 + i; |
1493 } | 2630 } |
1494 Expect.listEquals([0, 1, 2, 3, 4, | 2631 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); |
1495 5, 6, 7, 8, 9], | 2632 Expect.listEquals([ |
1496 view); | 2633 -1, |
1497 Expect.listEquals([-1, -1, -1, -1, 0, 0, 0, 0, | 2634 -1, |
1498 1, 0, 0, 0, 2, 0, 0, 0, | 2635 -1, |
1499 3, 0, 0, 0, 4, 0, 0, 0, | 2636 -1, |
1500 5, 0, 0, 0, 6, 0, 0, 0, | 2637 0, |
1501 7, 0, 0, 0, 8, 0, 0, 0, | 2638 0, |
1502 9, 0, 0, 0, -1, -1, -1, -1], | 2639 0, |
1503 array); | 2640 0, |
| 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); |
1504 for (int i = 0; i < view.length; ++i) { | 2682 for (int i = 0; i < view.length; ++i) { |
1505 view[i] = 0xFFFFFFFF - i; | 2683 view[i] = 0xFFFFFFFF - i; |
1506 } | 2684 } |
1507 Expect.listEquals([0xFFFFFFFF, 0xFFFFFFFE, | 2685 Expect.listEquals([ |
1508 0xFFFFFFFD, 0xFFFFFFFC, | 2686 0xFFFFFFFF, |
1509 0xFFFFFFFB, 0xFFFFFFFA, | 2687 0xFFFFFFFE, |
1510 0xFFFFFFF9, 0xFFFFFFF8, | 2688 0xFFFFFFFD, |
1511 0xFFFFFFF7, 0xFFFFFFF6], | 2689 0xFFFFFFFC, |
1512 view); | 2690 0xFFFFFFFB, |
1513 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, | 2691 0xFFFFFFFA, |
1514 -2, -1, -1, -1, -3, -1, -1, -1, | 2692 0xFFFFFFF9, |
1515 -4, -1, -1, -1, -5, -1, -1, -1, | 2693 0xFFFFFFF8, |
1516 -6, -1, -1, -1, -7, -1, -1, -1, | 2694 0xFFFFFFF7, |
1517 -8, -1, -1, -1, -9, -1, -1, -1, | 2695 0xFFFFFFF6 |
1518 -10, -1, -1, -1, -1, -1, -1, -1], | 2696 ], view); |
1519 array); | 2697 Expect.listEquals([ |
| 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); |
1520 for (int i = 0; i < view.length; ++i) { | 2747 for (int i = 0; i < view.length; ++i) { |
1521 view[i] = i; | 2748 view[i] = i; |
1522 } | 2749 } |
1523 var copy = view.sublist(0, view.length); | 2750 var copy = view.sublist(0, view.length); |
1524 Expect.isFalse(identical(copy, view)); | 2751 Expect.isFalse(identical(copy, view)); |
1525 Expect.isTrue(copy is Uint32List); | 2752 Expect.isTrue(copy is Uint32List); |
1526 Expect.equals(10, copy.length); | 2753 Expect.equals(10, copy.length); |
1527 Expect.listEquals(view, copy); | 2754 Expect.listEquals(view, copy); |
1528 var region = view.sublist(3, view.length - 3); | 2755 var region = view.sublist(3, view.length - 3); |
1529 Expect.isTrue(copy is Uint32List); | 2756 Expect.isTrue(copy is Uint32List); |
1530 Expect.equals(4, region.length); | 2757 Expect.equals(4, region.length); |
1531 Expect.listEquals([3, 4, 5, 6], region); | 2758 Expect.listEquals([3, 4, 5, 6], region); |
1532 view.setRange(3, 7, [0x100000001, 0, 1, 0xFFFFFFFF]); | 2759 view.setRange(3, 7, [0x100000001, 0, 1, 0xFFFFFFFF]); |
1533 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], | 2760 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFF, 7, 8, 9], view); |
1534 view); | 2761 Expect.listEquals([ |
1535 Expect.listEquals([-1, -1, -1, -1, 0, 0, 0, 0, | 2762 -1, |
1536 1, 0, 0, 0, 2, 0, 0, 0, | 2763 -1, |
1537 1, 0, 0, 0, 0, 0, 0, 0, | 2764 -1, |
1538 1, 0, 0, 0, -1, -1, -1, -1, | 2765 -1, |
1539 7, 0, 0, 0, 8, 0, 0, 0, | 2766 0, |
1540 9, 0, 0, 0, -1, -1, -1, -1], | 2767 0, |
1541 array); | 2768 0, |
| 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); |
1542 } | 2811 } |
1543 | 2812 |
1544 static testUint32ListView() { | 2813 static testUint32ListView() { |
1545 var array = new Int8List(48); | 2814 var array = new Int8List(48); |
1546 testUint32ListViewImpl(array); | 2815 testUint32ListViewImpl(array); |
1547 } | 2816 } |
1548 | 2817 |
1549 static testInt64ListViewImpl(var array) { | 2818 static testInt64ListViewImpl(var array) { |
1550 Expect.equals(96, array.length); | 2819 Expect.equals(96, array.length); |
1551 Expect.equals(1, array.elementSizeInBytes); | 2820 Expect.equals(1, array.elementSizeInBytes); |
1552 Expect.equals(96, array.lengthInBytes); | 2821 Expect.equals(96, array.lengthInBytes); |
1553 for (int i = 0; i < array.length; ++i) { | 2822 for (int i = 0; i < array.length; ++i) { |
1554 array[i] = 0xFF; | 2823 array[i] = 0xFF; |
1555 } | 2824 } |
1556 Expect.throws(() { new Int64List.view(array.buffer, -1); }, | 2825 Expect.throws(() { |
1557 (e) { return e is RangeError; }); | 2826 new Int64List.view(array.buffer, -1); |
1558 Expect.throws(() { new Int64List.view(array.buffer, 0, -1); }, | 2827 }, (e) { |
1559 (e) { return e is RangeError; }); | 2828 return e is RangeError; |
1560 Expect.throws(() { new Int64List.view(array.buffer, | 2829 }); |
1561 array.lengthInBytes + 1); }, | 2830 Expect.throws(() { |
1562 (e) { return e is RangeError; }); | 2831 new Int64List.view(array.buffer, 0, -1); |
1563 Expect.throws(() { new Int64List.view(array.buffer, | 2832 }, (e) { |
1564 0, array.length + 1); }, | 2833 return e is RangeError; |
1565 (e) { return e is RangeError; }); | 2834 }); |
1566 Expect.throws(() { new Int64List.view(array.buffer, | 2835 Expect.throws(() { |
1567 array.length - 1, 2); }, | 2836 new Int64List.view(array.buffer, array.lengthInBytes + 1); |
1568 (e) { return e is RangeError; }); | 2837 }, (e) { |
1569 var empty = new Int64List.view(array.buffer, | 2838 return e is RangeError; |
1570 array.lengthInBytes); | 2839 }); |
| 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); |
1571 Expect.isTrue(empty is List<int>); | 2851 Expect.isTrue(empty is List<int>); |
1572 Expect.isTrue(empty is Int64List); | 2852 Expect.isTrue(empty is Int64List); |
1573 Expect.equals(0, empty.length); | 2853 Expect.equals(0, empty.length); |
1574 var whole = new Int64List.view(array.buffer); | 2854 var whole = new Int64List.view(array.buffer); |
1575 Expect.isTrue(whole is List<int>); | 2855 Expect.isTrue(whole is List<int>); |
1576 Expect.isTrue(whole is Int64List); | 2856 Expect.isTrue(whole is Int64List); |
1577 Expect.equals(12, whole.length); | 2857 Expect.equals(12, whole.length); |
1578 var view = new Int64List.view(array.buffer, 8, 10); | 2858 var view = new Int64List.view(array.buffer, 8, 10); |
1579 Expect.isTrue(view is List<int>); | 2859 Expect.isTrue(view is List<int>); |
1580 Expect.isTrue(view is Int64List); | 2860 Expect.isTrue(view is Int64List); |
1581 Expect.equals(10, view.length); | 2861 Expect.equals(10, view.length); |
1582 Expect.equals(8, view.elementSizeInBytes); | 2862 Expect.equals(8, view.elementSizeInBytes); |
1583 Expect.equals(80, view.lengthInBytes); | 2863 Expect.equals(80, view.lengthInBytes); |
1584 Expect.listEquals([-1, -1, -1, -1, -1, | 2864 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], view); |
1585 -1, -1, -1, -1, -1], | 2865 Expect.throws(() { |
1586 view); | 2866 view[-1] = 0; |
1587 Expect.throws(() { view[-1] = 0; }, | 2867 }, (e) { |
1588 (e) { return e is RangeError; }); | 2868 return e is RangeError; |
1589 Expect.throws(() { return view[-1]; }, | 2869 }); |
1590 (e) { return e is RangeError; }); | 2870 Expect.throws(() { |
1591 Expect.throws(() { view[view.length]; }, | 2871 return view[-1]; |
1592 (e) { return e is RangeError; }); | 2872 }, (e) { |
1593 Expect.throws(() { view[10] = 0; }, | 2873 return e is RangeError; |
1594 (e) { return e is RangeError; }); | 2874 }); |
1595 Expect.throws(() { view.add(0); }, | 2875 Expect.throws(() { |
1596 (e) { return e is UnsupportedError; }); | 2876 view[view.length]; |
1597 Expect.throws(() { view.addAll([0]); }, | 2877 }, (e) { |
1598 (e) { return e is UnsupportedError; }); | 2878 return e is RangeError; |
1599 Expect.throws(() { view.clear(); }, | 2879 }); |
1600 (e) { return e is UnsupportedError; }); | 2880 Expect.throws(() { |
1601 Expect.throws(() { view.length = 0; }, | 2881 view[10] = 0; |
1602 (e) { return e is UnsupportedError; }); | 2882 }, (e) { |
1603 Expect.throws(() { view.removeLast(); }, | 2883 return e is RangeError; |
1604 (e) { return e is UnsupportedError; }); | 2884 }); |
1605 Expect.throws(() { view.removeRange(0, view.length - 1); }, | 2885 Expect.throws(() { |
1606 (e) { return e is UnsupportedError; }); | 2886 view.add(0); |
| 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 }); |
1607 for (int i = 0; i < view.length; ++i) { | 2915 for (int i = 0; i < view.length; ++i) { |
1608 view[i] = 1 + i; | 2916 view[i] = 1 + i; |
1609 } | 2917 } |
1610 Expect.listEquals([1, 2, 3, 4, 5, | 2918 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); |
1611 6, 7, 8, 9, 10], | 2919 Expect.listEquals([ |
1612 view); | 2920 0xFF, |
1613 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 2921 0xFF, |
1614 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 2922 0xFF, |
1615 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 2923 0xFF, |
1616 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 2924 0xFF, |
1617 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 2925 0xFF, |
1618 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 2926 0xFF, |
1619 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 2927 0xFF, |
1620 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 2928 0x01, |
1621 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 2929 0x00, |
1622 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 2930 0x00, |
1623 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 2931 0x00, |
1624 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 2932 0x00, |
1625 array); | 2933 0x00, |
| 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); |
1626 for (int i = 0; i < view.length; ++i) { | 3017 for (int i = 0; i < view.length; ++i) { |
1627 view[i] = 0x10000000000000000 + i; | 3018 view[i] = 0x10000000000000000 + i; |
1628 } | 3019 } |
1629 Expect.listEquals([0, 1, 2, 3, 4, | 3020 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); |
1630 5, 6, 7, 8, 9], | 3021 Expect.listEquals([ |
1631 view); | 3022 0xFF, |
1632 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3023 0xFF, |
1633 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3024 0xFF, |
1634 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3025 0xFF, |
1635 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3026 0xFF, |
1636 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3027 0xFF, |
1637 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3028 0xFF, |
1638 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3029 0xFF, |
1639 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3030 0x00, |
1640 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3031 0x00, |
1641 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3032 0x00, |
1642 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3033 0x00, |
1643 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 3034 0x00, |
1644 array); | 3035 0x00, |
| 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); |
1645 for (int i = 0; i < view.length; ++i) { | 3119 for (int i = 0; i < view.length; ++i) { |
1646 view[i] = -10 + i; | 3120 view[i] = -10 + i; |
1647 } | 3121 } |
1648 Expect.listEquals([-10, -9, -8, -7, -6, | 3122 Expect.listEquals([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], view); |
1649 -5, -4, -3, -2, -1], | 3123 Expect.listEquals([ |
1650 view); | 3124 0xFF, |
1651 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3125 0xFF, |
1652 0xF6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3126 0xFF, |
1653 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3127 0xFF, |
1654 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3128 0xFF, |
1655 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3129 0xFF, |
1656 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3130 0xFF, |
1657 0xFB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3131 0xFF, |
1658 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3132 0xF6, |
1659 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3133 0xFF, |
1660 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3134 0xFF, |
1661 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3135 0xFF, |
1662 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 3136 0xFF, |
1663 array); | 3137 0xFF, |
| 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); |
1664 for (int i = 0; i < view.length; ++i) { | 3221 for (int i = 0; i < view.length; ++i) { |
1665 view[i] = 0x7FFFFFFFFFFFFFFF - i; | 3222 view[i] = 0x7FFFFFFFFFFFFFFF - i; |
1666 } | 3223 } |
1667 Expect.listEquals([0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFE, | 3224 Expect.listEquals([ |
1668 0x7FFFFFFFFFFFFFFD, 0x7FFFFFFFFFFFFFFC, | 3225 0x7FFFFFFFFFFFFFFF, |
1669 0x7FFFFFFFFFFFFFFB, 0x7FFFFFFFFFFFFFFA, | 3226 0x7FFFFFFFFFFFFFFE, |
1670 0x7FFFFFFFFFFFFFF9, 0x7FFFFFFFFFFFFFF8, | 3227 0x7FFFFFFFFFFFFFFD, |
1671 0x7FFFFFFFFFFFFFF7, 0x7FFFFFFFFFFFFFF6], | 3228 0x7FFFFFFFFFFFFFFC, |
1672 view); | 3229 0x7FFFFFFFFFFFFFFB, |
1673 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3230 0x7FFFFFFFFFFFFFFA, |
1674 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, | 3231 0x7FFFFFFFFFFFFFF9, |
1675 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, | 3232 0x7FFFFFFFFFFFFFF8, |
1676 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, | 3233 0x7FFFFFFFFFFFFFF7, |
1677 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, | 3234 0x7FFFFFFFFFFFFFF6 |
1678 0xFB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, | 3235 ], view); |
1679 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, | 3236 Expect.listEquals([ |
1680 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, | 3237 0xFF, |
1681 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, | 3238 0xFF, |
1682 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, | 3239 0xFF, |
1683 0xF6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, | 3240 0xFF, |
1684 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 3241 0xFF, |
1685 array); | 3242 0xFF, |
| 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); |
1686 for (int i = 0; i < view.length; ++i) { | 3334 for (int i = 0; i < view.length; ++i) { |
1687 view[i] = -0x8000000000000000 + i; | 3335 view[i] = -0x8000000000000000 + i; |
1688 } | 3336 } |
1689 Expect.listEquals([-0x8000000000000000, -0x7FFFFFFFFFFFFFFF, | 3337 Expect.listEquals([ |
1690 -0x7FFFFFFFFFFFFFFE, -0x7FFFFFFFFFFFFFFD, | 3338 -0x8000000000000000, |
1691 -0x7FFFFFFFFFFFFFFC, -0x7FFFFFFFFFFFFFFB, | 3339 -0x7FFFFFFFFFFFFFFF, |
1692 -0x7FFFFFFFFFFFFFFA, -0x7FFFFFFFFFFFFFF9, | 3340 -0x7FFFFFFFFFFFFFFE, |
1693 -0x7FFFFFFFFFFFFFF8, -0x7FFFFFFFFFFFFFF7], | 3341 -0x7FFFFFFFFFFFFFFD, |
1694 view); | 3342 -0x7FFFFFFFFFFFFFFC, |
1695 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3343 -0x7FFFFFFFFFFFFFFB, |
1696 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 3344 -0x7FFFFFFFFFFFFFFA, |
1697 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 3345 -0x7FFFFFFFFFFFFFF9, |
1698 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 3346 -0x7FFFFFFFFFFFFFF8, |
1699 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 3347 -0x7FFFFFFFFFFFFFF7 |
1700 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 3348 ], view); |
1701 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 3349 Expect.listEquals([ |
1702 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 3350 0xFF, |
1703 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 3351 0xFF, |
1704 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 3352 0xFF, |
1705 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 3353 0xFF, |
1706 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 3354 0xFF, |
1707 array); | 3355 0xFF, |
| 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); |
1708 for (int i = 0; i < view.length; ++i) { | 3447 for (int i = 0; i < view.length; ++i) { |
1709 view[i] = i; | 3448 view[i] = i; |
1710 } | 3449 } |
1711 var copy = view.sublist(0, view.length); | 3450 var copy = view.sublist(0, view.length); |
1712 Expect.isFalse(identical(copy, view)); | 3451 Expect.isFalse(identical(copy, view)); |
1713 Expect.isTrue(copy is Int64List); | 3452 Expect.isTrue(copy is Int64List); |
1714 Expect.equals(10, copy.length); | 3453 Expect.equals(10, copy.length); |
1715 Expect.listEquals(view, copy); | 3454 Expect.listEquals(view, copy); |
1716 var region = view.sublist(3, view.length - 3); | 3455 var region = view.sublist(3, view.length - 3); |
1717 Expect.isTrue(copy is Int64List); | 3456 Expect.isTrue(copy is Int64List); |
1718 Expect.equals(4, region.length); | 3457 Expect.equals(4, region.length); |
1719 Expect.listEquals([3, 4, 5, 6], region); | 3458 Expect.listEquals([3, 4, 5, 6], region); |
1720 view.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); | 3459 view.setRange(3, 7, [-0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF]); |
1721 Expect.listEquals([0, 1, 2, -0x8000000000000000, 0, | 3460 Expect.listEquals( |
1722 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], | 3461 [0, 1, 2, -0x8000000000000000, 0, 1, 0x7FFFFFFFFFFFFFFF, 7, 8, 9], |
1723 view); | 3462 view); |
1724 Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 3463 Expect.listEquals([ |
1725 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3464 0xFF, |
1726 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3465 0xFF, |
1727 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3466 0xFF, |
1728 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 3467 0xFF, |
1729 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3468 0xFF, |
1730 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3469 0xFF, |
1731 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, | 3470 0xFF, |
1732 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3471 0xFF, |
1733 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3472 0x00, |
1734 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3473 0x00, |
1735 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], | 3474 0x00, |
1736 array); | 3475 0x00, |
| 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); |
1737 } | 3561 } |
1738 | 3562 |
1739 static testInt64ListView() { | 3563 static testInt64ListView() { |
1740 var array = new Uint8List(96); | 3564 var array = new Uint8List(96); |
1741 testInt64ListViewImpl(array); | 3565 testInt64ListViewImpl(array); |
1742 } | 3566 } |
1743 | 3567 |
1744 static testUint64ListViewImpl(var array) { | 3568 static testUint64ListViewImpl(var array) { |
1745 Expect.isTrue(array is List<int>); | 3569 Expect.isTrue(array is List<int>); |
1746 Expect.equals(96, array.length); | 3570 Expect.equals(96, array.length); |
1747 Expect.equals(1, array.elementSizeInBytes); | 3571 Expect.equals(1, array.elementSizeInBytes); |
1748 Expect.equals(96, array.lengthInBytes); | 3572 Expect.equals(96, array.lengthInBytes); |
1749 for (int i = 0; i < array.length; ++i) { | 3573 for (int i = 0; i < array.length; ++i) { |
1750 array[i] = -1; | 3574 array[i] = -1; |
1751 } | 3575 } |
1752 Expect.throws(() { new Uint64List.view(array.buffer, -1); }, | 3576 Expect.throws(() { |
1753 (e) { return e is RangeError; }); | 3577 new Uint64List.view(array.buffer, -1); |
1754 Expect.throws(() { new Uint64List.view(array.buffer, 0, -1); }, | 3578 }, (e) { |
1755 (e) { return e is RangeError; }); | 3579 return e is RangeError; |
1756 Expect.throws(() { new Uint64List.view(array.buffer, | 3580 }); |
1757 array.lengthInBytes + 1); }, | 3581 Expect.throws(() { |
1758 (e) { return e is RangeError; }); | 3582 new Uint64List.view(array.buffer, 0, -1); |
1759 Expect.throws(() { new Uint64List.view(array.buffer, | 3583 }, (e) { |
1760 0, array.length + 1); }, | 3584 return e is RangeError; |
1761 (e) { return e is RangeError; }); | 3585 }); |
1762 Expect.throws(() { new Uint64List.view(array.buffer, | 3586 Expect.throws(() { |
1763 array.length - 1, 2); }, | 3587 new Uint64List.view(array.buffer, array.lengthInBytes + 1); |
1764 (e) { return e is RangeError; }); | 3588 }, (e) { |
1765 var empty = new Uint64List.view(array.buffer, | 3589 return e is RangeError; |
1766 array.lengthInBytes); | 3590 }); |
| 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); |
1767 Expect.isTrue(empty is List<int>); | 3602 Expect.isTrue(empty is List<int>); |
1768 Expect.isTrue(empty is Uint64List); | 3603 Expect.isTrue(empty is Uint64List); |
1769 Expect.equals(0, empty.length); | 3604 Expect.equals(0, empty.length); |
1770 var whole = new Uint64List.view(array.buffer); | 3605 var whole = new Uint64List.view(array.buffer); |
1771 Expect.isTrue(whole is List<int>); | 3606 Expect.isTrue(whole is List<int>); |
1772 Expect.isTrue(whole is Uint64List); | 3607 Expect.isTrue(whole is Uint64List); |
1773 Expect.equals(12, whole.length); | 3608 Expect.equals(12, whole.length); |
1774 var view = new Uint64List.view(array.buffer, 8, 10); | 3609 var view = new Uint64List.view(array.buffer, 8, 10); |
1775 Expect.isTrue(view is List<int>); | 3610 Expect.isTrue(view is List<int>); |
1776 Expect.isTrue(view is Uint64List); | 3611 Expect.isTrue(view is Uint64List); |
1777 Expect.equals(10, view.length); | 3612 Expect.equals(10, view.length); |
1778 Expect.equals(8, view.elementSizeInBytes); | 3613 Expect.equals(8, view.elementSizeInBytes); |
1779 Expect.equals(80, view.lengthInBytes); | 3614 Expect.equals(80, view.lengthInBytes); |
1780 Expect.listEquals([0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, | 3615 Expect.listEquals([ |
1781 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, | 3616 0xFFFFFFFFFFFFFFFF, |
1782 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, | 3617 0xFFFFFFFFFFFFFFFF, |
1783 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, | 3618 0xFFFFFFFFFFFFFFFF, |
1784 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF], | 3619 0xFFFFFFFFFFFFFFFF, |
1785 view); | 3620 0xFFFFFFFFFFFFFFFF, |
1786 Expect.throws(() { view[-1] = 0; }, | 3621 0xFFFFFFFFFFFFFFFF, |
1787 (e) { return e is RangeError; }); | 3622 0xFFFFFFFFFFFFFFFF, |
1788 Expect.throws(() { return view[-1]; }, | 3623 0xFFFFFFFFFFFFFFFF, |
1789 (e) { return e is RangeError; }); | 3624 0xFFFFFFFFFFFFFFFF, |
1790 Expect.throws(() { view[view.length]; }, | 3625 0xFFFFFFFFFFFFFFFF |
1791 (e) { return e is RangeError; }); | 3626 ], view); |
1792 Expect.throws(() { view[view.length] = 0; }, | 3627 Expect.throws(() { |
1793 (e) { return e is RangeError; }); | 3628 view[-1] = 0; |
1794 Expect.throws(() { view.add(0); }, | 3629 }, (e) { |
1795 (e) { return e is UnsupportedError; }); | 3630 return e is RangeError; |
1796 Expect.throws(() { view.addAll([0]); }, | 3631 }); |
1797 (e) { return e is UnsupportedError; }); | 3632 Expect.throws(() { |
1798 Expect.throws(() { view.clear(); }, | 3633 return view[-1]; |
1799 (e) { return e is UnsupportedError; }); | 3634 }, (e) { |
1800 Expect.throws(() { view.length = 0; }, | 3635 return e is RangeError; |
1801 (e) { return e is UnsupportedError; }); | 3636 }); |
1802 Expect.throws(() { view.removeLast(); }, | 3637 Expect.throws(() { |
1803 (e) { return e is UnsupportedError; }); | 3638 view[view.length]; |
1804 Expect.throws(() { view.removeRange(0, view.length - 1); }, | 3639 }, (e) { |
1805 (e) { return e is UnsupportedError; }); | 3640 return e is RangeError; |
| 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 }); |
1806 for (int i = 0; i < view.length; ++i) { | 3677 for (int i = 0; i < view.length; ++i) { |
1807 view[i] = 1 + i; | 3678 view[i] = 1 + i; |
1808 } | 3679 } |
1809 Expect.listEquals([1, 2, 3, 4, 5, | 3680 Expect.listEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], view); |
1810 6, 7, 8, 9, 10], | 3681 Expect.listEquals([ |
1811 view); | 3682 -1, |
1812 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, | 3683 -1, |
1813 1, 0, 0, 0, 0, 0, 0, 0, | 3684 -1, |
1814 2, 0, 0, 0, 0, 0, 0, 0, | 3685 -1, |
1815 3, 0, 0, 0, 0, 0, 0, 0, | 3686 -1, |
1816 4, 0, 0, 0, 0, 0, 0, 0, | 3687 -1, |
1817 5, 0, 0, 0, 0, 0, 0, 0, | 3688 -1, |
1818 6, 0, 0, 0, 0, 0, 0, 0, | 3689 -1, |
1819 7, 0, 0, 0, 0, 0, 0, 0, | 3690 1, |
1820 8, 0, 0, 0, 0, 0, 0, 0, | 3691 0, |
1821 9, 0, 0, 0, 0, 0, 0, 0, | 3692 0, |
1822 10, 0, 0, 0, 0, 0, 0, 0, | 3693 0, |
1823 -1, -1, -1, -1, -1, -1, -1, -1], | 3694 0, |
1824 array); | 3695 0, |
| 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); |
1825 for (int i = 0; i < view.length; ++i) { | 3779 for (int i = 0; i < view.length; ++i) { |
1826 view[i] = 0x10000000000000000 + i; | 3780 view[i] = 0x10000000000000000 + i; |
1827 } | 3781 } |
1828 Expect.listEquals([0, 1, 2, 3, 4, | 3782 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], view); |
1829 5, 6, 7, 8, 9], | 3783 Expect.listEquals([ |
1830 view); | 3784 -1, |
1831 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, | 3785 -1, |
1832 0, 0, 0, 0, 0, 0, 0, 0, | 3786 -1, |
1833 1, 0, 0, 0, 0, 0, 0, 0, | 3787 -1, |
1834 2, 0, 0, 0, 0, 0, 0, 0, | 3788 -1, |
1835 3, 0, 0, 0, 0, 0, 0, 0, | 3789 -1, |
1836 4, 0, 0, 0, 0, 0, 0, 0, | 3790 -1, |
1837 5, 0, 0, 0, 0, 0, 0, 0, | 3791 -1, |
1838 6, 0, 0, 0, 0, 0, 0, 0, | 3792 0, |
1839 7, 0, 0, 0, 0, 0, 0, 0, | 3793 0, |
1840 8, 0, 0, 0, 0, 0, 0, 0, | 3794 0, |
1841 9, 0, 0, 0, 0, 0, 0, 0, | 3795 0, |
1842 -1, -1, -1, -1, -1, -1, -1, -1], | 3796 0, |
1843 array); | 3797 0, |
| 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); |
1844 for (int i = 0; i < view.length; ++i) { | 3881 for (int i = 0; i < view.length; ++i) { |
1845 view[i] = 0xFFFFFFFFFFFFFFFF - i; | 3882 view[i] = 0xFFFFFFFFFFFFFFFF - i; |
1846 } | 3883 } |
1847 Expect.listEquals([0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFE, | 3884 Expect.listEquals([ |
1848 0xFFFFFFFFFFFFFFFD, 0xFFFFFFFFFFFFFFFC, | 3885 0xFFFFFFFFFFFFFFFF, |
1849 0xFFFFFFFFFFFFFFFB, 0xFFFFFFFFFFFFFFFA, | 3886 0xFFFFFFFFFFFFFFFE, |
1850 0xFFFFFFFFFFFFFFF9, 0xFFFFFFFFFFFFFFF8, | 3887 0xFFFFFFFFFFFFFFFD, |
1851 0xFFFFFFFFFFFFFFF7, 0xFFFFFFFFFFFFFFF6], | 3888 0xFFFFFFFFFFFFFFFC, |
1852 view); | 3889 0xFFFFFFFFFFFFFFFB, |
1853 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, | 3890 0xFFFFFFFFFFFFFFFA, |
1854 -1, -1, -1, -1, -1, -1, -1, -1, | 3891 0xFFFFFFFFFFFFFFF9, |
1855 -2, -1, -1, -1, -1, -1, -1, -1, | 3892 0xFFFFFFFFFFFFFFF8, |
1856 -3, -1, -1, -1, -1, -1, -1, -1, | 3893 0xFFFFFFFFFFFFFFF7, |
1857 -4, -1, -1, -1, -1, -1, -1, -1, | 3894 0xFFFFFFFFFFFFFFF6 |
1858 -5, -1, -1, -1, -1, -1, -1, -1, | 3895 ], view); |
1859 -6, -1, -1, -1, -1, -1, -1, -1, | 3896 Expect.listEquals([ |
1860 -7, -1, -1, -1, -1, -1, -1, -1, | 3897 -1, |
1861 -8, -1, -1, -1, -1, -1, -1, -1, | 3898 -1, |
1862 -9, -1, -1, -1, -1, -1, -1, -1, | 3899 -1, |
1863 -10, -1, -1, -1, -1, -1, -1, -1, | 3900 -1, |
1864 -1, -1, -1, -1, -1, -1, -1, -1], | 3901 -1, |
1865 array); | 3902 -1, |
| 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); |
1866 for (int i = 0; i < view.length; ++i) { | 3994 for (int i = 0; i < view.length; ++i) { |
1867 view[i] = i; | 3995 view[i] = i; |
1868 } | 3996 } |
1869 var copy = view.sublist(0, view.length); | 3997 var copy = view.sublist(0, view.length); |
1870 Expect.isFalse(identical(copy, view)); | 3998 Expect.isFalse(identical(copy, view)); |
1871 Expect.isTrue(copy is Uint64List); | 3999 Expect.isTrue(copy is Uint64List); |
1872 Expect.equals(10, copy.length); | 4000 Expect.equals(10, copy.length); |
1873 Expect.listEquals(view, copy); | 4001 Expect.listEquals(view, copy); |
1874 var region = view.sublist(3, view.length - 3); | 4002 var region = view.sublist(3, view.length - 3); |
1875 Expect.isTrue(copy is Uint64List); | 4003 Expect.isTrue(copy is Uint64List); |
1876 Expect.equals(4, region.length); | 4004 Expect.equals(4, region.length); |
1877 Expect.listEquals([3, 4, 5, 6], region); | 4005 Expect.listEquals([3, 4, 5, 6], region); |
1878 view.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); | 4006 view.setRange(3, 7, [0x10000000000000001, 0, 1, 0xFFFFFFFFFFFFFFFF]); |
1879 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], | 4007 Expect.listEquals([0, 1, 2, 1, 0, 1, 0xFFFFFFFFFFFFFFFF, 7, 8, 9], view); |
1880 view); | 4008 Expect.listEquals([ |
1881 Expect.listEquals([-1, -1, -1, -1, -1, -1, -1, -1, | 4009 -1, |
1882 0, 0, 0, 0, 0, 0, 0, 0, | 4010 -1, |
1883 1, 0, 0, 0, 0, 0, 0, 0, | 4011 -1, |
1884 2, 0, 0, 0, 0, 0, 0, 0, | 4012 -1, |
1885 1, 0, 0, 0, 0, 0, 0, 0, | 4013 -1, |
1886 0, 0, 0, 0, 0, 0, 0, 0, | 4014 -1, |
1887 1, 0, 0, 0, 0, 0, 0, 0, | 4015 -1, |
1888 -1, -1, -1, -1, -1, -1, -1, -1, | 4016 -1, |
1889 7, 0, 0, 0, 0, 0, 0, 0, | 4017 0, |
1890 8, 0, 0, 0, 0, 0, 0, 0, | 4018 0, |
1891 9, 0, 0, 0, 0, 0, 0, 0, | 4019 0, |
1892 -1, -1, -1, -1, -1, -1, -1, -1], | 4020 0, |
1893 array); | 4021 0, |
| 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); |
1894 } | 4106 } |
1895 | 4107 |
1896 static testUint64ListView() { | 4108 static testUint64ListView() { |
1897 var array = new Int8List(96); | 4109 var array = new Int8List(96); |
1898 testUint64ListViewImpl(array); | 4110 testUint64ListViewImpl(array); |
1899 } | 4111 } |
1900 | 4112 |
1901 static testFloat32ListViewImpl(var array) { | 4113 static testFloat32ListViewImpl(var array) { |
1902 Expect.isTrue(array is List<int>); | 4114 Expect.isTrue(array is List<int>); |
1903 Expect.equals(12, array.length); | 4115 Expect.equals(12, array.length); |
1904 Expect.equals(4, array.elementSizeInBytes); | 4116 Expect.equals(4, array.elementSizeInBytes); |
1905 Expect.equals(48, array.lengthInBytes); | 4117 Expect.equals(48, array.lengthInBytes); |
1906 for (int i = 0; i < array.length; ++i) { | 4118 for (int i = 0; i < array.length; ++i) { |
1907 array[i] = 0xBF800000; | 4119 array[i] = 0xBF800000; |
1908 } | 4120 } |
1909 Expect.throws(() { new Float32List.view(array.buffer, -1); }, | 4121 Expect.throws(() { |
1910 (e) { return e is RangeError; }); | 4122 new Float32List.view(array.buffer, -1); |
1911 Expect.throws(() { new Float32List.view(array.buffer, 0, -1); }, | 4123 }, (e) { |
1912 (e) { return e is RangeError; }); | 4124 return e is RangeError; |
1913 Expect.throws(() { new Float32List.view(array.buffer, | 4125 }); |
1914 array.lengthInBytes + 1); }, | 4126 Expect.throws(() { |
1915 (e) { return e is RangeError; }); | 4127 new Float32List.view(array.buffer, 0, -1); |
1916 Expect.throws(() { new Float32List.view(array.buffer, | 4128 }, (e) { |
1917 0, array.lengthInBytes + 1); }, | 4129 return e is RangeError; |
1918 (e) { return e is RangeError; }); | 4130 }); |
1919 Expect.throws(() { new Float32List.view(array.buffer, | 4131 Expect.throws(() { |
1920 array.lengthInBytes - 1, 2); }, | 4132 new Float32List.view(array.buffer, array.lengthInBytes + 1); |
1921 (e) { return e is RangeError; }); | 4133 }, (e) { |
1922 var empty = new Float32List.view(array.buffer, | 4134 return e is RangeError; |
1923 array.lengthInBytes); | 4135 }); |
| 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); |
1924 Expect.isTrue(empty is List<double>); | 4147 Expect.isTrue(empty is List<double>); |
1925 Expect.isTrue(empty is Float32List); | 4148 Expect.isTrue(empty is Float32List); |
1926 Expect.equals(0, empty.length); | 4149 Expect.equals(0, empty.length); |
1927 var whole = new Float32List.view(array.buffer); | 4150 var whole = new Float32List.view(array.buffer); |
1928 Expect.isTrue(whole is List<double>); | 4151 Expect.isTrue(whole is List<double>); |
1929 Expect.isTrue(whole is Float32List); | 4152 Expect.isTrue(whole is Float32List); |
1930 Expect.equals(12, whole.length); | 4153 Expect.equals(12, whole.length); |
1931 var view = new Float32List.view(array.buffer, 4, 10); | 4154 var view = new Float32List.view(array.buffer, 4, 10); |
1932 Expect.isTrue(view is List<double>); | 4155 Expect.isTrue(view is List<double>); |
1933 Expect.isTrue(view is Float32List); | 4156 Expect.isTrue(view is Float32List); |
1934 Expect.equals(10, view.length); | 4157 Expect.equals(10, view.length); |
1935 Expect.equals(4, view.elementSizeInBytes); | 4158 Expect.equals(4, view.elementSizeInBytes); |
1936 Expect.equals(40, view.lengthInBytes); | 4159 Expect.equals(40, view.lengthInBytes); |
1937 Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0, | 4160 Expect.listEquals( |
1938 -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); |
1939 view); | 4162 Expect.throws(() { |
1940 Expect.throws(() { view[-1] = 0.0; }, | 4163 view[-1] = 0.0; |
1941 (e) { return e is RangeError; }); | 4164 }, (e) { |
1942 Expect.throws(() { return view[-1]; }, | 4165 return e is RangeError; |
1943 (e) { return e is RangeError; }); | 4166 }); |
1944 Expect.throws(() { view[10]; }, | 4167 Expect.throws(() { |
1945 (e) { return e is RangeError; }); | 4168 return view[-1]; |
1946 Expect.throws(() { view[10] = 0.0; }, | 4169 }, (e) { |
1947 (e) { return e is RangeError; }); | 4170 return e is RangeError; |
1948 Expect.throws(() { array.add(0.0); }, | 4171 }); |
1949 (e) { return e is UnsupportedError; }); | 4172 Expect.throws(() { |
1950 Expect.throws(() { array.addAll([0]); }, | 4173 view[10]; |
1951 (e) { return e is UnsupportedError; }); | 4174 }, (e) { |
1952 Expect.throws(() { array.clear(); }, | 4175 return e is RangeError; |
1953 (e) { return e is UnsupportedError; }); | 4176 }); |
1954 Expect.throws(() { array.length = 0; }, | 4177 Expect.throws(() { |
1955 (e) { return e is UnsupportedError; }); | 4178 view[10] = 0.0; |
1956 Expect.throws(() { array.removeLast(); }, | 4179 }, (e) { |
1957 (e) { return e is UnsupportedError; }); | 4180 return e is RangeError; |
1958 Expect.throws(() { array.removeRange(0, array.length - 1); }, | 4181 }); |
1959 (e) { return e is UnsupportedError; }); | 4182 Expect.throws(() { |
| 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 }); |
1960 for (int i = 0; i < view.length; ++i) { | 4212 for (int i = 0; i < view.length; ++i) { |
1961 view[i] = 1.0 + i; | 4213 view[i] = 1.0 + i; |
1962 } | 4214 } |
1963 Expect.listEquals([1.0, 2.0, 3.0, 4.0, 5.0, | 4215 Expect |
1964 6.0, 7.0, 8.0, 9.0, 10.0], | 4216 .listEquals([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], view); |
1965 view); | 4217 Expect.listEquals([ |
1966 Expect.listEquals([0xBF800000, 0x3F800000, | 4218 0xBF800000, |
1967 0x40000000, 0x40400000, | 4219 0x3F800000, |
1968 0x40800000, 0x40A00000, | 4220 0x40000000, |
1969 0x40C00000, 0x40E00000, | 4221 0x40400000, |
1970 0x41000000, 0x41100000, | 4222 0x40800000, |
1971 0x41200000, 0xBF800000], | 4223 0x40A00000, |
1972 array); | 4224 0x40C00000, |
| 4225 0x40E00000, |
| 4226 0x41000000, |
| 4227 0x41100000, |
| 4228 0x41200000, |
| 4229 0xBF800000 |
| 4230 ], array); |
1973 // TODO: min, max, and round | 4231 // TODO: min, max, and round |
1974 for (int i = 0; i < view.length; ++i) { | 4232 for (int i = 0; i < view.length; ++i) { |
1975 view[i] = i * 1.0; | 4233 view[i] = i * 1.0; |
1976 } | 4234 } |
1977 var copy = view.sublist(0, view.length); | 4235 var copy = view.sublist(0, view.length); |
1978 Expect.isFalse(identical(copy, view)); | 4236 Expect.isFalse(identical(copy, view)); |
1979 Expect.isTrue(copy is Float32List); | 4237 Expect.isTrue(copy is Float32List); |
1980 Expect.equals(10, copy.length); | 4238 Expect.equals(10, copy.length); |
1981 Expect.listEquals(view, copy); | 4239 Expect.listEquals(view, copy); |
1982 var region = view.sublist(3, view.length - 3); | 4240 var region = view.sublist(3, view.length - 3); |
1983 Expect.isTrue(copy is Float32List); | 4241 Expect.isTrue(copy is Float32List); |
1984 Expect.equals(4, region.length); | 4242 Expect.equals(4, region.length); |
1985 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 4243 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
1986 view.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 4244 view.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
1987 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 4245 Expect.listEquals([ |
1988 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 4246 0.0, |
1989 view); | 4247 1.0, |
1990 Expect.listEquals([0xBF800000, 0x00000000, | 4248 2.0, |
1991 0x3F800000, 0x40000000, | 4249 double.NEGATIVE_INFINITY, |
1992 0xFF800000, 0x00000000, | 4250 0.0, |
1993 0x3F800000, 0x7F800000, | 4251 1.0, |
1994 0x40E00000, 0x41000000, | 4252 double.INFINITY, |
1995 0x41100000, 0xBF800000], | 4253 7.0, |
1996 array); | 4254 8.0, |
| 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); |
1997 } | 4271 } |
1998 | 4272 |
1999 static testFloat32ListView() { | 4273 static testFloat32ListView() { |
2000 var array = new Uint32List(12); | 4274 var array = new Uint32List(12); |
2001 testFloat32ListViewImpl(array); | 4275 testFloat32ListViewImpl(array); |
2002 } | 4276 } |
2003 | 4277 |
2004 static testFloat64ListViewImpl(var array) { | 4278 static testFloat64ListViewImpl(var array) { |
2005 Expect.isTrue(array is List<int>); | 4279 Expect.isTrue(array is List<int>); |
2006 Expect.equals(12, array.length); | 4280 Expect.equals(12, array.length); |
2007 Expect.equals(8, array.elementSizeInBytes); | 4281 Expect.equals(8, array.elementSizeInBytes); |
2008 Expect.equals(96, array.lengthInBytes); | 4282 Expect.equals(96, array.lengthInBytes); |
2009 for (int i = 0; i < array.length; ++i) { | 4283 for (int i = 0; i < array.length; ++i) { |
2010 array[i] = 0xBFF0000000000000; | 4284 array[i] = 0xBFF0000000000000; |
2011 } | 4285 } |
2012 Expect.throws(() { new Float64List.view(array.buffer, -1); }, | 4286 Expect.throws(() { |
2013 (e) { return e is RangeError; }); | 4287 new Float64List.view(array.buffer, -1); |
2014 Expect.throws(() { new Float64List.view(array.buffer, 0, -1); }, | 4288 }, (e) { |
2015 (e) { return e is RangeError; }); | 4289 return e is RangeError; |
2016 Expect.throws(() { new Float64List.view(array.buffer, | 4290 }); |
2017 array.lengthInBytes + 1); }, | 4291 Expect.throws(() { |
2018 (e) { return e is RangeError; }); | 4292 new Float64List.view(array.buffer, 0, -1); |
2019 Expect.throws(() { new Float64List.view(array.buffer, | 4293 }, (e) { |
2020 0, array.lengthInBytes + 1); }, | 4294 return e is RangeError; |
2021 (e) { return e is RangeError; }); | 4295 }); |
2022 Expect.throws(() { new Float64List.view(array.buffer, | 4296 Expect.throws(() { |
2023 array.lengthInBytes - 1, 2); }, | 4297 new Float64List.view(array.buffer, array.lengthInBytes + 1); |
2024 (e) { return e is RangeError; }); | 4298 }, (e) { |
2025 var empty = new Float64List.view(array.buffer, | 4299 return e is RangeError; |
2026 array.lengthInBytes); | 4300 }); |
| 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); |
2027 Expect.isTrue(empty is List<double>); | 4312 Expect.isTrue(empty is List<double>); |
2028 Expect.isTrue(empty is Float64List); | 4313 Expect.isTrue(empty is Float64List); |
2029 Expect.equals(0, empty.length); | 4314 Expect.equals(0, empty.length); |
2030 var whole = new Float64List.view(array.buffer); | 4315 var whole = new Float64List.view(array.buffer); |
2031 Expect.isTrue(whole is List<double>); | 4316 Expect.isTrue(whole is List<double>); |
2032 Expect.isTrue(whole is Float64List); | 4317 Expect.isTrue(whole is Float64List); |
2033 Expect.equals(12, whole.length); | 4318 Expect.equals(12, whole.length); |
2034 var view = new Float64List.view(array.buffer, 8, 10); | 4319 var view = new Float64List.view(array.buffer, 8, 10); |
2035 Expect.isTrue(view is List<double>); | 4320 Expect.isTrue(view is List<double>); |
2036 Expect.isTrue(view is Float64List); | 4321 Expect.isTrue(view is Float64List); |
2037 Expect.equals(10, view.length); | 4322 Expect.equals(10, view.length); |
2038 Expect.equals(8, view.elementSizeInBytes); | 4323 Expect.equals(8, view.elementSizeInBytes); |
2039 Expect.equals(80, view.lengthInBytes); | 4324 Expect.equals(80, view.lengthInBytes); |
2040 Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0, | 4325 Expect.listEquals( |
2041 -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); |
2042 view); | 4327 Expect.throws(() { |
2043 Expect.throws(() { view[-1] = 0.0; }, | 4328 view[-1] = 0.0; |
2044 (e) { return e is RangeError; }); | 4329 }, (e) { |
2045 Expect.throws(() { return view[-1]; }, | 4330 return e is RangeError; |
2046 (e) { return e is RangeError; }); | 4331 }); |
2047 Expect.throws(() { view[10]; }, | 4332 Expect.throws(() { |
2048 (e) { return e is RangeError; }); | 4333 return view[-1]; |
2049 Expect.throws(() { view[10] = 0.0; }, | 4334 }, (e) { |
2050 (e) { return e is RangeError; }); | 4335 return e is RangeError; |
2051 Expect.throws(() { array.add(0.0); }, | 4336 }); |
2052 (e) { return e is UnsupportedError; }); | 4337 Expect.throws(() { |
2053 Expect.throws(() { array.addAll([0]); }, | 4338 view[10]; |
2054 (e) { return e is UnsupportedError; }); | 4339 }, (e) { |
2055 Expect.throws(() { array.clear(); }, | 4340 return e is RangeError; |
2056 (e) { return e is UnsupportedError; }); | 4341 }); |
2057 Expect.throws(() { array.length = 0; }, | 4342 Expect.throws(() { |
2058 (e) { return e is UnsupportedError; }); | 4343 view[10] = 0.0; |
2059 Expect.throws(() { array.removeLast(); }, | 4344 }, (e) { |
2060 (e) { return e is UnsupportedError; }); | 4345 return e is RangeError; |
2061 Expect.throws(() { array.removeRange(0, array.length - 1); }, | 4346 }); |
2062 (e) { return e is UnsupportedError; }); | 4347 Expect.throws(() { |
| 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 }); |
2063 for (int i = 0; i < view.length; ++i) { | 4377 for (int i = 0; i < view.length; ++i) { |
2064 view[i] = 1.0 + i; | 4378 view[i] = 1.0 + i; |
2065 } | 4379 } |
2066 Expect.listEquals([1.0, 2.0, 3.0, 4.0, 5.0, | 4380 Expect |
2067 6.0, 7.0, 8.0, 9.0, 10.0], | 4381 .listEquals([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], view); |
2068 view); | 4382 Expect.listEquals([ |
2069 Expect.listEquals([0xBFF0000000000000, 0x3FF0000000000000, | 4383 0xBFF0000000000000, |
2070 0x4000000000000000, 0x4008000000000000, | 4384 0x3FF0000000000000, |
2071 0x4010000000000000, 0x4014000000000000, | 4385 0x4000000000000000, |
2072 0x4018000000000000, 0x401C000000000000, | 4386 0x4008000000000000, |
2073 0x4020000000000000, 0x4022000000000000, | 4387 0x4010000000000000, |
2074 0x4024000000000000, 0xBFF0000000000000], | 4388 0x4014000000000000, |
2075 array); | 4389 0x4018000000000000, |
| 4390 0x401C000000000000, |
| 4391 0x4020000000000000, |
| 4392 0x4022000000000000, |
| 4393 0x4024000000000000, |
| 4394 0xBFF0000000000000 |
| 4395 ], array); |
2076 // TODO: min, max | 4396 // TODO: min, max |
2077 for (int i = 0; i < view.length; ++i) { | 4397 for (int i = 0; i < view.length; ++i) { |
2078 view[i] = i * 1.0; | 4398 view[i] = i * 1.0; |
2079 } | 4399 } |
2080 var copy = view.sublist(0, view.length); | 4400 var copy = view.sublist(0, view.length); |
2081 Expect.isFalse(identical(copy, view)); | 4401 Expect.isFalse(identical(copy, view)); |
2082 Expect.isTrue(copy is Float64List); | 4402 Expect.isTrue(copy is Float64List); |
2083 Expect.equals(10, copy.length); | 4403 Expect.equals(10, copy.length); |
2084 Expect.listEquals(view, copy); | 4404 Expect.listEquals(view, copy); |
2085 var region = view.sublist(3, view.length - 3); | 4405 var region = view.sublist(3, view.length - 3); |
2086 Expect.isTrue(copy is Float64List); | 4406 Expect.isTrue(copy is Float64List); |
2087 Expect.equals(4, region.length); | 4407 Expect.equals(4, region.length); |
2088 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); | 4408 Expect.listEquals([3.0, 4.0, 5.0, 6.0], region); |
2089 view.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); | 4409 view.setRange(3, 7, [double.NEGATIVE_INFINITY, 0.0, 1.0, double.INFINITY]); |
2090 Expect.listEquals([0.0, 1.0, 2.0, double.NEGATIVE_INFINITY, 0.0, | 4410 Expect.listEquals([ |
2091 1.0, double.INFINITY, 7.0, 8.0, 9.0], | 4411 0.0, |
2092 view); | 4412 1.0, |
2093 Expect.listEquals([0xBFF0000000000000, 0x0000000000000000, | 4413 2.0, |
2094 0x3FF0000000000000, 0x4000000000000000, | 4414 double.NEGATIVE_INFINITY, |
2095 0xFFF0000000000000, 0x0000000000000000, | 4415 0.0, |
2096 0x3FF0000000000000, 0x7FF0000000000000, | 4416 1.0, |
2097 0x401C000000000000, 0x4020000000000000, | 4417 double.INFINITY, |
2098 0x4022000000000000, 0xBFF0000000000000], | 4418 7.0, |
2099 array); | 4419 8.0, |
| 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); |
2100 } | 4436 } |
2101 | 4437 |
2102 static testFloat64ListView() { | 4438 static testFloat64ListView() { |
2103 var array = new Uint64List(12); | 4439 var array = new Uint64List(12); |
2104 testFloat64ListViewImpl(array); | 4440 testFloat64ListViewImpl(array); |
2105 } | 4441 } |
2106 | 4442 |
2107 static testMain() { | 4443 static testMain() { |
2108 testInt8List(); | 4444 testInt8List(); |
2109 testUint8List(); | 4445 testUint8List(); |
(...skipping 13 matching lines...) Expand all Loading... |
2123 testInt32ListView(); | 4459 testInt32ListView(); |
2124 testUint32ListView(); | 4460 testUint32ListView(); |
2125 testInt64ListView(); | 4461 testInt64ListView(); |
2126 testUint64ListView(); | 4462 testUint64ListView(); |
2127 testFloat32ListView(); | 4463 testFloat32ListView(); |
2128 testFloat64ListView(); | 4464 testFloat64ListView(); |
2129 } | 4465 } |
2130 } | 4466 } |
2131 | 4467 |
2132 main() { | 4468 main() { |
2133 for (var i=0; i<20; i++) { | 4469 for (var i = 0; i < 20; i++) { |
2134 OptimizedByteArrayTest.testMain(); | 4470 OptimizedByteArrayTest.testMain(); |
2135 } | 4471 } |
2136 } | 4472 } |
OLD | NEW |