Merge pull request #5406 from kumpera/fix_12157
[mono.git] / mono / mini / basic-long.cs
index 91d2ffdc5fb50f18fd87eb00414bc539a68386d6..82eb5befe7dd3b2b3a6b1153bf7cc70d65beee1f 100644 (file)
@@ -23,11 +23,18 @@ using System.Reflection;
  * the IL code looks.
  */
 
-class Tests {
+#if __MOBILE__
+class LongTests
+#else
+class Tests
+#endif
+{
 
-       public static int Main () {
-               return TestDriver.RunTests (typeof (Tests));
+#if !__MOBILE__
+       public static int Main (string[] args) {
+               return TestDriver.RunTests (typeof (Tests), args);
        }
+#endif
 
        public static int test_10_simple_cast () {
                long a = 10;
@@ -349,6 +356,17 @@ class Tests {
                return (int)(a & 8);
        }
 
+       public static int get_high_bit (ulong a) {
+               if ((a & 0x8000000000000000) != 0)
+                       return 1;
+               return 0;
+       }
+
+       public static int test_1_and () {
+               ulong a = 0xabcd1234deadbeef;
+               return get_high_bit (a);
+       }
+
        public static int test_10_or () {
                long a = 8;
                long b = 2;             
@@ -1003,26 +1021,6 @@ class Tests {
                return 0;
        }
 
-       static long return_5low () {
-               return 5;
-       }
-       
-       static long return_5high () {
-               return 0x500000000;
-       }
-
-       public static int test_3_long_ret () {
-               long val = return_5low ();
-               return (int) (val - 2);
-       }
-
-       public static int test_1_long_ret2 () {
-               long val = return_5high ();
-               if (val > 0xffffffff)
-                       return 1;
-               return 0;
-       }
-
        public static int test_3_byte_cast () {
                ulong val = 0xff00ff00f0f0f0f0;
                byte b;
@@ -1183,5 +1181,87 @@ class Tests {
 
                return t == 0 ? 0 : 1;
        }
+
+       public static int test_0_conv_u () {
+               unsafe {
+                       int** dead = (int**) 0xdeadbeaf;
+                       long i = (long)dead;
+                       return (i == 0xdeadbeaf) ? 0 : 1;
+               }
+       }
+
+       public static int test_0_lconv_to_u2 () {
+               unchecked { 
+                       ulong value = (ulong)(short)-10;
+                       value = (ushort)value;
+                   return (value == 65526) ? 0 : 1;
+               }
+       }
+
+       public static int test_0_lneg_regress_10320 () {
+               long a = 0x100000000;
+               ulong c = ((ulong) (-(-a))) >> 32;
+               return c == 1 ? 0 : 1;
+       }
+
+       public static int test_6_lrem_un () {
+               ulong r2 = 4294967296;
+               uint d = 10;
+               ulong res = r2 % d;
+
+               return (int)res;
+       }
+
+       public static int test_0_lrem_imm_1 () {
+               long b = 12L;
+               return (int)(b % 1L);
+       }
+
+       public static int test_0_lrem_imm_1_neg () {
+               long b = -2L;
+               return (int)(b % 1L);
+       }
+
+       public static int test_0_lrem_imm_2 ()
+       {
+               long x = 245345634L;
+               return (int)(x % 2L);
+       }
+
+       public static int test_1_lrem_imm_2 ()
+       {
+               long x = 24534553245L;
+               return (int)(x % 2L);
+       }
+
+       public static int test_1_lrem_imm_2_neg ()
+       {
+               long x = -24534553245L;
+               return -(int)(x % 2L);
+       }
+
+       public static int test_13_lrem_imm_32 ()
+       {
+               long x = 17389L;
+               return (int)(x % 32L);
+       }
+
+       public static int test_27_lrem_imm_32_neg ()
+       {
+               long x = -2435323L;
+               return -(int)(x % 32L);
+       }
+
+       public static int test_5_lrem_imm_large ()
+       {
+               long x = 0x1000000005L;
+               return (int)(x % 0x40000000L);
+       }
+
+       public static int test_5_lrem_imm_too_large ()
+       {
+               long x = 0x1000000005L;
+               return (int)(x % 0x80000000L);
+       }
 }