Warnings cleanup
[mcs.git] / tests / test-221.cs
blobae8ff2ac0325dded50652de19559cd0f91bc1626
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 //
7 class A { public virtual int Blah { get { return 1; } set {} } }
9 class B : A {
10 public override int Blah { get { return 2; } }
12 public static bool Test ()
14 // Make sure we see that set in A
16 B b = new B ();
18 if (b.Blah != 2) return false;
19 if (b.Blah ++ != 2) return false;
20 b.Blah = 0;
22 return true;
26 abstract class C { public abstract int Blah { get; set; } }
27 class D : C { public override int Blah { get { return 2; } set {} } }
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; } }
34 public static bool Test ()
36 E e = new E ();
38 if (e.Blah != 2) return false;
39 if (e.Blah ++ != 2) return false;
40 e.Blah = 2;
42 return true;
46 interface IBlah {
47 int this [int i] { get; set; }
48 int Blah { get; set; }
51 class F : IBlah {
52 int IBlah.this [int i] { get { return 1; } set {} }
53 int IBlah.Blah { get { return 1; } set {} }
55 public int this [int i] { get { return 2; } set {} }
56 public int Blah { get { return 2; } set {} }
58 public static bool Test ()
60 // Make sure we dont see a conflict between
61 // the explicit impl and the non interface version
62 F f = new F ();
64 if (f.Blah != 2) return false;
65 if (f.Blah ++ != 2) return false;
66 f.Blah = 2;
69 if (f [1] != 2) return false;
70 if (f [1] ++ != 2) return false;
71 f [1] = 2;
73 return true;
77 class Driver {
78 static int Main ()
80 if (! B.Test ()) return 1;
81 if (! E.Test ()) return 2;
82 if (! F.Test ()) return 3;
84 return 0;