Index: tests/language/bit_operations_test.dart |
=================================================================== |
--- tests/language/bit_operations_test.dart (revision 8116) |
+++ tests/language/bit_operations_test.dart (working copy) |
@@ -53,7 +53,35 @@ |
TestNegativeValueShifts(); |
TestPositiveValueShifts(); |
TestNoMaskingOfShiftCount(); |
+ TestNegativeCountShifts(); |
} |
+ |
+ static void TestNegativeCountShifts() { |
+ bool throwOnLeft(a, b) { |
+ try { |
+ var x = a << b; |
+ return false; |
+ } catch(var e) { |
+ return true; |
+ } |
+ } |
+ |
+ bool throwOnRight(a, b) { |
+ try { |
+ var x = a >> b; |
+ return false; |
+ } catch(var e) { |
+ return true; |
+ } |
+ } |
+ |
+ Expect.isTrue(throwOnLeft(12, -3)); |
+ Expect.isTrue(throwOnRight(12, -3)); |
+ for (int i = 0; i < 4000; i++) { |
+ Expect.isFalse(throwOnLeft(12, 3)); |
+ Expect.isFalse(throwOnRight(12, 3)); |
+ } |
+ } |
static void TestNegativeValueShifts() { |
for (int value = 0; value > -100; value--) { |