Take stars out of types where they make more sense.
[mono-project.git] / mcs / tests / gtest-etree-07.cs
blob266cb45a8b4ebf3116661f53c292b1de5e802262
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)), EmptyDelegate)")
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), EmptyDelegate)")
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), EmptyDelegate)")
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), EmptyDelegate)")
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), UnsafeDelegate)")
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;