Merge pull request #1548 from akoeplinger/stubs
[mono.git] / mono / mini / basic-float.cs
index bf8c50cb4221eb5183e03fca31a97fe1152f2cf3..9f87926717da6329485ff16bbaf2ee661bf5dd58 100644 (file)
@@ -26,11 +26,18 @@ using System.Reflection;
 /* A comparison made to same variable. */
 #pragma warning disable 1718
 
-class Tests {
-
+#if MOBILE
+class FloatTests
+#else
+class Tests
+#endif
+{
+
+#if !MOBILE
        public static int Main (string[] args) {
                return TestDriver.RunTests (typeof (Tests), args);
        }
+#endif
        
        public static int test_0_beq () {
                double a = 2.0;
@@ -73,6 +80,27 @@ class Tests {
                sbyte sb = (sbyte)a;
                if (sb != 2)
                        return 6;
+               /* MS.NET special cases these */
+               double d = Double.NaN;
+               ui = (uint)d;
+               if (ui != 0)
+                       return 7;
+               d = Double.PositiveInfinity;
+               ui = (uint)d;
+               if (ui != 0)
+                       return 8;
+               d = Double.NegativeInfinity;
+               ui = (uint)d;
+               if (ui != 0)
+                       return 9;
+               /* FIXME: This fails with llvm and with gcc -O2 on osx/linux */
+               /*
+               d = Double.MaxValue;
+               i = (int)d;
+               if (i != -2147483648)
+                       return 10;
+               */
+
                return 0;
        }
 
@@ -609,9 +637,6 @@ class Tests {
                return f == PositiveInfinity ? 0 : 1;
        }
 
-       /* 
-          Disabled until they can be fixed to run on amd64
-
        static double VALUE = 0.19975845134874831D;
 
        public static int test_0_float_conversion_reduces_double_precision () {
@@ -622,7 +647,8 @@ class Tests {
                return 0;
        }
 
-
+       /* This doesn't work with llvm */
+       /*
     public static int test_0_long_to_double_conversion ()
     {
                long l = 9223372036854775807L;
@@ -632,6 +658,7 @@ class Tests {
 
                return 0;
     }
+       */
 
        public static int INT_VAL = 0x13456799;
 
@@ -643,6 +670,14 @@ class Tests {
                        return 1;
                return 0;
        }
-       */
+
+       public static int test_0_int8_to_float_convertion ()
+    {
+               double d = (double)(float)(long)INT_VAL;
+
+               if (d != 323315616)
+                       return 1;
+               return 0;
+       }
 }