2008-10-24 Mark Probst <mark.probst@gmail.com>
[mono.git] / mono / tests / iface4.cs
index 6f30e77d98f2d2e44e65706021929da91c0471f2..5b667ffcee71b6b3a5661fedefc75a20e7548851 100644 (file)
@@ -6,10 +6,15 @@ public interface IVehicle {
        int Turn ();
 }
 
+public interface IWalker {
+       int Walk ();
+}
+
 public class Base : IVehicle {
        int IVehicle.Start () { return 1; }
        public int Stop () { return 2; }
        public virtual int Turn () { return 3; }
+       public int Walk () { return 1; }
 }
 
 public class Derived1 : Base {
@@ -18,23 +23,28 @@ public class Derived1 : Base {
 }
 
 public class Derived2 : Base, IVehicle {
-       // legal - we redeclared IVehicle support
-       int IVehicle.Start () { return 5; }
        // legal - we redeclared IVehicle support
        public new int Stop () { return 6; }
+       // legal - we redeclared IVehicle support
+       int IVehicle.Start () { return 5; }
        // replaces IVehicle.Turn 
        int IVehicle.Turn () { return 7; }
        // replaces Base.Turn 
        public override int Turn () { return 8; }
 }
 
+public class Derived3 : Derived1, IWalker {
+}
+
 public class Test {
 
        static int Main () {
                Derived1 d1 = new Derived1 ();
                Derived2 d2 = new Derived2 ();
+               Derived3 d3 = new Derived3 ();
                Base b1 = d1;
                Base b2 = d2;
+               Base rb = new Base ();
 
                if (d1.Turn () != 4)
                        return 1;
@@ -48,8 +58,22 @@ public class Test {
                if (b2.Turn () != 8)
                        return 4;
                
-               //Console.WriteLine ("TEST {0}", b2.Turn ());   
+               if (((IVehicle)b2).Turn () != 7)
+                       return 5;
+               
+               if (((IVehicle)rb).Stop () != 2)
+                       return 6;
+
+               if (((IVehicle)d1).Stop () != 2)
+                       return 7;
+
+               if (((IVehicle)d2).Stop () != 6)
+                       return 8;
+
+               if (d3.Walk () != 1)
+                       return 9;
 
+               //Console.WriteLine ("TEST {0}", ((IVehicle)b2).Turn ());
                return 0;
        }
 }