| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Dart test for testing bitwise operations. | 4 // Dart test for testing bitwise operations. |
| 5 | 5 |
| 6 class BitOperationsTest { | 6 class BitOperationsTest { |
| 7 static testMain() { | 7 static testMain() { |
| 8 for (int i = 0; i < 4; i++) { |
| 9 testOne(); |
| 10 } |
| 11 } |
| 12 static testOne() { |
| 8 Expect.equals(3, (3 & 7)); | 13 Expect.equals(3, (3 & 7)); |
| 9 Expect.equals(7, (3 | 7)); | 14 Expect.equals(7, (3 | 7)); |
| 10 Expect.equals(4, (3 ^ 7)); | 15 Expect.equals(4, (3 ^ 7)); |
| 11 Expect.equals(25, (100 >> 2)); | 16 Expect.equals(25, (100 >> 2)); |
| 12 Expect.equals(400, (100 << 2)); | 17 Expect.equals(400, (100 << 2)); |
| 13 Expect.equals(-25, (-100 >> 2)); | 18 Expect.equals(-25, (-100 >> 2)); |
| 14 Expect.equals(-101, ~100); | 19 Expect.equals(-101, ~100); |
| 15 Expect.equals(0x10000000000000000, 1 << 64); | 20 Expect.equals(0x10000000000000000, 1 << 64); |
| 16 Expect.equals(-0x10000000000000000, -1 << 64); | 21 Expect.equals(-0x10000000000000000, -1 << 64); |
| 22 Expect.equals(0x40000000, 0x04000000 << 4); |
| 23 Expect.equals(0x4000000000000000, 0x0400000000000000 << 4); |
| 17 Expect.equals(0, ~-1); | 24 Expect.equals(0, ~-1); |
| 18 Expect.equals(-1, ~0); | 25 Expect.equals(-1, ~0); |
| 19 | 26 |
| 20 Expect.equals(0, 1 >> 160); | 27 Expect.equals(0, 1 >> 160); |
| 21 Expect.equals(-1, -1 >> 160); | 28 Expect.equals(-1, -1 >> 160); |
| 22 | 29 |
| 23 Expect.equals(0x100000000000000001, | 30 Expect.equals(0x100000000000000001, |
| 24 0x100000000000000001 & 0x100000100F00000001); | 31 0x100000000000000001 & 0x100000100F00000001); |
| 25 Expect.equals(0x1, 0x1 & 0x100000100F00000001); | 32 Expect.equals(0x1, 0x1 & 0x100000100F00000001); |
| 26 Expect.equals(0x1, 0x100000100F00000001 & 0x1); | 33 Expect.equals(0x1, 0x100000100F00000001 & 0x1); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 90 } |
| 84 } | 91 } |
| 85 | 92 |
| 86 static int ShiftLeft(int a, int b) { return a << b; } | 93 static int ShiftLeft(int a, int b) { return a << b; } |
| 87 static int ShiftRight(int a, int b) { return a >> b; } | 94 static int ShiftRight(int a, int b) { return a >> b; } |
| 88 } | 95 } |
| 89 | 96 |
| 90 main() { | 97 main() { |
| 91 BitOperationsTest.testMain(); | 98 BitOperationsTest.testMain(); |
| 92 } | 99 } |
| OLD | NEW |