2005-07-21 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mono / mini / basic.cs
index 96eac959b0cf66fd851762ffb6aa7c9c29b6d707..b56800cfc7d9ec1a39d995df76b78de04fc78fd9 100644 (file)
@@ -307,6 +307,90 @@ class Tests {
                return number == n ? 0 : 1;
        }
 
+       public static int test_0_sub_ovf () {
+               int i, j, k;
+
+               checked {
+                       i = System.Int32.MinValue;
+                       j = 0;
+                       k = i - j;
+               }
+
+               if (k != System.Int32.MinValue)
+                       return 1;
+
+               checked {
+                       i = System.Int32.MaxValue;
+                       j = 0;
+                       k = i - j;
+               }
+
+               if (k != System.Int32.MaxValue)
+                       return 2;
+
+               checked {
+                       i = System.Int32.MinValue;
+                       j = System.Int32.MinValue + 1234;
+                       k = i - j;
+               }
+
+               if (k != -1234)
+                       return 3;
+
+               checked {
+                       i = System.Int32.MaxValue;
+                       j = 1234;
+                       k = i - j;
+               }
+
+               if (k != System.Int32.MaxValue - 1234)
+                       return 4;
+
+               checked {
+                       i = System.Int32.MaxValue - 1234;
+                       j = -1234;
+                       k = i - j;
+               }
+
+               if (k != System.Int32.MaxValue)
+                       return 5;
+
+               checked {
+                       i = System.Int32.MinValue + 1234;
+                       j = 1234;
+                       k = i - j;
+               }
+
+               if (k != System.Int32.MinValue)
+                       return 6;
+
+               return 0;
+       }
+
+       public static int test_0_sub_ovf_un () {
+               uint i, j, k;
+
+               checked {
+                       i = System.UInt32.MaxValue;
+                       j = 0;
+                       k = i - j;
+               }
+
+               if (k != System.UInt32.MaxValue)
+                       return 1;
+
+               checked {
+                       i = System.UInt32.MaxValue;
+                       j = System.UInt32.MaxValue;
+                       k = i - j;
+               }
+
+               if (k != 0)
+                       return 2;
+
+               return 0;
+       }
+
        public static int test_3_or () {
                int b = 2;
                int a = 3;
@@ -641,6 +725,17 @@ class Tests {
                
                return 0;
        }
+
+       public static int test_0_conv_ovf_i4_un () {
+               uint c;
+
+               checked {
+                       c = 0x7fffffff;
+                       int b = (int)c;
+               }
+
+               return 0;
+       }
        
        public static int test_0_bool () {
                bool val = true;
@@ -755,15 +850,6 @@ class Tests {
                return 0;
        }
 
-       public static unsafe int test_0_pin_string () {
-               string x = "xxx";
-               fixed (char *c = x) {
-                       if (*c != 'x')
-                               return 1;
-               }
-               return 0;
-       }
-
        public static int test_3_shift_regalloc () {
                int shift = 8;
                int orig = 1;
@@ -927,33 +1013,9 @@ class Tests {
                
                return n;
        }
-       
-       public static int my_flags;
+
        public static int test_0_and_cmp ()
        {
-               
-               /* various forms of test [mem], imm */
-               
-               my_flags = 0x01020304;
-               
-               if ((my_flags & 0x01020304) == 0)
-                       return 1;
-               
-               if ((my_flags & 0x00000304) == 0)
-                       return 2;
-               
-               if ((my_flags & 0x00000004) == 0)
-                       return 3;
-               
-               if ((my_flags & 0x00000300) == 0)
-                       return 4;
-               
-               if ((my_flags & 0x00020000) == 0)
-                       return 5;
-               
-               if ((my_flags & 0x01000000) == 0)
-                       return 6;
-               
                /* test esi, imm */
                int local = 0x01020304;
                
@@ -974,7 +1036,7 @@ class Tests {
                
                if ((local & 0x01000000) == 0)
                        return 12;
-               
+
                return 0;
        }