2008-08-22 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / basic-long.cs
index 59a059018eb0b8d99fb003349ae63edeb4a434af..91d2ffdc5fb50f18fd87eb00414bc539a68386d6 100644 (file)
@@ -103,6 +103,8 @@ class Tests {
                long a = 0xffffffffff;
                if (a == 0xfffffffffe)
                        return 1;
+               if (a == 0xfeffffffff)
+                       return 2;
                return 0;
        }
 
@@ -110,6 +112,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 +133,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 +154,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 +175,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 +196,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 +217,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 +238,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;
        }
 
@@ -506,6 +627,22 @@ class Tests {
                return count;
        }
 
+       public static int test_1_shift_u_32 ()
+       {
+               ulong a;
+               int count = 0;
+
+               a = UInt64.MaxValue;
+               // Avoid constant folding
+               for (int i = 0; i < 32; ++i)
+                       count ++;
+
+               if ((a >> count) != 0xFFFFFFFFUL)
+                       return 0;
+               else
+                       return 1;
+       }
+
        public static int test_1_simple_neg () {
                long a = 9;
                
@@ -626,6 +763,68 @@ class Tests {
 
                return 0;
        }
+
+       public static int test_0_mul_imm_opt ()
+       {
+               long i;
+
+               i = 1;
+               if ((i * 2) != 2)
+                       return 1;
+               i = -1;
+               if ((i * 2) != -2)
+                       return 2;
+               i = 1;
+               if ((i * 3) != 3)
+                       return 3;
+               i = -1;
+               if ((i * 3) != -3)
+                       return 4;
+               i = 1;
+               if ((i * 5) != 5)
+                       return 5;
+               i = -1;
+               if ((i * 5) != -5)
+                       return 6;
+               i = 1;
+               if ((i * 6) != 6)
+                       return 7;
+               i = -1;
+               if ((i * 6) != -6)
+                       return 8;
+               i = 1;
+               if ((i * 9) != 9)
+                       return 9;
+               i = -1;
+               if ((i * 9) != -9)
+                       return 10;
+               i = 1;
+               if ((i * 10) != 10)
+                       return 11;
+               i = -1;
+               if ((i * 10) != -10)
+                       return 12;
+               i = 1;
+               if ((i * 12) != 12)
+                       return 13;
+               i = -1;
+               if ((i * 12) != -12)
+                       return 14;
+               i = 1;
+               if ((i * 25) != 25)
+                       return 15;
+               i = -1;
+               if ((i * 25) != -25)
+                       return 16;
+               i = 1;
+               if ((i * 100) != 100)
+                       return 17;
+               i = -1;
+               if ((i * 100) != -100)
+                       return 18;
+               
+               return 0;
+       }
        
        public static int test_4_divun () {
                uint b = 12;
@@ -851,23 +1050,6 @@ class Tests {
 
                return (int)res;
        }
-
-       static long position = 0;
-
-       public static int test_4_static_inc_long () {
-
-               int count = 4;
-
-               position = 0;
-
-               position += count;
-
-               return (int)position;
-       }
-       
-       static void doit (double value, out long m) {
-               m = (long) value;
-       }
        
        public static int test_3_checked_cast_un () {
                 ulong i = 2;
@@ -940,19 +1122,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 ()
        {
@@ -986,5 +1166,22 @@ class Tests {
 
                return ((a >> (b - c)) == 0) ? 0 : 1;
        }
+
+       public static int test_1234_conv_ovf_u8 () {
+               int i = 1234;
+
+               checked {
+                       ulong l = (ulong)i;
+                       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;
+       }
 }