2005-06-08 Martin Baulig <martin@ximian.com>
[mono.git] / mono / tests / static-constructor.cs
1
2 using System;
3 using System.Reflection;
4
5 struct A {
6         public A (int i) {
7         }
8 }
9
10 struct B {
11         public B (int i) {
12         }
13 }
14
15 public class Tests {
16         static int last = 42;
17         static int burp;
18
19         static Tests () {
20                 /* 
21                  * This is really at test of the compiler: it should init
22                  * last before getting here.
23                 */
24                 if (last != 42)
25                         burp = 5;
26                 else
27                         burp = 4;
28         }
29         public static int Main() {
30                 if (last != 42)
31                         return 1;
32                 if (burp != 4)
33                         return 1;
34
35                 // Regression test for bug #59193 (shared runtime wrappers)
36                 ConstructorInfo con1 = typeof (A).GetConstructor (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type [1] { typeof (int) }, null);
37                 ConstructorInfo con2 = typeof (B).GetConstructor (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type [1] { typeof (int) }, null);
38
39                 con1.Invoke (null, new Object [] { 0 });
40                 con2.Invoke (null, new Object [] { 0 });
41
42                 return 0;
43         }
44 }