"disable_omit_fp" can now be included in MONO_DEBUG
[mono-project.git] / mcs / tests / gtest-etree-07.cs
blob6e46735c81812f4a1fb0de37d530bf5b3529ee1b
1 // Compiler options: -unsafe
3 using System;
4 using System.Linq.Expressions;
6 delegate void EmptyDelegate ();
7 unsafe delegate int* UnsafeDelegate ();
9 class C
11 static int i;
13 static void Test ()
15 i += 9;
18 static unsafe int* Foo ()
20 return (int*)1;
23 void M ()
27 int TestInstance ()
29 Expression<Func<EmptyDelegate>> e = () => M;
30 if (e.Body.ToString () != "Convert(Void M().CreateDelegate(EmptyDelegate, value(C)))")
31 return 1;
33 e.Compile () ();
35 Expression<Func<C, EmptyDelegate>> e2 = (l) => l.M;
36 if (e2.Body.ToString () != "Convert(Void M().CreateDelegate(EmptyDelegate, l))")
37 return 2;
39 e2.Compile () (this);
40 return 0;
43 public static int Main ()
45 Expression<Func<EmptyDelegate>> e = () => new EmptyDelegate (Test);
46 if (e.Body.ToString () != "Convert(Void Test().CreateDelegate(EmptyDelegate, null))")
47 return 1;
49 var v = e.Compile ();
50 v.Invoke ()();
52 if (i != 9)
53 return 2;
55 Expression<Func<EmptyDelegate>> e2 = () => Test;
56 if (e2.Body.ToString () != "Convert(Void Test().CreateDelegate(EmptyDelegate, null))")
57 return 3;
59 var v2 = e2.Compile ();
60 v2.Invoke ()();
62 if (i != 18)
63 return 4;
65 unsafe {
66 Expression<Func<UnsafeDelegate>> e3 = () => new UnsafeDelegate (Foo);
67 if (e3.Body.ToString () != "Convert(Int32* Foo().CreateDelegate(UnsafeDelegate, null))")
68 return 5;
70 var v3 = e3.Compile ();
71 if (v3.Invoke ()() != (int*)1)
72 return 6;
75 if (new C ().TestInstance () != 0)
76 return 7;
78 Console.WriteLine ("OK");
79 return 0;