Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-372.cs
1 // Some interfaces, one is a superset of the other  
2 public interface Node  
3 {  
4     int GetStat();  
5 }  
6 public interface FileNode : Node  
7 {  
8     int NotUsed();  
9 }  
10   
11 // Some basic implementations, one is a superset of the other  
12 public class GenericNode : Node  
13 {  
14     public virtual int GetStat() { return 0; }  
15 }  
16   
17 public class GenericFileNode : GenericNode , FileNode  
18 {  
19     public virtual int NotUsed() { return -1; }  
20 }  
21   
22   
23 // Now the ability to override a method depends on if we specify again that we  
24 // implement an interface -- although we must because we derive from a class  
25 // that does.  
26 public class WorkingTest : GenericFileNode , FileNode  
27 {  
28     public override int GetStat() { return 42; }  
29 }  
30   
31 public class FailingTest : GenericFileNode  
32 {  
33     // This never gets called, but it builds, so what did we override?!!! 
34     public override int GetStat() { return 42; }  
35 }  
36   
37 public class TestWrapper  
38 {  
39     static bool Test(Node inst, string name)  
40     {  
41         if(inst.GetStat() == 42)  
42         {  
43             System.Console.WriteLine("{0} -- Passed", name);  
44             return true;  
45         } else  
46         {  
47             System.Console.WriteLine("{0} -- FAILED", name);  
48             return false;  
49         }  
50     }  
51   
52     public static int Main()  
53     {  
54         if( Test(new WorkingTest(), "WorkingTest")  
55                 && Test(new FailingTest(), "FailingTest") )  
56             return 0; // everything worked  
57         else  
58             return 1;  
59     }  
60 }
61
62
63