Welcome to mirror list, hosted at ThFree Co, Russian Federation.

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