Added tests for Task.WhenAll w/ empty list
[mono.git] / mcs / tests / dtest-001.cs
1 //
2 // dynamic type attribute decoration
3 //
4
5 using System;
6 using System.Collections;
7 using System.Runtime.CompilerServices;
8 using System.Collections.Generic;
9 using System.Linq;
10
11 interface I<T>
12 {
13 }
14
15 class C
16 {
17         public C (dynamic d)
18         {
19         }
20
21         public dynamic a;
22         public const dynamic c = default (dynamic);
23
24         public dynamic Prop { set; get; }
25         public dynamic Prop2 { set { } }
26
27         public dynamic this[dynamic d] { set { } get { return 1; } }
28
29         public dynamic Method (dynamic d)
30         {
31                 return null;
32         }
33
34         // Transformation handling required
35         public dynamic[] t;
36         public dynamic[,] t2;
37         public Func<dynamic, int, dynamic[]> v;
38         public I<dynamic>[] iface;
39 }
40
41 delegate dynamic Del (dynamic d);
42
43 class Test
44 {
45         public static int Main ()
46         {
47                 Type t = typeof (C);
48                 Type ca = typeof (System.Runtime.CompilerServices.DynamicAttribute);
49
50                 if (t.GetMember ("a")[0].GetCustomAttributes (ca, false).Length != 1)
51                         return 1;
52
53                 if (t.GetMember ("c")[0].GetCustomAttributes (ca, false).Length != 1)
54                         return 3;
55
56                 if (t.GetMember ("Prop")[0].GetCustomAttributes (ca, false).Length != 1)
57                         return 4;
58
59                 if (t.GetMember ("get_Prop")[0].GetCustomAttributes (ca, false).Length != 0)
60                         return 5;
61
62                 if (t.GetMethod ("get_Prop").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
63                         return 6;
64
65                 if (t.GetMember ("set_Prop")[0].GetCustomAttributes (ca, false).Length != 0)
66                         return 7;
67
68                 if (t.GetMethod ("set_Prop").ReturnParameter.GetCustomAttributes (ca, false).Length != 0)
69                         return 8;
70
71                 if (t.GetMethod ("set_Prop").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
72                         return 9;
73
74                 if (t.GetMember ("Prop2")[0].GetCustomAttributes (ca, false).Length != 1)
75                         return 10;
76
77                 if (t.GetMember ("set_Prop2")[0].GetCustomAttributes (ca, false).Length != 0)
78                         return 11;
79
80                 if (t.GetMember ("Item")[0].GetCustomAttributes (ca, false).Length != 1)
81                         return 12;
82
83                 if (t.GetMethod ("get_Item").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
84                         return 13;
85
86                 if (t.GetMethod ("get_Item").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
87                         return 14;
88
89                 if (t.GetMethod ("set_Item").ReturnParameter.GetCustomAttributes (ca, false).Length != 0)
90                         return 15;
91
92                 if (t.GetMethod ("set_Item").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
93                         return 16;
94
95                 if (t.GetMethod ("set_Item").GetParameters ()[1].GetCustomAttributes (ca, false).Length != 1)
96                         return 17;
97
98                 if (t.GetMember ("Method")[0].GetCustomAttributes (ca, false).Length != 0)
99                         return 18;
100
101                 if (t.GetMethod ("Method").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
102                         return 19;
103
104                 if (t.GetConstructors ()[0].GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
105                         return 20;
106
107                 if (t.GetConstructors ()[0].GetCustomAttributes (ca, false).Length != 0)
108                         return 21;
109
110                 // Transformations
111                 DynamicAttribute da;
112                 da = t.GetMember ("t")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
113                 if (da == null)
114                         return 40;
115
116                 if (!da.TransformFlags.SequenceEqual (new bool[] { false, true }))
117                         return 41;
118
119                 da = t.GetMember ("t2")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
120                 if (da == null)
121                         return 42;
122
123                 if (!da.TransformFlags.SequenceEqual (new bool[] { false, true }))
124                         return 43;
125
126                 da = t.GetMember ("v")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
127                 if (da == null)
128                         return 44;
129                 if (!da.TransformFlags.SequenceEqual (new bool[] { false, true, false, false, true }))
130                         return 45;
131                 
132                 da = t.GetMember ("iface")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;
133                 if (da == null)
134                         return 46;
135                 if (!da.TransformFlags.SequenceEqual (new bool[] { false, false, true }))
136                         return 47;
137
138                 t = typeof (Del);
139
140                 if (t.GetMember ("Invoke")[0].GetCustomAttributes (ca, false).Length != 0)
141                         return 100;
142
143                 if (t.GetMethod ("Invoke").GetParameters ()[0].GetCustomAttributes (ca, false).Length != 1)
144                         return 101;
145
146                 if (t.GetMethod ("Invoke").ReturnParameter.GetCustomAttributes (ca, false).Length != 1)
147                         return 102;
148
149                 Console.WriteLine ("ok");
150                 return 0;
151         }
152 }