2002-08-15 Tim Coleman <tim@timcoleman.com>
[mono.git] / mcs / tests / test-148.cs
1 using System;
2 using System.Runtime.CompilerServices;
3
4 public interface X
5 {
6         [IndexerName ("Foo")]
7         int this [int a] {
8                 get;
9         }
10 }
11
12 public class Y : X
13 {
14         int X.this [int a] {
15                 get {
16                         return 1;
17                 }
18         }
19
20         [IndexerName ("Bar")]
21         public int this [int a] {
22                 get {
23                         return 2;
24                 }
25         }
26
27         [IndexerName ("Bar")]
28         public long this [double a] {
29                 get {
30                         return 3;
31                 }
32         }
33 }
34
35 public class Z : Y
36 {
37         [IndexerName ("Whatever")]
38         new public long this [double a] {
39                 get {
40                         return 4;
41                 }
42         }
43
44         public static int Test ()
45         {
46                 Z z = new Z ();
47                 X x = (X) z;
48                 Y y = (Y) z;
49
50                 Console.WriteLine (z [1]);
51                 Console.WriteLine (y [2]);
52                 Console.WriteLine (x [3]);
53
54                 if (z [1] != 4)
55                         return 1;
56                 if (y [1] != 2)
57                         return 2;
58                 if (x [1] != 1)
59                         return 3;
60
61                 double index = 5;
62
63                 Console.WriteLine (z [index]);
64                 Console.WriteLine (y [index]);
65
66                 if (z [index] != 4)
67                         return 4;
68                 if (y [index] != 3)
69                         return 5;
70
71                 return 0;
72         }
73
74         public static int Main ()
75         {
76                 int result = Test ();
77
78                 Console.WriteLine ("RESULT: " + result);
79
80                 return result;
81         }
82 }