Merge pull request #1193 from esdrubal/decimal-round
[mono.git] / mcs / tests / test-null-operator-05.cs
1 using System;
2
3 class CI
4 {
5         public string this [string i] { set { } get { return ""; } }
6         public int? this [int i] { set { } get { return 1; } }
7 }
8
9 class C
10 {
11         static int TestArrayAccess ()
12         {
13                 byte[] arr = null;
14                 var v = arr? [0];
15                 if (v != null)
16                         return 1;
17
18                 long?[] ar2 = null;
19                 var v2 = ar2? [-1];
20                 if (v2 != null)
21                         return 2;
22
23 // TODO: Disabled for now?
24 //        arr? [0] += 2;
25                 return 0;
26         }
27
28         static int TestIndexerAccess ()
29         {
30                 CI ci = null;
31                 var v = ci? ["x"];
32                 if (v != null)
33                         return 1;
34
35                 var v2 = ci? [0];
36                 if (v2 != null)
37                         return 2;
38
39 // TODO: Disabled for now?
40 //       ci? [0] += 3;
41                 return 0;
42         }
43
44         static int Main ()
45         {
46                 int res;
47                 res = TestArrayAccess ();
48                 if (res != 0)
49                         return 10 + res;
50
51                 res = TestIndexerAccess ();
52                 if (res != 0)
53                         return 20 + res;
54
55                 Console.WriteLine ("ok");
56                 return 0;
57         }
58 }