Merge pull request #5428 from kumpera/wasm-support-p2
[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 interface IWalker {
10         int Walk ();
11 }
12
13 public class Base : IVehicle {
14         int IVehicle.Start () { return 1; }
15         public int Stop () { return 2; }
16         public virtual int Turn () { return 3; }
17         public int Walk () { return 1; }
18 }
19
20 public class Derived1 : Base {
21         // replaces Base.Turn + IVehice.Turn
22         public override int Turn () { return 4; }
23 }
24
25 public class Derived2 : Base, IVehicle {
26         // legal - we redeclared IVehicle support
27         public new int Stop () { return 6; }
28         // legal - we redeclared IVehicle support
29         int IVehicle.Start () { return 5; }
30         // replaces IVehicle.Turn 
31         int IVehicle.Turn () { return 7; }
32         // replaces Base.Turn 
33         public override int Turn () { return 8; }
34 }
35
36 public class Derived3 : Derived1, IWalker {
37 }
38
39 public class Test {
40
41         static int Main () {
42                 Derived1 d1 = new Derived1 ();
43                 Derived2 d2 = new Derived2 ();
44                 Derived3 d3 = new Derived3 ();
45                 Base b1 = d1;
46                 Base b2 = d2;
47                 Base rb = new Base ();
48
49                 if (d1.Turn () != 4)
50                         return 1;
51                 
52                 if (((IVehicle)d1).Turn () != 4)
53                         return 2;
54
55                 if (((Base)d2).Turn () != 8)
56                         return 10;
57
58                 if (((IVehicle)d2).Turn () != 7)
59                         return 3;
60
61                 if (b2.Turn () != 8)
62                         return 4;
63                 
64                 if (((IVehicle)b2).Turn () != 7)
65                         return 5;
66                 
67                 if (((IVehicle)rb).Stop () != 2)
68                         return 6;
69
70                 if (((IVehicle)d1).Stop () != 2)
71                         return 7;
72
73                 if (((IVehicle)d2).Stop () != 6)
74                         return 8;
75
76                 if (d3.Walk () != 1)
77                         return 9;
78
79                 //Console.WriteLine ("TEST {0}", ((IVehicle)b2).Turn ());
80                 return 0;
81         }
82 }