2 using System.Reflection;
7 return TestDriver.RunTests (typeof (Tests));
10 static int test_0_beq () {
17 static int test_0_bne_un () {
24 static int test_0_conv_r8 () {
31 static int test_0_conv_i () {
42 ushort us = (ushort)a;
51 static int test_5_conv_r4 () {
57 static int test_5_double_conv_r4 () {
63 static int test_5_float_conv_r8 () {
69 static int test_5_conv_r8 () {
75 static int test_5_add () {
81 static int test_5_sub () {
87 static int test_24_mul () {
93 static int test_4_div () {
99 static int test_2_rem () {
105 static int test_2_neg () {
110 static int test_46_float_add_spill () {
111 // we overflow the FP stack
122 return (int)(1.0 + (a + (b + (c + (d + (e + (f + (g + (h + i)))))))));
125 static int test_362880_float_mul_spill () {
126 // we overflow the FP stack
137 return (int)(1.0 * (a * (b * (c * (d * (e * (f * (g * (h * i)))))))));
140 static int test_4_long_cast () {
142 double d = (double)a;
149 /* FIXME: This only works on little-endian machines */
151 static unsafe int test_2_negative_zero () {
156 byte *ptr = (byte*)&d;
170 static int test_16_float_cmp () {
259 static int test_15_float_cmp_un () {
260 double a = Double.NaN;
343 static int test_15_float_branch () {
411 static int test_15_float_branch_un () {
412 double a = Double.NaN;
481 public class TestDriver {
483 static public int RunTests (Type type, string[] args) {
484 int failed = 0, ran = 0;
485 int result, expected, elen;
488 MethodInfo[] methods;
489 bool do_timings = false;
491 DateTime start, end = DateTime.Now;
493 if (args != null && args.Length > 0) {
494 for (j = 0; j < args.Length; j++) {
495 if (args [j] == "--time") {
497 string[] new_args = new string [args.Length - 1];
498 for (i = 0; i < j; ++i)
499 new_args [i] = args [i];
501 for (; j < args.Length; ++i, ++j)
502 new_args [i] = args [j];
508 methods = type.GetMethods (BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Static);
509 for (i = 0; i < methods.Length; ++i) {
510 name = methods [i].Name;
511 if (!name.StartsWith ("test_"))
513 if (args != null && args.Length > 0) {
515 for (j = 0; j < args.Length; j++) {
516 if (name.EndsWith (args [j])) {
524 for (j = 5; j < name.Length; ++j)
525 if (!Char.IsDigit (name [j]))
527 expected = Int32.Parse (name.Substring (5, j - 5));
528 start = DateTime.Now;
529 result = (int)methods [i].Invoke (null, null);
532 long tdiff = end.Ticks - start.Ticks;
533 int mdiff = (int)tdiff/10000;
535 Console.WriteLine ("{0} took {1} ms", name, mdiff);
538 if (result != expected) {
540 Console.WriteLine ("{0} failed: got {1}, expected {2}", name, result, expected);
545 Console.WriteLine ("Total ms: {0}", tms);
547 Console.WriteLine ("Regression tests: {0} ran, {1} failed in {2}", ran, failed, type);
548 //Console.WriteLine ("Regression tests: {0} ran, {1} failed in [{2}]{3}", ran, failed, type.Assembly.GetName().Name, type);
551 static public int RunTests (Type type) {
552 return RunTests (type, null);