Index: tests/language/src/BitOperationsTest.dart |
diff --git a/tests/language/src/BitOperationsTest.dart b/tests/language/src/BitOperationsTest.dart |
index 2dd0a313fa7fc77d019ef4678b7bc296e176f449..173f80f960329b30cc4b554a2b133e80b446f4b5 100644 |
--- a/tests/language/src/BitOperationsTest.dart |
+++ b/tests/language/src/BitOperationsTest.dart |
@@ -1,7 +1,10 @@ |
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-// Dart test for testing bitwise operations. |
+// Dart test for testing bitwise operations. This test only includes small |
+// enough numbers that even a dart implementation with the JS exemption is |
+// expected to pass them. See BitOperationsVMTest for the tests that a |
+// fully spec compliant implementation is expected to pass. |
class BitOperationsTest { |
static testMain() { |
@@ -17,38 +20,29 @@ class BitOperationsTest { |
Expect.equals(400, (100 << 2)); |
Expect.equals(-25, (-100 >> 2)); |
Expect.equals(-101, ~100); |
- Expect.equals(0x10000000000000000, 1 << 64); |
- Expect.equals(-0x10000000000000000, -1 << 64); |
+ Expect.equals(0x10000000, 1 << 28); |
Ivan Posva
2012/01/13 00:54:25
Isn't the range representable in bit operations in
|
+ Expect.equals(-0x10000000, -1 << 28); |
Expect.equals(0x40000000, 0x04000000 << 4); |
- Expect.equals(0x4000000000000000, 0x0400000000000000 << 4); |
+ Expect.equals(0x4000000, 0x0400000 << 4); |
Expect.equals(0, ~-1); |
Expect.equals(-1, ~0); |
- Expect.equals(0, 1 >> 160); |
- Expect.equals(-1, -1 >> 160); |
+ Expect.equals(0x10100F01, 0x10000001 | 0x10100F01); |
+ Expect.equals(0x10100F11, 0x11 | 0x10100F01); |
+ Expect.equals(0x10100F11, 0x10100F01 | 0x11); |
- Expect.equals(0x100000000000000001, |
- 0x100000000000000001 & 0x100000100F00000001); |
- Expect.equals(0x1, 0x1 & 0x100000100F00000001); |
- Expect.equals(0x1, 0x100000100F00000001 & 0x1); |
+ Expect.equals(0x0F000F0, |
+ 0x0F00F1 ^ 0xFF0001); |
- Expect.equals(0x100000100F00000001, |
- 0x100000000000000001 | 0x100000100F00000001); |
- Expect.equals(0x100000100F00000011, 0x11 | 0x100000100F00000001); |
- Expect.equals(0x100000100F00000011, 0x100000100F00000001 | 0x11); |
+ Expect.equals(0x31, 0xF0F0001 ^ 0xF0F0030); |
+ Expect.equals(0xF0F0031, 0xF0F0001 ^ 0x30); |
+ Expect.equals(0xF0F0031, 0x30 ^ 0xF0F0001); |
- Expect.equals(0x0F000F00000000000000, |
- 0x0F00F00000000000001 ^ 0xFF00000000000000001); |
- Expect.equals(0x31, 0xF00F00000000000001 ^ 0xF00F00000000000030); |
- Expect.equals(0xF00F00000000000031, 0xF00F00000000000001 ^ 0x30); |
- Expect.equals(0xF00F00000000000031, 0x30 ^ 0xF00F00000000000001); |
+ Expect.equals(0xF0000F, 0xF0000F7 >> 4); |
+ Expect.equals(15, 0xF000000 >> 24); |
- Expect.equals(0xF0000000000000000F, 0xF0000000000000000F7 >> 4); |
- Expect.equals(15, 0xF00000000 >> 32); |
- Expect.equals(1030792151040, 16492674416655 >> 4); |
- |
- Expect.equals(0xF0000000000000000F0, 0xF0000000000000000F << 4); |
- Expect.equals(0xF00000000, 15 << 32); |
+ Expect.equals(0xF0000F0, 0xF0000F << 4); |
+ Expect.equals(0xF000000, 15 << 24); |
TestNegativeValueShifts(); |
TestPositiveValueShifts(); |
@@ -57,7 +51,7 @@ class BitOperationsTest { |
static void TestNegativeValueShifts() { |
for (int value = 0; value > -100; value--) { |
- for (int i = 0; i < 300; i++) { |
+ for (int i = 0; i < 24; i++) { |
int b = (value << i) >> i; |
Expect.equals(value, b); |
} |
@@ -66,7 +60,7 @@ class BitOperationsTest { |
static void TestPositiveValueShifts() { |
for (int value = 0; value < 100; value++) { |
- for (int i = 0; i < 300; i++) { |
+ for (int i = 0; i < 24; i++) { |
int b = (value << i) >> i; |
Expect.equals(value, b); |
} |
@@ -76,14 +70,14 @@ class BitOperationsTest { |
static void TestNoMaskingOfShiftCount() { |
// Shifts which would behave differently if shift count was masked into a |
// range. |
- Expect.equals(0, 0 >> 256); |
- Expect.equals(0, 1 >> 256); |
- Expect.equals(0, 2 >> 256); |
- Expect.equals(0, ShiftRight(0, 256)); |
- Expect.equals(0, ShiftRight(1, 256)); |
- Expect.equals(0, ShiftRight(2, 256)); |
+ Expect.equals(0, 0 >> 30); |
Ivan Posva
2012/01/13 00:54:25
Not sure about this. Does the JS exemption also re
kasperl
2012/01/16 08:37:32
This is an interesting question. We clearly need t
|
+ Expect.equals(0, 1 >> 30); |
+ Expect.equals(0, 2 >> 30); |
+ Expect.equals(0, ShiftRight(0, 30)); |
+ Expect.equals(0, ShiftRight(1, 30)); |
+ Expect.equals(0, ShiftRight(2, 30)); |
- for (int shift = 1; shift <= 256; shift++) { |
+ for (int shift = 1; shift <= 30; shift++) { |
Expect.equals(0, ShiftRight(1, shift)); |
Expect.equals(-1, ShiftRight(-1, shift)); |
Expect.equals(true, ShiftLeft(1, shift) > ShiftLeft(1, shift - 1)); |