2 using System.Reflection;
5 * Regression tests for the mono JIT.
7 * Each test needs to be of the form:
9 * static int test_<result>_<name> ();
11 * where <result> is an integer (the value that needs to be returned by
12 * the method to make it pass.
13 * <name> is a user-displayed name used to identify the test.
15 * The tests can be driven in two ways:
16 * *) running the program directly: Main() uses reflection to find and invoke
17 * the test methods (this is useful mostly to check that the tests are correct)
18 * *) with the --regression switch of the jit (this is the preferred way since
19 * all the tests will be run with optimizations on and off)
21 * The reflection logic could be moved to a .dll since we need at least another
22 * regression test file written in IL code to have better control on how
26 delegate int IntNoArgs();
30 public virtual int method1 () {
34 public virtual int method2 () {
38 public virtual int method3 () {
42 public virtual int method4 () {
46 public virtual int method5 () {
52 public class Middle : Base {
53 public override int method2 () {
57 public override int method4 () {
61 public override sealed int method5 () {
67 public class OpenFinal : Middle {
68 public override sealed int method4 () {
72 static public int staticMethod() {
78 sealed public class SealedFinal : Middle {
79 public override int method1 () {
83 static public int staticMethod() {
91 static int Main (string[] args) {
92 return TestDriver.RunTests (typeof (Tests), args);
95 static public int test_0_sealed_class_devirt_right_method () {
96 SealedFinal x = new SealedFinal ();
97 if (x.method1 () != 4)
99 if (x.method2 () != 2)
101 if (x.method3 () != 1)
106 static public int test_0_sealed_method_devirt_right_method () {
107 OpenFinal x = new OpenFinal ();
108 if (x.method4 () != 3)
110 if (x.method5 () != 2)
115 static public int test_0_sealed_class_devirt_right_method_using_delegates () {
116 SealedFinal x = new SealedFinal ();
117 IntNoArgs d1 = new IntNoArgs(x.method1);
118 IntNoArgs d2 = new IntNoArgs(x.method2);
119 IntNoArgs d3 = new IntNoArgs(x.method3);
130 static public int test_0_sealed_method_devirt_right_method_using_delegates () {
131 OpenFinal x = new OpenFinal ();
132 IntNoArgs d1 = new IntNoArgs(x.method4);
133 IntNoArgs d2 = new IntNoArgs(x.method5);
143 static public int test_0_delegate_over_static_method_devirtualize_ok () {
144 IntNoArgs d1 = new IntNoArgs(OpenFinal.staticMethod);
145 IntNoArgs d2 = new IntNoArgs(SealedFinal.staticMethod);
155 static public int test_0_npe_still_happens() {
157 SealedFinal y = null;
162 } catch(NullReferenceException e) {
169 } catch(NullReferenceException e) {
176 } catch(NullReferenceException e) {
183 } catch(NullReferenceException e) {
190 } catch(NullReferenceException e) {