2008-07-07 Bill Holmes <billholmes54@gmail.com>
[mono.git] / mono / mini / basic-calls.cs
index c5c7d97ca25ba3a5a4a965f03db252a2be94f18c..77996ab2ee3d5f7ca499f34f9b67a427594ad5f1 100644 (file)
@@ -154,6 +154,17 @@ class Tests {
                return (int)pass_floats (1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f);
        }
 
+       public static bool is_small (float value) {
+               double d = (double)value;
+               double d2 = 7.183757E-41;
+               return d - d2 < 0.000001;
+       }
+               
+       static int test_0_float_argument_passing_precision () {
+               float f = 7.183757E-41f;
+               return is_small (f) ? 0 : 1;
+       }
+
        // The first argument must be passed on a dword aligned stack location
        static int pass_byref_ints_longs (ref long a, ref int b, ref byte c, ref short d, ref long e, ref int f, ref long g) {
                return (int)(a + b + c + d + e + f + g);
@@ -232,86 +243,50 @@ class Tests {
                return isnan (f) ? 1 : 0;
        }
 
-       struct FooStruct {
-
-               public FooStruct (long l) {
-               }
+       static int first_is_zero (int v1, int v2) {
+               if (v1 != 0)
+                       return -1;
+               return v2;
+       }
+       static int test_1_handle_dup_stloc () {
+               int index = 0;
+               int val = first_is_zero (index, ++index);
+               if (val != 1)
+                       return 2;
+               return 1;
        }
 
-       static int test_0_calls_opcode_emulation () {
-               // Test that emulated opcodes do not clobber arguments already in
-               // out registers
-               checked {
-                       long val = 10000;
-                       new FooStruct (val * 10000);
-               }
-               return 0;
+       static long return_5low () {
+               return 5;
        }
        
-       static uint dum_de_dum = 1;
-       static int test_0_long_arg_opt ()
-       {
-               return Foo (0x1234567887654321, dum_de_dum);
+       static long return_5high () {
+               return 0x500000000;
        }
-       
-       static int Foo (ulong x, ulong y)
-       {
-               if (x != 0x1234567887654321)
-                       return 1;
-               
-               if (y != 1)
-                       return 2;
-               
-               return 0;
+
+       public static int test_3_long_ret () {
+               long val = return_5low ();
+               return (int) (val - 2);
        }
-       
-       static int test_0_long_ret_opt ()
-       {
-               ulong x = X ();
-               if (x != 0x1234567887654321)
+
+       public static int test_1_long_ret2 () {
+               long val = return_5high ();
+               if (val > 0xffffffff)
                        return 1;
-               ulong y = Y ();
-               if (y != 1)
-                       return 2;
-               
                return 0;
        }
-       
-       static ulong X ()
-       {
-               return 0x1234567887654321;
-       }
-       
-       static ulong Y ()
-       {
-               return dum_de_dum;
-       }
 
-       /* from bug# 71515 */
-       static int counter = 0;
-       static bool WriteStuff () {
-               counter = 10;
-               return true;
-       }
-       static int test_0_cond_branch_side_effects () {
-               counter = 5;
-               if (WriteStuff());
-               if (counter == 10)
-                       return 0;
-               return 1;
+       static void doit (double value, out long m) {
+               m = (long) value;
        }
 
-       static int first_is_zero (int v1, int v2) {
-               if (v1 != 0)
-                       return -1;
-               return v2;
-       }
-       static int test_1_handle_dup_stloc () {
-               int index = 0;
-               int val = first_is_zero (index, ++index);
-               if (val != 1)
+       public static int test_0_ftol_clobber () {
+               long m;
+               doit (1.3, out m);
+               if (m != 1)
                        return 2;
-               return 1;
+               return 0;
        }
+
 }