Merge pull request #3563 from lewurm/interpreter
[mono.git] / mcs / tests / test-221.cs
1 //
2 // Tests for bug # 52427 -- property inhertance stuff.
3 // these tests are problems that cropped up while
4 // making the patch. We dont want to regress on these.
5 //
6
7 class A { public virtual int Blah { get { return 1; } set {} } }
8
9 class B : A {
10         public override int Blah { get { return 2; } }
11         
12         public static bool Test ()
13         {
14                 // Make sure we see that set in A
15                 
16                 B b = new B ();
17                 
18                 if (b.Blah != 2) return false;
19                 if (b.Blah ++ != 2) return false;
20                 b.Blah = 0;
21                 
22                 return true;
23         }
24 }
25
26 abstract class C { public abstract int Blah { get; set; } }
27 class D : C { public override int Blah { get { return 2; } set {} } }
28
29 class E : D {
30         // Make sure we see that there is actually a base
31         // which we can call
32         public override int Blah { get { return base.Blah; } }
33         
34         public static bool Test ()
35         {       
36                 E e = new E ();
37                 
38                 if (e.Blah != 2) return false;
39                 if (e.Blah ++ != 2) return false;
40                 e.Blah = 2;
41                 
42                 return true;
43         }
44 }
45
46 interface IBlah {
47         int this [int i] { get; set; }
48         int Blah { get; set; }
49 }
50
51 class F : IBlah {
52         int IBlah.this [int i] { get { return 1; } set {} }
53         int IBlah.Blah { get { return 1; } set {} }
54         
55         public int this [int i] { get { return 2; } set {} }
56         public int Blah { get { return 2; } set {} }
57         
58         public static bool Test ()
59         {
60                 // Make sure we dont see a conflict between
61                 // the explicit impl and the non interface version
62                 F f = new F ();
63                 
64                 if (f.Blah != 2) return false;
65                 if (f.Blah ++ != 2) return false;
66                 f.Blah = 2;
67                 
68                 
69                 if (f [1] != 2) return false;
70                 if (f [1] ++ != 2) return false;
71                 f [1] = 2;
72                 
73                 return true;
74         }
75 }
76
77 class Driver {
78         public static int Main ()
79         {
80                 if (! B.Test ()) return 1;
81                 if (! E.Test ()) return 2;
82                 if (! F.Test ()) return 3;
83                 
84                 return 0;
85         }
86 }