2010-02-20 Zoltan Varga <vargaz@gmail.com>
[mcs.git] / tests / gtest-etree-07.cs
blob067717a7f1e6bb808baaceb6a60a9eeee03f22fd
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 public static int Main ()
25 Expression<Func<EmptyDelegate>> e = () => new EmptyDelegate (Test);
27 if (e.Body.ToString () != "Convert(CreateDelegate(EmptyDelegate, null, Void Test()))")
28 return 1;
30 var v = e.Compile ();
31 v.Invoke ()();
33 if (i != 9)
34 return 2;
36 Expression<Func<EmptyDelegate>> e2 = () => Test;
37 if (e2.Body.ToString () != "Convert(CreateDelegate(EmptyDelegate, null, Void Test()))")
38 return 3;
40 var v2 = e2.Compile ();
41 v2.Invoke ()();
43 if (i != 18)
44 return 4;
46 unsafe {
47 Expression<Func<UnsafeDelegate>> e3 = () => new UnsafeDelegate (Foo);
48 if (e3.Body.ToString () != "Convert(CreateDelegate(UnsafeDelegate, null, Int32* Foo()))")
49 return 5;
51 var v3 = e3.Compile ();
52 if (v3.Invoke ()() != (int*)1)
53 return 6;
56 Console.WriteLine ("OK");
57 return 0;