[2019-12] [threads] Add back mono_threads_attach_tools_thread as a public API (#18074)
[mono-project.git] / mono / tests / iface4.cs
blob6cb9df81d683856c1ec82a7408b59130c6a6dc78
1 using System;
3 public interface IVehicle {
4 int Start ();
5 int Stop ();
6 int Turn ();
9 public interface IWalker {
10 int Walk ();
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; }
20 public class Derived1 : Base {
21 // replaces Base.Turn + IVehice.Turn
22 public override int Turn () { return 4; }
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; }
36 public class Derived3 : Derived1, IWalker {
39 public class Test {
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 ();
49 if (d1.Turn () != 4)
50 return 1;
52 if (((IVehicle)d1).Turn () != 4)
53 return 2;
55 if (((Base)d2).Turn () != 8)
56 return 10;
58 if (((IVehicle)d2).Turn () != 7)
59 return 3;
61 if (b2.Turn () != 8)
62 return 4;
64 if (((IVehicle)b2).Turn () != 7)
65 return 5;
67 if (((IVehicle)rb).Stop () != 2)
68 return 6;
70 if (((IVehicle)d1).Stop () != 2)
71 return 7;
73 if (((IVehicle)d2).Stop () != 6)
74 return 8;
76 if (d3.Walk () != 1)
77 return 9;
79 //Console.WriteLine ("TEST {0}", ((IVehicle)b2).Turn ());
80 return 0;