| OLD | NEW |
| (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 unalignedUint16() { |
| 10 var bytes = new ByteData(64); |
| 11 for (var i = 0; i < 2; i++) { |
| 12 bytes.setUint16(i, 0xABCD); |
| 13 Expect.equals(0xABCD, bytes.getUint16(i)); |
| 14 } |
| 15 } |
| 16 |
| 17 unalignedInt16() { |
| 18 var bytes = new ByteData(64); |
| 19 for (var i = 0; i < 2; i++) { |
| 20 bytes.setInt16(i, -0x1234); |
| 21 Expect.equals(-0x1234, bytes.getInt16(i)); |
| 22 } |
| 23 } |
| 24 |
| 25 unalignedUint32() { |
| 26 var bytes = new ByteData(64); |
| 27 for (var i = 0; i < 4; i++) { |
| 28 bytes.setUint32(i, 0xABCDABCD); |
| 29 Expect.equals(0xABCDABCD, bytes.getUint32(i)); |
| 30 } |
| 31 } |
| 32 |
| 33 unalignedInt32() { |
| 34 var bytes = new ByteData(64); |
| 35 for (var i = 0; i < 4; i++) { |
| 36 bytes.setInt32(i, -0x12341234); |
| 37 Expect.equals(-0x12341234, bytes.getInt32(i)); |
| 38 } |
| 39 } |
| 40 |
| 41 unalignedUint64() { |
| 42 var bytes = new ByteData(64); |
| 43 for (var i = 0; i < 8; i++) { |
| 44 bytes.setUint64(i, 0xABCDABCD); |
| 45 Expect.equals(0xABCDABCD, bytes.getUint64(i)); |
| 46 } |
| 47 } |
| 48 |
| 49 unalignedInt64() { |
| 50 var bytes = new ByteData(64); |
| 51 for (var i = 0; i < 8; i++) { |
| 52 bytes.setInt64(i, -0x12341234); |
| 53 Expect.equals(-0x12341234, bytes.getInt64(i)); |
| 54 } |
| 55 } |
| 56 |
| 57 unalignedFloat32() { |
| 58 var bytes = new ByteData(64); |
| 59 for (var i = 0; i < 4; i++) { |
| 60 bytes.setFloat32(i, 16.25); |
| 61 Expect.equals(16.25, bytes.getFloat32(i)); |
| 62 } |
| 63 } |
| 64 |
| 65 unalignedFloat64() { |
| 66 var bytes = new ByteData(64); |
| 67 for (var i = 0; i < 8; i++) { |
| 68 bytes.setFloat64(i, 16.25); |
| 69 Expect.equals(16.25, bytes.getFloat64(i)); |
| 70 } |
| 71 } |
| 72 |
| 73 main() { |
| 74 for (var i = 0; i < 20; i++) { |
| 75 unalignedUint16(); |
| 76 unalignedInt16(); |
| 77 unalignedUint32(); |
| 78 unalignedInt32(); |
| 79 unalignedUint64(); |
| 80 unalignedInt64(); |
| 81 unalignedFloat32(); |
| 82 unalignedFloat64(); |
| 83 } |
| 84 } |
| OLD | NEW |