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

test-99.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 036850e34bbd396b89818a143a148ddff87b2ffd (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
//
// Tests the resulting value of operator + (U x, E y)
// as well as implicit conversions in the above operator.
//
using System;
class X {
	enum A : int {
		a = 1, b, c
	}
	
	enum Test : short {
		A = 1,
		B
	}
	
	public static int Main ()
	{
		int v = 1;
		object foo = (v + A.a);
		object foo2 = (1 + A.a);

		if (foo.GetType ().ToString () != "X+A"){
			Console.WriteLine ("Expression evaluator bug in E operator + (U x, E y)");
			return 1;
		}
		
		if (foo2.GetType ().ToString () != "X+A"){
			Console.WriteLine ("Constant folder bug in E operator + (U x, E y)");
			return 2;
		}

		// Now try the implicit conversions for underlying types in enum operators
		byte b = 1;
		short s = (short) (Test.A + b);
		
		const int e = A.b + 1 - A.a;

		//
		// Make sure that other operators still work
		if (Test.A != Test.A)
			return 3;
		if (Test.A == Test.B)
			return 4;

		const A e2 = 3 - A.b;
		if (e2 != A.a)
			return 5;
		
		return 0;
	}
}