| 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 // | 4 // |
| 5 // Dart test program for testing native float arrays. | 5 // Dart test program for testing native float arrays. |
| 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("FloatArrayTest.dart"); | 8 #library("FloatArrayTest.dart"); |
| 9 | 9 |
| 10 #import('dart:scalarlist'); | 10 #import('dart:scalarlist'); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 var list = new Float64List(10); | 170 var list = new Float64List(10); |
| 171 list[0] = 2.0; | 171 list[0] = 2.0; |
| 172 Expect.throws(() { | 172 Expect.throws(() { |
| 173 list[0] = 2; | 173 list[0] = 2; |
| 174 }); | 174 }); |
| 175 Expect.throws(() { | 175 Expect.throws(() { |
| 176 list[0] = "hello"; | 176 list[0] = "hello"; |
| 177 }); | 177 }); |
| 178 } | 178 } |
| 179 | 179 |
| 180 storeIt32(Float32List a, int index, value) { |
| 181 a[index] = value; |
| 182 } |
| 183 |
| 184 storeIt64(Float64List a, int index, value) { |
| 185 a[index] = value; |
| 186 } |
| 187 |
| 180 main() { | 188 main() { |
| 189 var a32 = new Float32List(5); |
| 181 for (int i = 0; i < 2000; i++) { | 190 for (int i = 0; i < 2000; i++) { |
| 182 testCreateFloat32Array(); | 191 testCreateFloat32Array(); |
| 183 testSetRange32(); | 192 testSetRange32(); |
| 184 testIndexOutOfRange32(); | 193 testIndexOutOfRange32(); |
| 185 testIndexOf32(); | 194 testIndexOf32(); |
| 195 storeIt32(a32, 1, 2.0); |
| 186 } | 196 } |
| 197 var a64 = new Float64List(5); |
| 187 for (int i = 0; i < 2000; i++) { | 198 for (int i = 0; i < 2000; i++) { |
| 188 testCreateFloat64Array(); | 199 testCreateFloat64Array(); |
| 189 testSetRange64(); | 200 testSetRange64(); |
| 190 testIndexOutOfRange64(); | 201 testIndexOutOfRange64(); |
| 191 testIndexOf64(); | 202 testIndexOf64(); |
| 203 storeIt64(a64, 1, 2.0); |
| 192 } | 204 } |
| 193 // These two take a long time in checked mode. | 205 // These two take a long time in checked mode. |
| 194 testBadValues32(); | 206 testBadValues32(); |
| 195 testBadValues64(); | 207 testBadValues64(); |
| 208 // Check optimized (inlined) version of []= |
| 209 Expect.throws(() { |
| 210 storeIt32(a32, 1, 2); |
| 211 }); |
| 212 Expect.throws(() { |
| 213 storeIt64(a64, 1, 2); |
| 214 }); |
| 196 } | 215 } |
| OLD | NEW |