| 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 bytes.setUint16(0, 0xABCD); | |
| 12 Expect.equals(0xABCD, bytes.getUint16(0)); | |
| 13 bytes.setUint16(1, 0xBCDE); | |
| 14 Expect.equals(0xBCDE, bytes.getUint16(1)); | |
| 15 } | |
| 16 | |
| 17 unalignedInt16() { | |
| 18 var bytes = new ByteData(64); | |
| 19 bytes.setInt16(0, -0x1234); | |
| 20 Expect.equals(-0x1234, bytes.getInt16(0)); | |
| 21 bytes.setInt16(1, -0x2345); | |
| 22 Expect.equals(-0x2345, bytes.getInt16(1)); | |
| 23 } | |
| 24 | |
| 25 unalignedUint32() { | |
| 26 var bytes = new ByteData(64); | |
| 27 bytes.setUint32(0, 0xABCDABCD); | |
| 28 Expect.equals(0xABCDABCD, bytes.getUint32(0)); | |
| 29 bytes.setUint32(1, 0xBCDEBCDE); | |
| 30 Expect.equals(0xBCDEBCDE, bytes.getUint32(1)); | |
| 31 bytes.setUint32(2, 0xABCDABCD); | |
| 32 Expect.equals(0xABCDABCD, bytes.getUint32(2)); | |
| 33 bytes.setUint32(3, 0xBCDEBCDE); | |
| 34 Expect.equals(0xBCDEBCDE, bytes.getUint32(3)); | |
| 35 } | |
| 36 | |
| 37 unalignedInt32() { | |
| 38 var bytes = new ByteData(64); | |
| 39 bytes.setInt32(0, -0x12341234); | |
| 40 Expect.equals(-0x12341234, bytes.getInt32(0)); | |
| 41 bytes.setInt32(1, -0x23452345); | |
| 42 Expect.equals(-0x23452345, bytes.getInt32(1)); | |
| 43 bytes.setInt32(2, -0x12341234); | |
| 44 Expect.equals(-0x12341234, bytes.getInt32(2)); | |
| 45 bytes.setInt32(3, -0x23452345); | |
| 46 Expect.equals(-0x23452345, bytes.getInt32(3)); | |
| 47 } | |
| 48 | |
| 49 unalignedUint64() { | |
| 50 var bytes = new ByteData(64); | |
| 51 bytes.setUint64(0, 0xABCDABCD); | |
| 52 Expect.equals(0xABCDABCD, bytes.getUint64(0)); | |
| 53 bytes.setUint64(1, 0xBCDEBCDE); | |
| 54 Expect.equals(0xBCDEBCDE, bytes.getUint64(1)); | |
| 55 bytes.setUint64(2, 0xABCDABCD); | |
| 56 Expect.equals(0xABCDABCD, bytes.getUint64(2)); | |
| 57 bytes.setUint64(3, 0xBCDEBCDE); | |
| 58 Expect.equals(0xBCDEBCDE, bytes.getUint64(3)); | |
| 59 bytes.setUint64(4, 0xABCDABCD); | |
| 60 Expect.equals(0xABCDABCD, bytes.getUint64(4)); | |
| 61 bytes.setUint64(5, 0xBCDEBCDE); | |
| 62 Expect.equals(0xBCDEBCDE, bytes.getUint64(5)); | |
| 63 bytes.setUint64(6, 0xABCDABCD); | |
| 64 Expect.equals(0xABCDABCD, bytes.getUint64(6)); | |
| 65 bytes.setUint64(7, 0xBCDEBCDE); | |
| 66 Expect.equals(0xBCDEBCDE, bytes.getUint64(7)); | |
| 67 } | |
| 68 | |
| 69 unalignedInt64() { | |
| 70 var bytes = new ByteData(64); | |
| 71 bytes.setInt64(0, -0x12341234); | |
| 72 Expect.equals(-0x12341234, bytes.getInt64(0)); | |
| 73 bytes.setInt64(1, -0x23452345); | |
| 74 Expect.equals(-0x23452345, bytes.getInt64(1)); | |
| 75 bytes.setInt64(2, -0x12341234); | |
| 76 Expect.equals(-0x12341234, bytes.getInt64(2)); | |
| 77 bytes.setInt64(3, -0x23452345); | |
| 78 Expect.equals(-0x23452345, bytes.getInt64(3)); | |
| 79 bytes.setInt64(4, -0x12341234); | |
| 80 Expect.equals(-0x12341234, bytes.getInt64(4)); | |
| 81 bytes.setInt64(5, -0x23452345); | |
| 82 Expect.equals(-0x23452345, bytes.getInt64(5)); | |
| 83 bytes.setInt64(6, -0x12341234); | |
| 84 Expect.equals(-0x12341234, bytes.getInt64(6)); | |
| 85 bytes.setInt64(7, -0x23452345); | |
| 86 Expect.equals(-0x23452345, bytes.getInt64(7)); | |
| 87 } | |
| 88 | |
| 89 unalignedFloat32() { | |
| 90 var bytes = new ByteData(64); | |
| 91 bytes.setFloat32(0, 16.25); | |
| 92 Expect.equals(16.25, bytes.getFloat32(0)); | |
| 93 bytes.setFloat32(1, 32.125); | |
| 94 Expect.equals(32.125, bytes.getFloat32(1)); | |
| 95 bytes.setFloat32(2, 16.25); | |
| 96 Expect.equals(16.25, bytes.getFloat32(2)); | |
| 97 bytes.setFloat32(3, 32.125); | |
| 98 Expect.equals(32.125, bytes.getFloat32(3)); | |
| 99 } | |
| 100 | |
| 101 unalignedFloat64() { | |
| 102 var bytes = new ByteData(64); | |
| 103 bytes.setFloat64(0, 16.25); | |
| 104 Expect.equals(16.25, bytes.getFloat64(0)); | |
| 105 bytes.setFloat64(1, 32.125); | |
| 106 Expect.equals(32.125, bytes.getFloat64(1)); | |
| 107 bytes.setFloat64(2, 16.25); | |
| 108 Expect.equals(16.25, bytes.getFloat64(2)); | |
| 109 bytes.setFloat64(3, 32.125); | |
| 110 Expect.equals(32.125, bytes.getFloat64(3)); | |
| 111 bytes.setFloat64(4, 16.25); | |
| 112 Expect.equals(16.25, bytes.getFloat64(4)); | |
| 113 bytes.setFloat64(5, 32.125); | |
| 114 Expect.equals(32.125, bytes.getFloat64(5)); | |
| 115 bytes.setFloat64(6, 16.25); | |
| 116 Expect.equals(16.25, bytes.getFloat64(6)); | |
| 117 bytes.setFloat64(7, 32.125); | |
| 118 Expect.equals(32.125, bytes.getFloat64(7)); | |
| 119 } | |
| 120 | |
| 121 main() { | |
| 122 for (var i = 0; i < 20; i++) { | |
| 123 unalignedUint16(); | |
| 124 unalignedInt16(); | |
| 125 unalignedUint32(); | |
| 126 unalignedInt32(); | |
| 127 unalignedUint64(); | |
| 128 unalignedInt64(); | |
| 129 unalignedFloat32(); | |
| 130 unalignedFloat64(); | |
| 131 } | |
| 132 } | |
| OLD | NEW |