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

dtest-016.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4ad76120c013dc11e06a8b7ea57442ecc868cc53 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;

class Foo
{
	public virtual void Dyn (out dynamic o)
	{
		o = null;
	}
}

class Bar : Foo
{
	public override void Dyn (out dynamic o)
	{
		base.Dyn (out o);
	}
}

public class C
{
	public void Method_A (ref int i)
	{
	}

	public void Method_B (ref dynamic i)
	{
	}
	
	public static int M (string a, string b)
	{
		return 5;
	}
	
	public static int M (ref object o, out dynamic d)
	{
		d = null;
		return 1;
	}
}

class D
{
	public static int Foo (dynamic d)
	{
		return 1;
	}

	public static int Foo (params object[] o)
	{
		return 2;
	}
}

class E
{
	public static int Foo (int i, dynamic d)
	{
		return 1;
	}

	public static int Foo (double d, object i)
	{
		return 2;
	}
}

class Program
{
	static void DynOut (out dynamic d)
	{
		d = null;
	}

	static void DynRef (ref object d)
	{
		d = null;
	}
	
	static int DynParams (int a, int b, params int[] arr)
	{
		return arr [1] + b;
	}
	
	void TestErrorVersions ()
	{
		var c = new C ();
		dynamic d = null;
		c.Method_A (d);
		c.Method_B (d);	
	}

	public static int Main ()
	{
		object o;
		DynOut (out o);

		dynamic d = null;
		DynRef (ref d);
		
		dynamic d1 = 1, d2;
		
		// This should not involve runtime binder
		if (C.M (ref d1, out d2) != 1)
			return 1;
		
		dynamic d3 = 5;
		dynamic d4 = -9;
		if (DynParams (1, 2, d3, d4) != -7)
			return 2;

		if (DynParams (1, 2, 3, d4) != -7)
			return 3;
		
		d = 44;
		if (D.Foo (d) != 1)
			return 4;

		if (E.Foo (0, 0) != 1)
			return 5;
		
		return 0;
	}
}