* test-148.cs: New test.
svn path=/trunk/mcs/; revision=6032
+2002-07-23 Martin Baulig <martin@gnome.org>
+
+ * test-148.cs: New test.
+
2002-07-22 Martin Baulig <martin@gnome.org>
* verify-2.cs: New test.
verify-1.cs verify-2.cs
+* Indexers and Properties
+
+ test-148.cs
+
Test cases listed by Number:
============================
-----------
Testing `new' modifier.
+test-148.cs
+-----------
+Testing the `IndexerName' attribute in interface indexers.
+
verify-1.cs
-----------
Test whether we do not jump out of the method in a Try/Finally block.
test-111 test-112 test-113 test-114 test-115 test-116 test-117 test-118 test-119 \
test-121 test-123 test-125 test-126 test-127 test-128 test-129 test-130 \
test-131 test-134 test-135 test-136 test-137 test-138 test-139 test-140 \
- test-141 test-142 test-143 test-144 test-145 test-146 test-147
+ test-141 test-142 test-143 test-144 test-145 test-146 test-147 test-148
UNSAFE_SOURCES = \
unsafe-1 unsafe-2 unsafe-3 test-58.cs
--- /dev/null
+using System;
+using System.Runtime.CompilerServices;
+
+public interface X
+{
+ [IndexerName ("Foo")]
+ int this [int a] {
+ get;
+ }
+}
+
+public class Y : X
+{
+ int X.this [int a] {
+ get {
+ return 1;
+ }
+ }
+
+ [IndexerName ("Bar")]
+ public int this [int a] {
+ get {
+ return 2;
+ }
+ }
+
+ [IndexerName ("Bar")]
+ public long this [double a] {
+ get {
+ return 3;
+ }
+ }
+}
+
+public class Z : Y
+{
+ [IndexerName ("Whatever")]
+ new public long this [double a] {
+ get {
+ return 4;
+ }
+ }
+
+ public static int Test ()
+ {
+ Z z = new Z ();
+ X x = (X) z;
+ Y y = (Y) z;
+
+ Console.WriteLine (z [1]);
+ Console.WriteLine (y [2]);
+ Console.WriteLine (x [3]);
+
+ if (z [1] != 4)
+ return 1;
+ if (y [1] != 2)
+ return 2;
+ if (x [1] != 1)
+ return 3;
+
+ double index = 5;
+
+ Console.WriteLine (z [index]);
+ Console.WriteLine (y [index]);
+
+ if (z [index] != 4)
+ return 4;
+ if (y [index] != 3)
+ return 5;
+
+ return 0;
+ }
+
+ public static int Main ()
+ {
+ int result = Test ();
+
+ Console.WriteLine ("RESULT: " + result);
+
+ return result;
+ }
+}