OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 // VMOptions=--optimization_counter_threshold=10 --no-background_compilation | 4 // VMOptions=--optimization_counter_threshold=10 --no-background_compilation |
5 | 5 |
6 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 | 8 |
9 unalignedFloat32() { | 9 unalignedFloat32() { |
10 var bytes = new ByteData(64); | 10 var bytes = new ByteData(64); |
11 for (var i = 0; i < 4; i++) { | 11 for (var i = 0; i < 4; i++) { |
12 bytes.setFloat32(i, 16.25); | 12 bytes.setFloat32(i, 16.25, Endianness.HOST_ENDIAN); |
13 Expect.equals(16.25, bytes.getFloat32(i)); | 13 Expect.equals(16.25, bytes.getFloat32(i, Endianness.HOST_ENDIAN)); |
14 } | 14 } |
15 } | 15 } |
16 | 16 |
17 unalignedFloat64() { | 17 unalignedFloat64() { |
18 var bytes = new ByteData(64); | 18 var bytes = new ByteData(64); |
19 for (var i = 0; i < 8; i++) { | 19 for (var i = 0; i < 8; i++) { |
20 bytes.setFloat64(i, 16.25); | 20 bytes.setFloat64(i, 16.25, Endianness.HOST_ENDIAN); |
21 Expect.equals(16.25, bytes.getFloat64(i)); | 21 Expect.equals(16.25, bytes.getFloat64(i, Endianness.HOST_ENDIAN)); |
22 } | 22 } |
23 } | 23 } |
24 | 24 |
25 main() { | 25 main() { |
26 for (var i = 0; i < 20; i++) { | 26 for (var i = 0; i < 20; i++) { |
27 unalignedFloat32(); | 27 unalignedFloat32(); |
28 unalignedFloat64(); | 28 unalignedFloat64(); |
29 } | 29 } |
30 } | 30 } |
OLD | NEW |