Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gtest-etree-07.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 067717a7f1e6bb808baaceb6a60a9eeee03f22fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Compiler options: -unsafe

using System;
using System.Linq.Expressions;

delegate void EmptyDelegate ();
unsafe delegate int* UnsafeDelegate ();

class C
{
	static int i;
	
	static void Test ()
	{
		i += 9;
	}
	
	static unsafe int* Foo ()
	{
		return (int*)1;
	}
	
	public static int Main ()
	{
		Expression<Func<EmptyDelegate>> e = () => new EmptyDelegate (Test);
		
		if (e.Body.ToString () != "Convert(CreateDelegate(EmptyDelegate, null, Void Test()))")
			return 1;

		var v = e.Compile ();
		v.Invoke ()();
		
		if (i != 9)
			return 2;
		
		Expression<Func<EmptyDelegate>> e2 = () => Test;
		if (e2.Body.ToString () != "Convert(CreateDelegate(EmptyDelegate, null, Void Test()))")
			return 3;

		var v2 = e2.Compile ();
		v2.Invoke ()();
		
		if (i != 18)
			return 4;
			
		unsafe {
			Expression<Func<UnsafeDelegate>> e3 = () => new UnsafeDelegate (Foo);
			if (e3.Body.ToString () != "Convert(CreateDelegate(UnsafeDelegate, null, Int32* Foo()))")
				return 5;
			
			var v3 = e3.Compile ();
			if (v3.Invoke ()() != (int*)1)
				return 6;
		}

		Console.WriteLine ("OK");
		return 0;
	}
}