Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-23.cs
1 //
2 // Tests properties
3 //
4 using System;
5
6 class X {
7         static int v;
8
9         static X ()
10         {
11                 v = 10;
12         }
13
14         public static int Value {
15                 get {
16                         return v;
17                 }
18
19                 set {
20                         v = value;
21                 }
22         }
23
24         public static int Main ()
25         {
26                 if (Value != 10)
27                         return 1;
28
29                 Value = 4;
30
31                 if (Value != 4)
32                         return 2;
33
34                 Y y = new Y ("hello");
35
36                 if (y.Value != "hello")
37                         return 3;
38
39                 y.Value = "goodbye";
40                 if (y.Value != "goodbye")
41                         return 4;
42
43                 Z z = new Z ();
44
45                 if (Z.IVal != 4)
46                         return 5;
47                 Z.IVal = 10;
48                 if (Z.IVal != 10)
49                         return 6;
50
51                 z.XVal = 23;
52                 if (z.XVal != 23)
53                         return 7;
54
55                 return 0;
56         }
57 }
58         
59 class Y {
60         string init;
61         
62         public Y (string s)
63         {
64                 init = s;
65         }
66
67         public string Value {
68                 get {
69                         return init;
70                 }
71
72                 set {
73                         init = value;
74                 }
75         }
76 }
77
78 struct Z {
79         static int val;
80         int xval;
81         
82         static Z ()
83         {
84                 val = 4;
85         }
86
87         static public int IVal {
88                 get {
89                         return val;
90                 }
91
92                 set {
93                         val= value;
94                 }
95         }
96
97         public int XVal {
98                 get {
99                         return xval;
100                 }
101
102                 set {
103                         xval = value;
104                 }
105         }
106 }