Merge pull request #1180 from akoeplinger/no-net40-in-make-check
[mono.git] / mcs / tests / test-null-operator-02.cs
1 using System;
2
3 class CI
4 {
5     public long Field;
6     public sbyte? FieldNullable;
7     public object FieldReference;
8
9         public int Prop { get; set; }
10     public byte? PropNullable { get; set; }
11     public string PropReference { get; set; }
12
13     public event Action ev1;
14 }
15
16 class C
17 {
18     static int TestProperty ()
19     {
20         CI ci = null;
21         var m1 = ci?.Prop;
22         var m2 = ci?.PropNullable;
23         var m3 = ci?.PropReference;
24
25 //        ci?.Prop = 6;
26
27         ci = new CI ();
28         m1 = ci?.Prop;
29         m2 = ci?.PropNullable;
30         m3 = ci?.PropReference;
31
32 //        ci?.Prop = 5;
33 //        if (ci.Prop != 5)
34 //            return 1;
35
36 // TODO: It's not allowed for now
37 //      ci?.Prop += 4;
38 //      var pp1 = ci?.Prop = 4;
39 //      var pp2 = ci?.Prop += 4;
40
41         return 0;
42     }
43
44     static int TestField ()
45     {
46         CI ci = null;
47         var m1 = ci?.Field;
48         var m2 = ci?.FieldNullable;
49         var m3 = ci?.FieldReference;
50
51 //        ci?.Field = 6;
52
53         ci = new CI ();
54         m1 = ci?.Field;
55         m2 = ci?.FieldNullable;
56         m3 = ci?.FieldReference;
57
58 //        ci?.Field = 5;
59 //        if (ci.Field != 5)
60 //            return 1;
61
62 // TODO: It's not allowed for now
63 //      ci?.Field += 4;
64 //      var pp1 = ci?.Field = 4;
65 //      var pp2 = ci?.Field += 4;
66
67         return 0;
68     }
69
70     static int TestEvent ()
71     {
72         CI ci = null;
73         ci?.ev1 += null;
74
75         ci = new CI ();
76         ci?.ev1 += null;
77
78         return 0;
79     }
80
81     static int Main ()
82     {
83         int res;
84
85         res = TestProperty ();
86         if (res != 0)
87             return 10 + res;
88
89         res = TestField ();
90         if (res != 0)
91             return 20 + res;
92
93         res = TestEvent ();
94         if (res != 0)
95             return 30 + res;            
96
97         Console.WriteLine ("ok");
98         return 0;
99     }
100 }