summaryrefslogtreecommitdiff
path: root/mcs/tests/gtest-143.cs
blob: 808bbca599d36185126d52dca65aa2877efdc39c (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
using System;

class X
{
	static int counter;
	static int Index ()
	{
		if (counter++ != 0)
			throw new ApplicationException ();
		
		return 1;
	}
	
	int? indexer;
	int? this [int index] {
		get {
			return indexer;
		}
		set {
			indexer = value;
		}
	}	
	
	static int Test ()
	{
		int? a = 5;
		int? b = a++;

		if (a != 6)
			return 1;
		if (b != 5)
			return 2;

		int? c = ++a;

		if (c != 7)
			return 3;

		b++;
		++b;

		if (b != 7)
			return 4;

		int? d = b++ + ++a;

		if (a != 8)
			return 5;
		if (b != 8)
			return 6;
		if (d != 15)
			return 7;
		
		var s = new short?[] { 3, 2, 1 };
		counter = 0;
		var r = s [Index ()]++;
		if (counter != 1)
			return 8;
		
		if (r != 2)
			return 9;
		
		if (s[1] != 3)
			return 10;

		counter = 0;
		s [Index ()]++;
		if (counter != 1)
			return 11;
		
		if (s[1] != 4)
			return 12;
			
		X x = new X ();
		x.indexer = 6;
		counter = 0;
		var r2 = x[Index ()]--;
		if (counter != 1)
			return 13;
			
		if (r2 != 6)
			return 14;
		
		if (x.indexer != 5)
			return 15;

		return 0;
	}

	public static int Main ()
	{
		int result = Test ();
		if (result != 0)
			Console.WriteLine ("ERROR: {0}", result);
		return result;
	}
}