X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fbasic-math.cs;h=4482c913af6f88513c7e0465b2f6b954ce78e6da;hb=1e726ce7a38a92860acab28f4427813d2ba14c13;hp=05c39cd803e3f43cd8dc1ce906b70c716eb4d412;hpb=538d3bb80572334c18ae117ea7703406a4a22872;p=mono.git diff --git a/mono/mini/basic-math.cs b/mono/mini/basic-math.cs index 05c39cd803e..4482c913af6 100644 --- a/mono/mini/basic-math.cs +++ b/mono/mini/basic-math.cs @@ -6,7 +6,7 @@ using System.Reflection; * * Each test needs to be of the form: * - * static int test__ (); + * public static int test__ (); * * where is an integer (the value that needs to be returned by * the method to make it pass. @@ -25,44 +25,44 @@ using System.Reflection; class Tests { - static int Main () { - return TestDriver.RunTests (typeof (Tests)); + public static int Main (string[] args) { + return TestDriver.RunTests (typeof (Tests), args); } - static int test_0_sin_precision () { + public static int test_0_sin_precision () { double d1 = Math.Sin (1); double d2 = Math.Sin (1) - d1; return (d2 == 0) ? 0 : 1; } - static int test_0_cos_precision () { + public static int test_0_cos_precision () { double d1 = Math.Cos (1); double d2 = Math.Cos (1) - d1; return (d2 == 0) ? 0 : 1; } - static int test_0_tan_precision () { + public static int test_0_tan_precision () { double d1 = Math.Tan (1); double d2 = Math.Tan (1) - d1; return (d2 == 0) ? 0 : 1; } - static int test_0_atan_precision () { + public static int test_0_atan_precision () { double d1 = Math.Atan (double.NegativeInfinity); double d2 = Math.Atan (double.NegativeInfinity) - d1; return (d2 == 0) ? 0 : 1; } - static int test_0_sqrt_precision () { + public static int test_0_sqrt_precision () { double d1 = Math.Sqrt (2); double d2 = Math.Sqrt (2) - d1; return (d2 == 0) ? 0 : 1; } - static int test_2_sqrt () { + public static int test_2_sqrt () { return (int) Math.Sqrt (4); } - static int test_0_sqrt_precision_and_not_spill () { + public static int test_0_sqrt_precision_and_not_spill () { double expected = 0; double[] operands = new double[3]; double[] temporaries = new double[3]; @@ -87,7 +87,7 @@ class Tests { return (result == expected) ? 0 : 1; } - static int test_0_sqrt_precision_and_spill () { + public static int test_0_sqrt_precision_and_spill () { double expected = 0; double[] operands = new double[9]; double[] temporaries = new double[9]; @@ -112,7 +112,7 @@ class Tests { return (result == expected) ? 0 : 1; } - static int test_0_div_precision_and_spill () { + public static int test_0_div_precision_and_spill () { double expected = 0; double[] operands = new double[9]; double[] temporaries = new double[9]; @@ -136,23 +136,154 @@ class Tests { return (result == expected) ? 0 : 1; } - static int test_0_sqrt_nan () { + public static int test_0_sqrt_nan () { return Double.IsNaN (Math.Sqrt (Double.NaN)) ? 0 : 1; } - static int test_0_sin_nan () { + public static int test_0_sin_nan () { return Double.IsNaN (Math.Sin (Double.NaN)) ? 0 : 1; } - static int test_0_cos_nan () { + public static int test_0_cos_nan () { return Double.IsNaN (Math.Cos (Double.NaN)) ? 0 : 1; } - static int test_0_tan_nan () { + public static int test_0_tan_nan () { return Double.IsNaN (Math.Tan (Double.NaN)) ? 0 : 1; } - static int test_0_atan_nan () { + public static int test_0_atan_nan () { return Double.IsNaN (Math.Atan (Double.NaN)) ? 0 : 1; } + + public static int test_0_min () { + if (Math.Min (5, 6) != 5) + return 1; + if (Math.Min (6, 5) != 5) + return 2; + if (Math.Min (-100, -101) != -101) + return 3; + if (Math.Min ((long)5, (long)6) != 5) + return 4; + if (Math.Min ((long)6, (long)5) != 5) + return 5; + if (Math.Min ((long)-100, (long)-101) != -101) + return 6; + return 0; + } + + public static int test_0_max () { + if (Math.Max (5, 6) != 6) + return 1; + if (Math.Max (6, 5) != 6) + return 2; + if (Math.Max (-100, -101) != -100) + return 3; + if (Math.Max ((long)5, (long)6) != 6) + return 4; + if (Math.Max ((long)6, (long)5) != 6) + return 5; + if (Math.Max ((long)-100, (long)-101) != -100) + return 6; + return 0; + } + + public static int test_0_min_un () { + uint a = (uint)int.MaxValue + 10; + + for (uint b = 7; b <= 10; ++b) { + if (Math.Min (a, b) != b) + return (int)b; + if (Math.Min (b, a) != b) + return (int)b; + } + + if (Math.Min ((ulong)5, (ulong)6) != 5) + return 4; + if (Math.Min ((ulong)6, (ulong)5) != 5) + return 5; + + ulong la = (ulong)long.MaxValue + 10; + + for (ulong b = 7; b <= 10; ++b) { + if (Math.Min (la, b) != b) + return (int)b; + if (Math.Min (b, la) != b) + return (int)b; + } + + return 0; + } + + public static int test_0_max_un () { + uint a = (uint)int.MaxValue + 10; + + for (uint b = 7; b <= 10; ++b) { + if (Math.Max (a, b) != a) + return (int)b; + if (Math.Max (b, a) != a) + return (int)b; + } + + if (Math.Max ((ulong)5, (ulong)6) != 6) + return 4; + if (Math.Max ((ulong)6, (ulong)5) != 6) + return 5; + + ulong la = (ulong)long.MaxValue + 10; + + for (ulong b = 7; b <= 10; ++b) { + if (Math.Max (la, b) != la) + return (int)b; + if (Math.Max (b, la) != la) + return (int)b; + } + + return 0; + } + + public static int test_0_abs () { + double d = -5.0; + + if (Math.Abs (d) != 5.0) + return 1; + return 0; + } + + public static int test_0_round () { + if (Math.Round (5.0) != 5.0) + return 1; + + if (Math.Round (5.000000000000001) != 5.0) + return 2; + + if (Math.Round (5.499999999999999) != 5.0) + return 3; + + if (Math.Round (5.5) != 6.0) + return 4; + + if (Math.Round (5.999999999999999) != 6.0) + return 5; + + if (Math.Round (Double.Epsilon) != 0) + return 6; + + if (!Double.IsNaN (Math.Round (Double.NaN))) + return 7; + + if (!Double.IsPositiveInfinity (Math.Round (Double.PositiveInfinity))) + return 8; + + if (!Double.IsNegativeInfinity (Math.Round (Double.NegativeInfinity))) + return 9; + + if (Math.Round (Double.MinValue) != Double.MinValue) + return 10; + + if (Math.Round (Double.MaxValue) != Double.MaxValue) + return 11; + + return 0; + } }