| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // Library tag to be able to run in html test framework. | |
| 6 library float32x4_list_test; | |
| 7 | |
| 8 import 'dart:scalarlist'; | |
| 9 | |
| 10 testLoadStore(array) { | |
| 11 Expect.equals(8, array.length); | |
| 12 Expect.isTrue(array is List<Float32x4>); | |
| 13 array[0] = new Float32x4(1.0, 2.0, 3.0, 4.0); | |
| 14 Expect.equals(1.0, array[0].x); | |
| 15 Expect.equals(2.0, array[0].y); | |
| 16 Expect.equals(3.0, array[0].z); | |
| 17 Expect.equals(4.0, array[0].w); | |
| 18 array[1] = array[0]; | |
| 19 array[0] = array[0].withX(9.0); | |
| 20 Expect.equals(9.0, array[0].x); | |
| 21 Expect.equals(2.0, array[0].y); | |
| 22 Expect.equals(3.0, array[0].z); | |
| 23 Expect.equals(4.0, array[0].w); | |
| 24 Expect.equals(1.0, array[1].x); | |
| 25 Expect.equals(2.0, array[1].y); | |
| 26 Expect.equals(3.0, array[1].z); | |
| 27 Expect.equals(4.0, array[1].w); | |
| 28 } | |
| 29 | |
| 30 testView(array) { | |
| 31 Expect.equals(8, array.length); | |
| 32 Expect.isTrue(array is List<Float32x4>); | |
| 33 Expect.equals(0.0, array[0].x); | |
| 34 Expect.equals(1.0, array[0].y); | |
| 35 Expect.equals(2.0, array[0].z); | |
| 36 Expect.equals(3.0, array[0].w); | |
| 37 Expect.equals(4.0, array[1].x); | |
| 38 Expect.equals(5.0, array[1].y); | |
| 39 Expect.equals(6.0, array[1].z); | |
| 40 Expect.equals(7.0, array[1].w); | |
| 41 } | |
| 42 | |
| 43 main() { | |
| 44 var list; | |
| 45 | |
| 46 list = new Float32x4List(8); | |
| 47 for (int i = 0; i < 3000; i++) { | |
| 48 testLoadStore(list); | |
| 49 } | |
| 50 | |
| 51 list = new Float32x4List.transferable(8); | |
| 52 for (int i = 0; i < 3000; i++) { | |
| 53 testLoadStore(list); | |
| 54 } | |
| 55 Float32List floatList = new Float32List(32); | |
| 56 for (int i = 0; i < floatList.length; i++) { | |
| 57 floatList[i] = i.toDouble(); | |
| 58 } | |
| 59 list = new Float32x4List.view(floatList.asByteArray()); | |
| 60 for (int i = 0; i < 3000; i++) { | |
| 61 testView(list); | |
| 62 } | |
| 63 for (int i = 0; i < 3000; i++) { | |
| 64 testLoadStore(list); | |
| 65 } | |
| 66 } | |
| OLD | NEW |