Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / dtest-016.cs
1 using System;
2
3 class Foo
4 {
5         public virtual void Dyn (out dynamic o)
6         {
7                 o = null;
8         }
9 }
10
11 class Bar : Foo
12 {
13         public override void Dyn (out dynamic o)
14         {
15                 base.Dyn (out o);
16         }
17 }
18
19 public class C
20 {
21         public void Method_A (ref int i)
22         {
23         }
24
25         public void Method_B (ref dynamic i)
26         {
27         }
28         
29         public static int M (string a, string b)
30         {
31                 return 5;
32         }
33         
34         public static int M (ref object o, out dynamic d)
35         {
36                 d = null;
37                 return 1;
38         }
39 }
40
41 class D
42 {
43         public static int Foo (dynamic d)
44         {
45                 return 1;
46         }
47
48         public static int Foo (params object[] o)
49         {
50                 return 2;
51         }
52 }
53
54 class E
55 {
56         public static int Foo (int i, dynamic d)
57         {
58                 return 1;
59         }
60
61         public static int Foo (double d, object i)
62         {
63                 return 2;
64         }
65 }
66
67 class Program
68 {
69         static void DynOut (out dynamic d)
70         {
71                 d = null;
72         }
73
74         static void DynRef (ref object d)
75         {
76                 d = null;
77         }
78         
79         static int DynParams (int a, int b, params int[] arr)
80         {
81                 return arr [1] + b;
82         }
83         
84         void TestErrorVersions ()
85         {
86                 var c = new C ();
87                 dynamic d = null;
88                 c.Method_A (d);
89                 c.Method_B (d); 
90         }
91
92         public static int Main ()
93         {
94                 object o;
95                 DynOut (out o);
96
97                 dynamic d = null;
98                 DynRef (ref d);
99                 
100                 dynamic d1 = 1, d2;
101                 
102                 // This should not involve runtime binder
103                 if (C.M (ref d1, out d2) != 1)
104                         return 1;
105                 
106                 dynamic d3 = 5;
107                 dynamic d4 = -9;
108                 if (DynParams (1, 2, d3, d4) != -7)
109                         return 2;
110
111                 if (DynParams (1, 2, 3, d4) != -7)
112                         return 3;
113                 
114                 d = 44;
115                 if (D.Foo (d) != 1)
116                         return 4;
117
118                 if (E.Foo (0, 0) != 1)
119                         return 5;
120                 
121                 return 0;
122         }
123 }