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

test-232.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cf3a426fa33a822afe3443a2aa15e82d3a7679ad (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
using System;
using System.Reflection;

public class CtorInfoTest
{
	enum E
	{
		A = 0,
		B = 1
	}
	
	public static void Main(string[] args)
	{

		// uses static initialization
		int[] iarray = // int array, int constants
		{
			0,
			1,
			2,
			3,
			4,
			5,
			6,
		};
		
		object[] oarray = // int array, int constants
		{
			0,
			E.A,
			null,
			"A",
			new int (),
			1.1,
			-2m,
		};
		
		object[] ooarray =
		{
			null,
			new int[] { 0, 0 },
			0,
			new object[0],
		};
		
		// mcs used to throw with 7 or more elements in the array initializer
		ConstructorInfo[] ciarray = // ref array, null constants
		{
			null,
			null,
			null,
			null,
			null,
			null,
			null,
		};

		string[] scarray = // string array, string constants
		{
			"a",
			"b",
			"c",
			"d",
			"e",
			"f",
			"g",
		};

		string[] snarray = // string array, null constants
		{
			null,
			null,
			null,
			null,
			null,
			null,
			null,
		};

		decimal[] darray = // decimal constants
		{
			0M,
			1M,
			2M,
			3M,
			4M,
			5M,
			6M,
			7M,
		};

		IConvertible[] lcarray = // boxed integer constants
		{
			0,
			1,
			2,
			3,
			4,
			5,
			6,
			7,
		};
		

		System.Enum[] eatarray = // boxed enum constants
		{
			AttributeTargets.Assembly,
			AttributeTargets.Module,
			AttributeTargets.Class,
			AttributeTargets.Struct,
			AttributeTargets.Enum,
			AttributeTargets.Constructor,
			AttributeTargets.Method,
			AttributeTargets.Property,
			AttributeTargets.Field,
			AttributeTargets.Event,
			AttributeTargets.Interface,
			AttributeTargets.Parameter,
			AttributeTargets.Delegate,
			AttributeTargets.ReturnValue,
			AttributeTargets.All,
		};

		E[] atarray = // enum constants
		{
			E.A,
			E.B
		};

		
		string[] smarray = // string array, mixture
		{
			null,
			"a"
		};

		for (int i = 0; i < iarray.Length; ++i)
			Assert (i, iarray [i]);
		
		for (int i = 0; i < ciarray.Length; ++i)
			Assert (null, ciarray [i]);
		
		Assert ("a", scarray [0]);

		for (int i = 0; i < snarray.Length; ++i)
			Assert (null, snarray [i]);

		for (decimal i = 0; i < darray.Length; ++i)
			Assert (i, darray [(int)i]);

		for (int i = 0; i < lcarray.Length; ++i)
			Assert (i, lcarray [i]);

		Assert (E.A, atarray [0]);
		Assert (E.B, atarray [1]);
		
		Assert (AttributeTargets.Assembly, eatarray [0]);
		Assert (AttributeTargets.Class, eatarray [2]);
		
		Assert (null, smarray [0]);
		Assert ("a", smarray [1]);
		
	}
	
	static void Assert (object expected, object value)
	{
		if (expected == null && value == null)
			return;
		
		if (!expected.Equals (value))
			Console.WriteLine ("ERROR {0} != {1}", expected, value);
	}
}