Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: tests/language/vm/unaligned_float_access_literal_index_test.dart

Issue 2473553002: Fix unaligned access to TypedData from native code. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--optimization_counter_threshold=10 --no-background_compilation
5
6 import 'dart:typed_data';
7 import 'package:expect/expect.dart';
8
9 unalignedFloat32() {
10 var bytes = new ByteData(64);
11 bytes.setFloat32(0, 16.25);
12 Expect.equals(16.25, bytes.getFloat32(0));
13 bytes.setFloat32(1, 32.125);
14 Expect.equals(32.125, bytes.getFloat32(1));
15 bytes.setFloat32(2, 16.25);
16 Expect.equals(16.25, bytes.getFloat32(2));
17 bytes.setFloat32(3, 32.125);
18 Expect.equals(32.125, bytes.getFloat32(3));
19 }
20
21 unalignedFloat64() {
22 var bytes = new ByteData(64);
23 bytes.setFloat64(0, 16.25);
24 Expect.equals(16.25, bytes.getFloat64(0));
25 bytes.setFloat64(1, 32.125);
26 Expect.equals(32.125, bytes.getFloat64(1));
27 bytes.setFloat64(2, 16.25);
28 Expect.equals(16.25, bytes.getFloat64(2));
29 bytes.setFloat64(3, 32.125);
30 Expect.equals(32.125, bytes.getFloat64(3));
31 bytes.setFloat64(4, 16.25);
32 Expect.equals(16.25, bytes.getFloat64(4));
33 bytes.setFloat64(5, 32.125);
34 Expect.equals(32.125, bytes.getFloat64(5));
35 bytes.setFloat64(6, 16.25);
36 Expect.equals(16.25, bytes.getFloat64(6));
37 bytes.setFloat64(7, 32.125);
38 Expect.equals(32.125, bytes.getFloat64(7));
39 }
40
41 main() {
42 for (var i = 0; i < 20; i++) {
43 unalignedFloat32();
44 unalignedFloat64();
45 }
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698