| 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 TypedArray; | 8 library TypedArray; |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 import 'dart:typeddata'; | 10 import 'dart:typeddata'; |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 } | 278 } |
| 279 | 279 |
| 280 | 280 |
| 281 // Float32 Array. | 281 // Float32 Array. |
| 282 Float32List initFloat32() { | 282 Float32List initFloat32() { |
| 283 var float32 = new Float32List(2); | 283 var float32 = new Float32List(2); |
| 284 float32[0] = 1.0; | 284 float32[0] = 1.0; |
| 285 float32[1] = 2.0; | 285 float32[1] = 2.0; |
| 286 return float32; | 286 return float32; |
| 287 } | 287 } |
| 288 Float32List float32 = new Float32List(2); | 288 Float32List float32 = initFloat32(); |
| 289 | 289 |
| 290 void float32_receiver() { | 290 void float32_receiver() { |
| 291 var sp = spawnFunction(float32_sender); | 291 var sp = spawnFunction(float32_sender); |
| 292 sp.call(float32.length).then((a) { | 292 sp.call(float32.length).then((a) { |
| 293 Expect.equals(float32.length, a.length); | 293 Expect.equals(float32.length, a.length); |
| 294 for (int i = 0; i < a.length; i++) { | 294 for (int i = 0; i < a.length; i++) { |
| 295 Expect.equals(float32[i], a[i]); | 295 Expect.equals(float32[i], a[i]); |
| 296 } | 296 } |
| 297 print("float32_receiver"); | 297 print("float32_receiver"); |
| 298 }); | 298 }); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 float64_sender() { | 333 float64_sender() { |
| 334 port.receive((len, r) { | 334 port.receive((len, r) { |
| 335 Expect.equals(float64.length, len); | 335 Expect.equals(float64.length, len); |
| 336 var a = new Float64List(len); | 336 var a = new Float64List(len); |
| 337 for (int i = 0; i < len; i++) { | 337 for (int i = 0; i < len; i++) { |
| 338 a[i] = float64[i]; | 338 a[i] = float64[i]; |
| 339 } | 339 } |
| 340 r.send(a); | 340 r.send(a); |
| 341 }); | 341 }); |
| 342 } | 342 } |
| OLD | NEW |