[Mono-list] request for test suite for the interpreter

Paolo Molaro lupus@ximian.com
Sun, 15 Jul 2001 19:42:40 +0200


I added support to the interpreter for calling functions
with 0..n arguments (the info about the number and type of
the arguments is completely decoded now in a useful C struct).
So this is a good time for starting writing a test suite to make
sure the interpreter does work correctly.

Below you'll find a sample program that exercises the interpreter
in different ways. Feel free to add more tests (hopefully
for corner cases). Do not use fields or vararg functions or
objects or external assembly routines (ie, no Console.WriteLine).
Make Main() return the number of the test that failed.

You should be able to use any numeric value, perform function
calls with any number of params and perform the usual numeric
operations. You can use loops (no switch, yet).
Have you functions accept multiple arguments and feel
free to use any number of local variables in your functions
and recursion.

If any problem will show up (and I'm sure it will;-)
I'll fix them when I return from my vacation.

Thanks,
	lupus

public class TestIntOps {

	public static int simple_add (int a, int b) {
		return a+b;
	}

	public static int simple_sub (int a, int b) {
		return a-b;
	}
	
	public static int simple_mul (int a, int b) {
		return a*b;
	}
	
	public static int Main() {
		int num = 1;
	
		if (simple_add (1, 1)   != 2)  return num;
		num++;
		if (simple_add (31, -1) != 30) return num;
		num++;
		if (simple_sub (31, -1) != 32) return num;
		num++;
		if (simple_mul (12, 12) != 144) return num;
		num++;
		
		// add more meaningful tests
	
    	return 0;
	}
}

-- 
-----------------------------------------------------------------
lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better