X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fbasic-float.cs;h=e6a14456f95e4a3750f7d6247cf3fb97851a5fa4;hb=d295ab661864a5dee77a97d298bf2dde09c94de1;hp=694a1d37d0aa11037d95006b08266d3e50467fd8;hpb=6352c16dd5306ccb8bedc742bf99505688695dc6;p=mono.git diff --git a/mono/mini/basic-float.cs b/mono/mini/basic-float.cs index 694a1d37d0a..e6a14456f95 100644 --- a/mono/mini/basic-float.cs +++ b/mono/mini/basic-float.cs @@ -26,14 +26,14 @@ using System.Reflection; /* A comparison made to same variable. */ #pragma warning disable 1718 -#if MOBILE +#if __MOBILE__ class FloatTests #else class Tests #endif { -#if !MOBILE +#if !__MOBILE__ public static int Main (string[] args) { return TestDriver.RunTests (typeof (Tests), args); } @@ -93,6 +93,13 @@ class Tests 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; } @@ -624,8 +631,8 @@ class Tests public static int test_0_float_precision () { float f1 = 3.40282346638528859E+38f; float f2 = 3.40282346638528859E+38f; - float PositiveInfinity = 1.0f / 0.0f; - float f = f1 + f2; + float PositiveInfinity = (float)(1.0f / 0.0f); + float f = (float)(f1 + f2); return f == PositiveInfinity ? 0 : 1; } @@ -672,5 +679,146 @@ class Tests return 1; return 0; } + + public static int test_5_r4_fadd () { + float f1 = 3.0f; + float f2 = 2.0f; + return (int)(f1 + f2); + } + + public static int test_1_r4_fsub () { + float f1 = 3.0f; + float f2 = 2.0f; + return (int)(f1 - f2); + } + + public static int test_6_fmul_r4 () { + float f1 = 2.0f; + float f2 = 3.0f; + return (int)(f1 * f2); + } + + public static int test_3_fdiv_r4 () { + float f1 = 6.0f; + float f2 = 2.0f; + return (int)(f1 / f2); + } + + public static int test_1_frem_r4 () { + float f1 = 7.0f; + float f2 = 2.0f; + return (int)(f1 % f2); + } + + public static int test_0_fcmp_eq_r4 () { + float f1 = 1.0f; + float f2 = 1.0f; + return f1 == f2 ? 0 : 1; + } + + public static int test_0_fcmp_eq_2_r4 () { + float f1 = 1.0f; + float f2 = 2.0f; + return f1 == f2 ? 1 : 0; + } + + public static int test_0_fcmp_eq_r4_mixed () { + float f1 = 1.0f; + double f2 = 1.0; + return f1 == f2 ? 0 : 1; + } + + public static int test_3_iconv_to_r4 () { + int i = 3; + float f = (float)i; + return (int)f; + } + + public static int test_2_neg_r4 () { + float a = -2.0f; + return (int)(-a); + } + + public static int test_0_fceq_r4 () { + float f1 = 1.0f; + float f2 = 1.0f; + bool res = f1 == f2; + return res ? 0 : 1; + } + + public static int test_0_fcgt_r4 () { + float f1 = 2.0f; + float f2 = 1.0f; + bool res = f1 > f2; + bool res2 = f2 > f1; + return res && !res2 ? 0 : 1; + } + + public static int test_0_fclt_r4 () { + float f1 = 1.0f; + float f2 = 2.0f; + bool res = f1 < f2; + bool res2 = f2 < f1; + return res && !res2 ? 0 : 1; + } + + public static int test_0_fclt_un_r4 () { + float f1 = 2.0f; + float f2 = 1.0f; + bool res = f1 >= f2; + bool res2 = f2 >= f1; + return res && !res2 ? 0 : 1; + } + + public static int test_0_fcgt_un_r4 () { + float f1 = 1.0f; + float f2 = 2.0f; + bool res = f1 <= f2; + bool res2 = f2 <= f1; + return res && !res2 ? 0 : 1; + } + + public static int test_0_fconv_to_u4_r4 () { + float a = 10.0f; + + uint b = (uint)a; + return b == 10 ? 0 : 1; + } + + public static int test_0_fconv_to_u1_r4 () { + float a = 10.0f; + + byte b = (byte)a; + return b == 10 ? 0 : 1; + } + + public static int test_0_fconv_to_i1_r4 () { + float a = 127.0f; + + sbyte b = (sbyte)a; + return b == 127 ? 0 : 1; + } + + public static int test_0_fconv_to_u2_r4 () { + float a = 10.0f; + + ushort b = (ushort)a; + return b == 10 ? 0 : 1; + } + + public static int test_0_fconv_to_i2_r4 () { + float a = 127.0f; + + short b = (short)a; + return b == 127 ? 0 : 1; + } + + public static int test_10_rconv_to_u8 () { + ulong l = 10; + float f = (float)l; + l = (ulong)f; + return (int)l; + } + }