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