2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / tests / test-56.cs
1 //
2 // Stress test properties and the various modes of 
3 // declarations (virtual, overrides, abstract, new)
4 //
5 using System;
6
7 interface I {
8         int P {
9                 get; set;
10         }
11 }
12
13 abstract class A : I {
14         public int p;
15         public int q;
16         
17         public int P {
18                 get { return p; }
19                 set { p = value; }
20         }
21
22         public abstract int Q { get; set; }
23
24         public int r;
25         public virtual int R { get { return r; } set { r = value; } }
26 }
27
28 class B : A {
29         public int bp;
30
31         public new int P
32         {
33                 get { return bp; }
34                 set { bp = value; }
35         }
36
37         public override int Q {
38                 get { return q; }
39                 set { q = value; }
40         }
41 }
42
43 class C : A {
44         public override int Q {
45                 get { return q; }
46                 set { q = value; }
47         }
48
49         public int rr;
50         public override int R { get { return rr; } set { rr = value; } }
51 }
52
53 class M {
54
55         static int Main ()
56         {
57                 B b = new B ();
58
59                 b.P = 1;
60                 b.R = 10;
61                 b.Q = 20;
62                                  
63                 if (b.P != 1)
64                         return 1;
65                 if (b.bp != 1)
66                         return 2;
67
68                 if (b.R != 10)
69                         return 3;
70                 if (b.r != 10)
71                         return 4;
72
73                 if (b.Q != 20)
74                         return 5;
75                 if (b.q != 20)
76                         return 6;
77
78                 C c = new C ();
79
80                 c.R = 10;
81                 c.Q = 20;
82                 c.P = 30;
83                 if (c.R != 10)
84                         return 7;
85                 if (c.rr != 10)
86                         return 8;
87                 if (c.P != 30)
88                         return 9;
89                 if (c.p != 30)
90                         return 10;
91
92                 Console.WriteLine ("Test passes");
93                 return 0;
94         }
95 }
96