[sdks] Fix README.md
[mono-project.git] / mcs / tests / gtest-143.cs
blob808bbca599d36185126d52dca65aa2877efdc39c
1 using System;
3 class X
5 static int counter;
6 static int Index ()
8 if (counter++ != 0)
9 throw new ApplicationException ();
11 return 1;
14 int? indexer;
15 int? this [int index] {
16 get {
17 return indexer;
19 set {
20 indexer = value;
24 static int Test ()
26 int? a = 5;
27 int? b = a++;
29 if (a != 6)
30 return 1;
31 if (b != 5)
32 return 2;
34 int? c = ++a;
36 if (c != 7)
37 return 3;
39 b++;
40 ++b;
42 if (b != 7)
43 return 4;
45 int? d = b++ + ++a;
47 if (a != 8)
48 return 5;
49 if (b != 8)
50 return 6;
51 if (d != 15)
52 return 7;
54 var s = new short?[] { 3, 2, 1 };
55 counter = 0;
56 var r = s [Index ()]++;
57 if (counter != 1)
58 return 8;
60 if (r != 2)
61 return 9;
63 if (s[1] != 3)
64 return 10;
66 counter = 0;
67 s [Index ()]++;
68 if (counter != 1)
69 return 11;
71 if (s[1] != 4)
72 return 12;
74 X x = new X ();
75 x.indexer = 6;
76 counter = 0;
77 var r2 = x[Index ()]--;
78 if (counter != 1)
79 return 13;
81 if (r2 != 6)
82 return 14;
84 if (x.indexer != 5)
85 return 15;
87 return 0;
90 public static int Main ()
92 int result = Test ();
93 if (result != 0)
94 Console.WriteLine ("ERROR: {0}", result);
95 return result;