* iface4.cs: Tested also Stop method (just to be on the safe side).
[mono.git] / mono / tests / iface4.cs
1 using System;
2
3 public interface IVehicle {
4         int Start ();
5         int Stop ();
6         int Turn ();
7 }
8
9 public class Base : IVehicle {
10         int IVehicle.Start () { return 1; }
11         public int Stop () { return 2; }
12         public virtual int Turn () { return 3; }
13 }
14
15 public class Derived1 : Base {
16         // replaces Base.Turn + IVehice.Turn
17         public override int Turn () { return 4; }
18 }
19
20 public class Derived2 : Base, IVehicle {
21         // legal - we redeclared IVehicle support
22         public new int Stop () { return 6; }
23         // legal - we redeclared IVehicle support
24         int IVehicle.Start () { return 5; }
25         // replaces IVehicle.Turn 
26         int IVehicle.Turn () { return 7; }
27         // replaces Base.Turn 
28         public override int Turn () { return 8; }
29 }
30
31 public class Test {
32
33         static int Main () {
34                 Derived1 d1 = new Derived1 ();
35                 Derived2 d2 = new Derived2 ();
36                 Base b1 = d1;
37                 Base b2 = d2;
38                 Base rb = new Base ();
39
40                 if (d1.Turn () != 4)
41                         return 1;
42                 
43                 if (((IVehicle)d1).Turn () != 4)
44                         return 2;
45
46                 if (((IVehicle)d2).Turn () != 7)
47                         return 3;
48
49                 if (b2.Turn () != 8)
50                         return 4;
51                 
52                 if (((IVehicle)b2).Turn () != 7)
53                         return 5;
54                 
55                 if (((IVehicle)rb).Stop () != 2)
56                         return 6;
57
58                 if (((IVehicle)d1).Stop () != 2)
59                         return 7;
60
61                 if (((IVehicle)d2).Stop () != 6)
62                         return 8;
63
64                 //Console.WriteLine ("TEST {0}", ((IVehicle)b2).Turn ());
65                 return 0;
66         }
67 }