if (b != 127)
return -20;
- try {
- l = 0x00000000ffffffff;
- failed = true;
- checked {
- b = (sbyte)l;
- }
- } catch (OverflowException) {
- failed = false;
- }
- if (failed)
- return 21;
- if (b != 127)
- return -21;
-
return 0;
}
if (failed)
return 16;
+ try {
+ l = 0x00000000ffffffff;
+ failed = true;
+ checked {
+ b = (short)l;
+ }
+ } catch (OverflowException) {
+ failed = false;
+ }
+ if (failed)
+ return 17;
+
return 0;
}
if (failed)
return 9;
+ try {
+ ulong ul = (long)(System.Int32.MaxValue) + 1;
+ failed = true;
+ checked {
+ a = (int)ul;
+ }
+ }
+ catch (OverflowException) {
+ failed = false;
+ }
+ if (failed)
+ return 10;
+
+
{
int i;
float f = 1.1f;
if (failed)
return 2;
-
try {
double d = System.Int64.MinValue - 1024.0;
failed = false;
ulong a;
bool failed;
+ /*
+ * These tests depend on properties of x86 fp arithmetic so they won't work
+ * on other platforms.
+ */
+
+ /*
try {
double d = System.UInt64.MaxValue - 1024.0;
failed = true;
}
if (failed)
return 2;
-
+ */
try {
double d = 0;
if ((uint)d != 4294967295)
return 1;
+ /*
+ * These tests depend on properties of x86 fp arithmetic so they won't work
+ * on other platforms.
+ */
+ /*
d = 0xffffffffffffffff;
if ((ulong)d != 0)
if ((byte)d != 0)
return 4;
+ */
d = 0xffff;
ThrowClass.rethrow2 ();
}
catch (Exception ex) {
+ // Check that each catch clause has its own exception variable
+ // If not, the throw below will overwrite the exception used
+ // by the rethrow
+ try {
+ throw new DivideByZeroException ();
+ }
+ catch (Exception foo) {
+ }
+
throw;
}
}
return 1;
}
}
+
+ static int test_0_array_size () {
+ bool failed;
+
+ try {
+ failed = true;
+ int[] mem1 = new int [Int32.MaxValue];
+ }
+ catch (OutOfMemoryException e) {
+ failed = false;
+ }
+ if (failed)
+ return 1;
+
+ try {
+ failed = true;
+ int[,] mem2 = new int [Int32.MaxValue, Int32.MaxValue];
+ }
+ catch (OutOfMemoryException e) {
+ failed = false;
+ }
+ if (failed)
+ return 2;
+
+ return 0;
+ }
+
+ struct S {
+ int i, j, k, l, m, n;
+ }
+
+ static IntPtr[] addr;
+
+ static unsafe void throw_func (int i, S s) {
+ addr [i] = new IntPtr (&i);
+ throw new Exception ();
+ }
+
+ /* Test that arguments are correctly popped off the stack during unwinding */
+ static int test_0_stack_unwind () {
+ addr = new IntPtr [1000];
+ S s = new S ();
+ for (int j = 0; j < 1000; j++) {
+ try {
+ throw_func (j, s);
+ }
+ catch (Exception) {
+ }
+ }
+ return (addr [0].ToInt64 () - addr [100].ToInt64 () < 100) ? 0 : 1;
+ }
}