Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-136.cs
1 //
2 // Tests that explicit and normal implementations of methods are handled
3 // properly.  Before we used to have the normal method implementation
4 // "implement" the classes, so that it would go into an infinite loop.
5 // (bug #26334)
6 //
7 // Now explicit implementations are defined first.
8 //
9 using System;
10
11 public interface IDiagnostic
12 {
13         void Stop();
14
15 public interface IAutomobile
16 {
17         void Stop();
18 }
19
20 public class MyCar: IAutomobile, IDiagnostic {
21         public bool diag_stop, car_stop, auto_stop;
22         
23         void IDiagnostic.Stop() {
24                 diag_stop = true;
25         }
26
27         public void Stop() {
28                 car_stop = true;
29                 IAutomobile self = (IAutomobile)this; // cast this
30                 self.Stop(); // forwarding call
31         }
32
33         void IAutomobile.Stop()
34         {
35                 auto_stop = true;
36         }
37 }
38
39 class TestConflict {
40         public static int Main ()
41         {
42                 MyCar car1 = new MyCar();
43                 car1.Stop(); // calls the IAutomobile.Stop implementation
44                 
45                 IDiagnostic car2 = new MyCar();
46                 car2.Stop();
47                 
48                 IAutomobile car3 = new MyCar();
49                 car3.Stop();
50
51                 if (!car1.car_stop)
52                         return 1;
53
54                 if (car1.diag_stop)
55                         return 2;
56
57                 Console.WriteLine ("ok");
58                 return 0;
59         }
60 }