Merge pull request #3563 from lewurm/interpreter
[mono.git] / mcs / tests / test-94.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         public static int Main () {
34                 Derived1 d1 = new Derived1 ();
35                 Derived2 d2 = new Derived2 ();
36                 Base b1 = d1;
37                 Base b2 = d2;
38
39                 if (d1.Turn () != 4)
40                         return 1;
41                 
42                 if (((IVehicle)d1).Turn () != 4)
43                         return 2;
44
45                 if (((IVehicle)d2).Turn () != 7)
46                         return 3;
47
48                 if (b2.Turn () != 8)
49                         return 4;
50                 
51                 if (((IVehicle)b2).Turn () != 7)
52                         return 5;
53                 
54                 //Console.WriteLine ("TEST {0}", ((IVehicle)b2).Turn ());       
55
56                 return 0;
57         }
58 }
59