codeowners update
[mono.git] / mcs / tests / gtest-143.cs
1 using System;
2
3 class X
4 {
5         static int counter;
6         static int Index ()
7         {
8                 if (counter++ != 0)
9                         throw new ApplicationException ();
10                 
11                 return 1;
12         }
13         
14         int? indexer;
15         int? this [int index] {
16                 get {
17                         return indexer;
18                 }
19                 set {
20                         indexer = value;
21                 }
22         }       
23         
24         static int Test ()
25         {
26                 int? a = 5;
27                 int? b = a++;
28
29                 if (a != 6)
30                         return 1;
31                 if (b != 5)
32                         return 2;
33
34                 int? c = ++a;
35
36                 if (c != 7)
37                         return 3;
38
39                 b++;
40                 ++b;
41
42                 if (b != 7)
43                         return 4;
44
45                 int? d = b++ + ++a;
46
47                 if (a != 8)
48                         return 5;
49                 if (b != 8)
50                         return 6;
51                 if (d != 15)
52                         return 7;
53                 
54                 var s = new short?[] { 3, 2, 1 };
55                 counter = 0;
56                 var r = s [Index ()]++;
57                 if (counter != 1)
58                         return 8;
59                 
60                 if (r != 2)
61                         return 9;
62                 
63                 if (s[1] != 3)
64                         return 10;
65
66                 counter = 0;
67                 s [Index ()]++;
68                 if (counter != 1)
69                         return 11;
70                 
71                 if (s[1] != 4)
72                         return 12;
73                         
74                 X x = new X ();
75                 x.indexer = 6;
76                 counter = 0;
77                 var r2 = x[Index ()]--;
78                 if (counter != 1)
79                         return 13;
80                         
81                 if (r2 != 6)
82                         return 14;
83                 
84                 if (x.indexer != 5)
85                         return 15;
86
87                 return 0;
88         }
89
90         public static int Main ()
91         {
92                 int result = Test ();
93                 if (result != 0)
94                         Console.WriteLine ("ERROR: {0}", result);
95                 return result;
96         }
97 }