| 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 // Library tag to be able to run in html test framework. | 7 // Library tag to be able to run in html test framework. |
| 8 library TypedDataTest; | 8 library TypedDataTest; |
| 9 | 9 |
| 10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 154 } |
| 155 | 155 |
| 156 typed_data[0] = 20; | 156 typed_data[0] = 20; |
| 157 typed_data[1] = 21; | 157 typed_data[1] = 21; |
| 158 typed_data[2] = 22; | 158 typed_data[2] = 22; |
| 159 list.setRange(0, 3, typed_data); | 159 list.setRange(0, 3, typed_data); |
| 160 for (int i = 0; i < 3; i++) { | 160 for (int i = 0; i < 3; i++) { |
| 161 Expect.equals(20 + i, list[i]); | 161 Expect.equals(20 + i, list[i]); |
| 162 } | 162 } |
| 163 | 163 |
| 164 typed_data.setRange(1, 2, const [8, 9]); | 164 typed_data.setRange(1, 3, const [8, 9]); |
| 165 Expect.equals(20, typed_data[0]); | 165 Expect.equals(20, typed_data[0]); |
| 166 Expect.equals(8, typed_data[1]); | 166 Expect.equals(8, typed_data[1]); |
| 167 Expect.equals(9, typed_data[2]); | 167 Expect.equals(9, typed_data[2]); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void testSetRange() { | 170 void testSetRange() { |
| 171 testSetRangeHelper(new Uint8List(3)); | 171 testSetRangeHelper(new Uint8List(3)); |
| 172 testSetRangeHelper(new Uint8List.transferable(3)); | 172 testSetRangeHelper(new Uint8List.transferable(3)); |
| 173 testSetRangeHelper(new Uint8ClampedList(3)); | 173 testSetRangeHelper(new Uint8ClampedList(3)); |
| 174 testSetRangeHelper(new Uint8ClampedList.transferable(3)); | 174 testSetRangeHelper(new Uint8ClampedList.transferable(3)); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void testIndexOutOfRangeHelper(typed_data) { | 177 void testIndexOutOfRangeHelper(typed_data) { |
| 178 List<int> list = const [0, 1, 2, 3]; | 178 List<int> list = const [0, 1, 2, 3]; |
| 179 | 179 |
| 180 Expect.throws(() { | 180 Expect.throws(() { |
| 181 typed_data.setRange(0, 4, list); | 181 typed_data.setRange(0, 4, list); |
| 182 }); | 182 }); |
| 183 | 183 |
| 184 Expect.throws(() { | 184 Expect.throws(() { |
| 185 typed_data.setRange(3, 1, list); | 185 typed_data.setRange(3, 4, list); |
| 186 }); | 186 }); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void testIndexOutOfRange() { | 189 void testIndexOutOfRange() { |
| 190 testIndexOutOfRangeHelper(new Uint8List(3)); | 190 testIndexOutOfRangeHelper(new Uint8List(3)); |
| 191 testIndexOutOfRangeHelper(new Uint8List.transferable(3)); | 191 testIndexOutOfRangeHelper(new Uint8List.transferable(3)); |
| 192 testIndexOutOfRangeHelper(new Uint8ClampedList(3)); | 192 testIndexOutOfRangeHelper(new Uint8ClampedList(3)); |
| 193 testIndexOutOfRangeHelper(new Uint8ClampedList.transferable(3)); | 193 testIndexOutOfRangeHelper(new Uint8ClampedList.transferable(3)); |
| 194 } | 194 } |
| 195 | 195 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 testGetAtIndex(float64list, 1.4260258159703532e-105); | 393 testGetAtIndex(float64list, 1.4260258159703532e-105); |
| 394 } | 394 } |
| 395 testTypedDataRange(true); | 395 testTypedDataRange(true); |
| 396 testUnsignedTypedDataRange(true); | 396 testUnsignedTypedDataRange(true); |
| 397 testExternalClampedUnsignedTypedDataRange(true); | 397 testExternalClampedUnsignedTypedDataRange(true); |
| 398 testViewCreation(); | 398 testViewCreation(); |
| 399 testWhere(); | 399 testWhere(); |
| 400 testCreationFromList(); | 400 testCreationFromList(); |
| 401 } | 401 } |
| 402 | 402 |
| OLD | NEW |