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

test-148.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 61aa394433ca6f3f52cb63a1e66a57ad91456ae0 (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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
using System;
using System.Collections;
using System.Runtime.CompilerServices;

public interface X
{
	[IndexerName ("Foo")]
	int this [int a] {
		get;
	}
}

public class Y : X
{
	int X.this [int a] {
		get {
			return 1;
		}
	}

	[IndexerName ("Bar")]
	public int this [int a] {
		get {
			return 2;
		}
	}

	[IndexerName ("Bar")]
	public long this [double a] {
		get {
			return 3;
		}
	}
}

public class Z : Y
{
	[IndexerName ("Whatever")]
	new public long this [double a] {
		get {
			return 4;
		}
	}

	[IndexerName ("Whatever")]
	public float this [long a, int b] {
		get {
			return a / b;
		}
	}

	public int InstanceTest ()
	{
		double index = 5;

		Console.WriteLine ("INSTANCE TEST");

		if (this [index] != 4)
			return 6;
		if (base [index] != 3)
			return 7;

		return 0;
	}

	public static int Test ()
	{
		Z z = new Z ();
		X x = (X) z;
		Y y = (Y) z;

		Console.WriteLine (z [1]);
		Console.WriteLine (y [2]);
		Console.WriteLine (x [3]);

		if (z [1] != 4)
			return 1;
		if (y [1] != 2)
			return 2;
		if (x [1] != 1)
			return 3;

		double index = 5;

		Console.WriteLine (z [index]);
		Console.WriteLine (y [index]);

		if (z [index] != 4)
			return 4;
		if (y [index] != 3)
			return 5;

		int retval = z.InstanceTest ();
		if (retval != 0)
			return retval;

		B b = new B ();
		if (b [4] != 16)
			return 8;
		if (b [3,5] != 15)
			return 9;

		D d = new D ();
		if (d [4] != 16)
			return 10;
		if (d [3,5] != 15)
			return 11;

		//
		// Now test for bug 35492
		//
		ChildList xd = new ChildList ();

		xd.Add (0);
		if (0 != (int)xd [0])
			return 12;
		
		xd.Test ();
		if (1 != (int) xd [0])
			return 13;
		
		return 0;
	}

	class MyArray : ArrayList
	{
		public override object this[int index]
		{
			get { return base[index]; }
			set { base[index] = value;}
		}
	}

	public static int Main ()
	{
		int result = Test ();

		Console.WriteLine ("RESULT: " + result);

		E e = new E ();
		e.g = "monkey";

		//
		// Now test base [...]
		//
		MyArray arr = new MyArray ( );
		arr.Add ( "String value" );
		if (arr[0].ToString () != "String value")
			return 100;

		return result;
	}

}

public class A
{
	[IndexerName("Monkey")]
	public int this [int value] {
		get {
			return value * 4;
		}
	}
}

public class B : A
{
	public long this [long a, int value] {
		get {
			return a * value;
		}
	}
}

public class C
{
	public int this [int value] {
		get {
			return value * 4;
		}
	}
}

public class D : C
{
	public long this [long a, int value] {
		get {
			return a * value;
		}
	}
}

public class E {
	public virtual string g {
		get { return "g"; }
		set { }
	}
}

public class F : E {
	public override string g {
		get { return "h"; }
	}
}

public class DisposableNotifyList : ArrayList
	{
	}
	
public class ChildList : DisposableNotifyList
    {
		public void Test()
		{
			base[0] = 1;

		}
    }