more work on Integers.java

This commit is contained in:
Joel Dice 2009-03-13 18:36:11 -06:00
parent 1f35e5efb4
commit ef12477670

View File

@ -65,6 +65,33 @@ public class Integers {
expect(~a == ~5);
}
{ int a = -5;
expect(a >> 2 == -5 >> 2);
expect(a >>> 2 == -5 >>> 2);
expect(a << 2 == -5 << 2);
expect(a + 2 == -5 + 2);
expect(a - 2 == -5 - 2);
expect(a * 2 == -5 * 2);
expect(a / 2 == -5 / 2);
expect(a % 2 == -5 % 2);
expect((a & 2) == (-5 & 2));
expect((a | 2) == (-5 | 2));
expect((a ^ 2) == (-5 ^ 2));
a = 5;
expect(a >> 2 == 5 >> 2);
expect(a >>> 2 == 5 >>> 2);
expect(a << 2 == 5 << 2);
expect(a + 2 == 5 + 2);
expect(a - 2 == 5 - 2);
expect(a * 2 == 5 * 2);
expect(a / 2 == 5 / 2);
expect(a % 2 == 5 % 2);
expect((a & 2) == (5 & 2));
expect((a | 2) == (5 | 2));
expect((a ^ 2) == (5 ^ 2));
}
{ int a = -5;
int b = 1234567;
expect(a + b == -5 + 1234567);
@ -88,7 +115,28 @@ public class Integers {
expect((a ^ b) == (5 ^ 1234567));
}
{ int a = -1223457;
{ int a = -5;
expect(a + 1234567 == -5 + 1234567);
expect(a - 1234567 == -5 - 1234567);
expect(a * 1234567 == -5 * 1234567);
expect(a / 1234567 == -5 / 1234567);
expect(a % 1234567 == -5 % 1234567);
expect((a & 1234567) == (-5 & 1234567));
expect((a | 1234567) == (-5 | 1234567));
expect((a ^ 1234567) == (-5 ^ 1234567));
a = 5;
expect(a + 1234567 == 5 + 1234567);
expect(a - 1234567 == 5 - 1234567);
expect(a * 1234567 == 5 * 1234567);
expect(a / 1234567 == 5 / 1234567);
expect(a % 1234567 == 5 % 1234567);
expect((a & 1234567) == (5 & 1234567));
expect((a | 1234567) == (5 | 1234567));
expect((a ^ 1234567) == (5 ^ 1234567));
}
{ int a = -1234567;
int b = 2;
expect(a >> b == -1234567 >> 2);
expect(a >>> b == -1234567 >>> 2);
@ -121,7 +169,34 @@ public class Integers {
expect(~a == ~1234567);
}
{ int a = -1223457;
{ int a = -1234567;
expect(a >> 2 == -1234567 >> 2);
expect(a >>> 2 == -1234567 >>> 2);
expect(a << 2 == -1234567 << 2);
expect(a + 2 == -1234567 + 2);
expect(a - 2 == -1234567 - 2);
expect(a * 2 == -1234567 * 2);
expect(a / 2 == -1234567 / 2);
expect(a % 2 == -1234567 % 2);
expect((a & 2) == (-1234567 & 2));
expect((a | 2) == (-1234567 | 2));
expect((a ^ 2) == (-1234567 ^ 2));
a = 1234567;
expect(a >> 2 == 1234567 >> 2);
expect(a >>> 2 == 1234567 >>> 2);
expect(a << 2 == 1234567 << 2);
expect(a + 2 == 1234567 + 2);
expect(a - 2 == 1234567 - 2);
expect(a * 2 == 1234567 * 2);
expect(a / 2 == 1234567 / 2);
expect(a % 2 == 1234567 % 2);
expect((a & 2) == (1234567 & 2));
expect((a | 2) == (1234567 | 2));
expect((a ^ 2) == (1234567 ^ 2));
}
{ int a = -1234567;
int b = 1234567;
expect(a + b == -1234567 + 1234567);
expect(a - b == -1234567 - 1234567);
@ -144,6 +219,27 @@ public class Integers {
expect((a ^ b) == (1234567 ^ 1234567));
}
{ int a = -1234567;
expect(a + 1234567 == -1234567 + 1234567);
expect(a - 1234567 == -1234567 - 1234567);
expect(a * 1234567 == -1234567 * 1234567);
expect(a / 1234567 == -1234567 / 1234567);
expect(a % 1234567 == -1234567 % 1234567);
expect((a & 1234567) == (-1234567 & 1234567));
expect((a | 1234567) == (-1234567 | 1234567));
expect((a ^ 1234567) == (-1234567 ^ 1234567));
a = 1234567;
expect(a + 1234567 == 1234567 + 1234567);
expect(a - 1234567 == 1234567 - 1234567);
expect(a * 1234567 == 1234567 * 1234567);
expect(a / 1234567 == 1234567 / 1234567);
expect(a % 1234567 == 1234567 % 1234567);
expect((a & 1234567) == (1234567 & 1234567));
expect((a | 1234567) == (1234567 | 1234567));
expect((a ^ 1234567) == (1234567 ^ 1234567));
}
{ int get_buffer = 2144642881;
int bits_left = 30;
int l = 9;