Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / mini / basic-long.cs
index 63fa64db490d83bbfe08690752416ed36f81e487..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;
@@ -103,6 +110,8 @@ class Tests {
                long a = 0xffffffffff;
                if (a == 0xfffffffffe)
                        return 1;
+               if (a == 0xfeffffffff)
+                       return 2;
                return 0;
        }
 
@@ -110,6 +119,20 @@ class Tests {
                long a = 0xffffffffff;
                if (a > 0xffffffffff)
                        return 1;
+
+               if (a > 0x1ffffffffff)
+                       return 2;
+
+               if (a > 0xff00000000) {} else
+                       return 3;
+
+               if (a > 0xfeffffffff) {} else
+                       return 4;
+
+               a = 0xff00000000;
+               if (a > 0xffffffffff)
+                       return 5;
+
                return 0;
        }
 
@@ -117,6 +140,20 @@ class Tests {
                ulong a = 0xffffffffff;
                if (a > 0xffffffffff)
                        return 1;
+
+               if (a > 0x1ffffffffff)
+                       return 2;
+
+               if (a > 0xff00000000) {} else
+                       return 3;
+
+               if (a > 0xfeffffffff) {} else
+                       return 4;
+
+               a = 0xff00000000;
+               if (a > 0xffffffffff)
+                       return 5;
+
                return 0;
        }
 
@@ -124,6 +161,20 @@ class Tests {
                long a = 0xffffffffff;
                if (a < 0xffffffffff)
                        return 1;
+
+               if (a < 0x1ffffffffff) {} else
+                       return 2;
+
+               if (a < 0xff00000000)
+                       return 3;
+
+               if (a < 0xfeffffffff)
+                       return 4;
+
+               a = 0xff00000000;
+               if (a < 0xffffffffff) {} else
+                       return 5;
+
                return 0;
        }
 
@@ -131,6 +182,20 @@ class Tests {
                ulong a = 0xffffffffff;
                if (a < 0xffffffffff)
                        return 1;
+
+               if (a < 0x1ffffffffff) {} else
+                       return 2;
+
+               if (a < 0xff00000000)
+                       return 3;
+
+               if (a < 0xfeffffffff)
+                       return 4;
+
+               a = 0xff00000000;
+               if (a < 0xffffffffff) {} else
+                       return 5;
+
                return 0;
        }
 
@@ -138,6 +203,20 @@ class Tests {
                long a = 0xfffffffffe;
                if (a >= 0xffffffffff)
                        return 1;
+
+               if (a >= 0x1fffffffffe)
+                       return 2;
+
+               if (a >= 0xff00000000) {} else
+                       return 3;
+
+               if (a >= 0xfefffffffe) {} else
+                       return 4;
+
+               a = 0xff00000000;
+               if (a >= 0xffffffffff)
+                       return 5;
+
                return 0;
        }
 
@@ -145,6 +224,20 @@ class Tests {
                ulong a = 0xfffffffffe;
                if (a >= 0xffffffffff)
                        return 1;
+
+               if (a >= 0x1fffffffffe)
+                       return 2;
+
+               if (a >= 0xff00000000) {} else
+                       return 3;
+
+               if (a >= 0xfefffffffe) {} else
+                       return 4;
+
+               a = 0xff00000000;
+               if (a >= 0xffffffffff)
+                       return 5;
+
                return 0;
        }
 
@@ -152,6 +245,41 @@ class Tests {
                long a = 0xffffffffff;
                if (a <= 0xfffffffffe)
                        return 1;
+
+               if (a <= 0x1ffffffffff) {} else
+                       return 2;
+
+               if (a <= 0xff00000000)
+                       return 3;
+
+               if (a <= 0xfeffffffff)
+                       return 4;
+
+               a = 0xff00000000;
+               if (a <= 0xffffffffff) {} else
+                       return 5;
+
+               return 0;
+       }
+
+       public static int test_0_bgt_un () {
+               ulong a = 0xffffffffff;
+               if (a <= 0xfffffffffe)
+                       return 1;
+
+               if (a <= 0x1ffffffffff) {} else
+                       return 2;
+
+               if (a <= 0xff00000000)
+                       return 3;
+
+               if (a <= 0xfeffffffff)
+                       return 4;
+
+               a = 0xff00000000;
+               if (a <= 0xffffffffff) {} else
+                       return 5;
+
                return 0;
        }
 
@@ -197,23 +325,6 @@ class Tests {
                return 0;
        }
 
-       public static int test_0_conv_to_r8 () {
-               long a = 150;
-               double b = (double) a;
-
-               if (b != 150.0)
-                       return 1;
-               return 0;
-       }
-
-       public static int test_0_conv_to_r4 () {
-               long a = 3000;
-               float b = (float) a;
-
-               if (b != 3000.0F)
-                       return 1;
-               return 0;
-       }
        /*
        public static int test_0_conv_from_r8 () {
                double b = 2.0;
@@ -245,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;             
@@ -899,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;
@@ -947,10 +1049,6 @@ class Tests {
                return (int)res;
        }
        
-       static void doit (double value, out long m) {
-               m = (long) value;
-       }
-       
        public static int test_3_checked_cast_un () {
                 ulong i = 2;
                 long j;
@@ -1022,19 +1120,17 @@ class Tests {
                return j;
        }
 
-       public static int test_0_ftol_clobber () {
-               long m;
-               doit (1.3, out m);
-               if (m != 1)
-                       return 2;
-               return 0;
-       }
-
        public static int test_0_ulong_regress () {
                ulong u = 4257145737;
                u --;
                return (u == 4257145736) ? 0 : 1;
        }
+
+       public static int test_0_ulong_regress2 () {
+               int p2 = 31;
+               ulong sum_p = 2897079476 + (ulong) (1 << p2);
+               return (sum_p == 749595828) ? 0 : 1;
+       }
        
        public static int test_0_assemble_long ()
        {
@@ -1077,5 +1173,95 @@ class Tests {
                        return (int)l;
                }
        }
+
+       public static int test_0_regress_cprop_80738 () {
+               int hours = Int32.MinValue;
+               int hrssec = (hours * 3600);
+               long t = ((long)(hrssec) * 1000L);
+
+               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);
+       }
 }