| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Dart test program for testing typed data. | 5 // Dart test program for testing typed data. |
| 6 | 6 |
| 7 // VMOptions=--optimization_counter_threshold=10 | 7 // VMOptions=--optimization_counter_threshold=10 |
| 8 | 8 |
| 9 // Library tag to be able to run in html test framework. | 9 // Library tag to be able to run in html test framework. |
| 10 library TypedDataTest; | 10 library TypedDataTest; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 Expect.equals(20, typed_data[0]); | 136 Expect.equals(20, typed_data[0]); |
| 137 Expect.equals(8, typed_data[1]); | 137 Expect.equals(8, typed_data[1]); |
| 138 Expect.equals(9, typed_data[2]); | 138 Expect.equals(9, typed_data[2]); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void testSetRange() { | 141 void testSetRange() { |
| 142 testSetRangeHelper(new Uint8List(3)); | 142 testSetRangeHelper(new Uint8List(3)); |
| 143 testSetRangeHelper(new Uint8ClampedList(3)); | 143 testSetRangeHelper(new Uint8ClampedList(3)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void testIndexOutOfRangeHelper(typed_data) { | 146 class C { |
| 147 final x; |
| 148 C(this.x); |
| 149 operator<(o) => false; |
| 150 operator>=(o) => false; |
| 151 operator*(o) => x; |
| 152 } |
| 153 |
| 154 void testIndexOutOfRangeHelper(typed_data, value) { |
| 147 List<int> list = const [0, 1, 2, 3]; | 155 List<int> list = const [0, 1, 2, 3]; |
| 148 | 156 |
| 149 Expect.throws(() { | 157 Expect.throws(() { |
| 150 typed_data.setRange(0, 4, list); | 158 typed_data.setRange(0, 4, list); |
| 151 }); | 159 }); |
| 152 | 160 |
| 153 Expect.throws(() { | 161 Expect.throws(() { |
| 154 typed_data.setRange(3, 4, list); | 162 typed_data.setRange(3, 4, list); |
| 155 }); | 163 }); |
| 164 |
| 165 Expect.throws(() { |
| 166 typed_data[new C(-4000000)] = value; |
| 167 }); |
| 168 |
| 169 Expect.throws(() { |
| 170 var size = typed_data.elementSizeInBytes; |
| 171 var i = (typed_data.length - 1) * size + 1; |
| 172 typed_data[new C(i)] = value; |
| 173 }); |
| 156 } | 174 } |
| 157 | 175 |
| 158 void testIndexOutOfRange() { | 176 void testIndexOutOfRange() { |
| 159 testIndexOutOfRangeHelper(new Uint8List(3)); | 177 testIndexOutOfRangeHelper(new Int8List(3), 0); |
| 160 testIndexOutOfRangeHelper(new Uint8ClampedList(3)); | 178 testIndexOutOfRangeHelper(new Uint8List(3), 0); |
| 179 testIndexOutOfRangeHelper(new Uint8ClampedList(3), 0); |
| 180 testIndexOutOfRangeHelper(new Int16List(3), 0); |
| 181 testIndexOutOfRangeHelper(new Uint16List(3), 0); |
| 182 testIndexOutOfRangeHelper(new Int32List(3), 0); |
| 183 testIndexOutOfRangeHelper(new Uint32List(3), 0); |
| 184 testIndexOutOfRangeHelper(new Int64List(3), 0); |
| 185 testIndexOutOfRangeHelper(new Uint64List(3), 0); |
| 186 testIndexOutOfRangeHelper(new Float32List(3), 0.0); |
| 187 testIndexOutOfRangeHelper(new Float64List(3), 0.0); |
| 161 } | 188 } |
| 162 | 189 |
| 163 void testIndexOfHelper(list) { | 190 void testIndexOfHelper(list) { |
| 164 for (int i = 0; i < list.length; i++) { | 191 for (int i = 0; i < list.length; i++) { |
| 165 list[i] = i + 10; | 192 list[i] = i + 10; |
| 166 } | 193 } |
| 167 Expect.equals(0, list.indexOf(10)); | 194 Expect.equals(0, list.indexOf(10)); |
| 168 Expect.equals(5, list.indexOf(15)); | 195 Expect.equals(5, list.indexOf(15)); |
| 169 Expect.equals(9, list.indexOf(19)); | 196 Expect.equals(9, list.indexOf(19)); |
| 170 Expect.equals(-1, list.indexOf(20)); | 197 Expect.equals(-1, list.indexOf(20)); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 testSetAtIndex(float64list, 1.4260258159703532e-105, true); | 398 testSetAtIndex(float64list, 1.4260258159703532e-105, true); |
| 372 testGetAtIndex(float64list, 1.4260258159703532e-105); | 399 testGetAtIndex(float64list, 1.4260258159703532e-105); |
| 373 } | 400 } |
| 374 testTypedDataRange(true); | 401 testTypedDataRange(true); |
| 375 testUnsignedTypedDataRange(true); | 402 testUnsignedTypedDataRange(true); |
| 376 testViewCreation(); | 403 testViewCreation(); |
| 377 testWhere(); | 404 testWhere(); |
| 378 testCreationFromList(); | 405 testCreationFromList(); |
| 379 } | 406 } |
| 380 | 407 |
| OLD | NEW |