2002-07-23 Martin Baulig <martin@gnome.org>
authorMartin Baulig <martin@novell.com>
Mon, 22 Jul 2002 22:40:42 +0000 (22:40 -0000)
committerMartin Baulig <martin@novell.com>
Mon, 22 Jul 2002 22:40:42 +0000 (22:40 -0000)
* test-148.cs: New test.

svn path=/trunk/mcs/; revision=6032

mcs/tests/ChangeLog
mcs/tests/README.tests
mcs/tests/makefile
mcs/tests/test-148.cs [new file with mode: 0644]

index bb3aea08102065e56d3ad051f578d4cf81137984..cb6e39f0b8e5487d292e1c4726d5bdac23b982dd 100755 (executable)
@@ -1,3 +1,7 @@
+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.
index 9d58f77ef9dd4b6b81a632633ab0647d3b8635db..113228c83de1660302b072ea688be8f9435d75bb 100644 (file)
@@ -13,6 +13,10 @@ Test cases listed by Category:
 
   verify-1.cs verify-2.cs
 
+* Indexers and Properties
+
+  test-148.cs
+
 Test cases listed by Number:
 ============================
 
@@ -25,6 +29,10 @@ test-147.cs
 -----------
 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.
index 9339bcc0ffab33b88bf852e411bc1de0e2d554ac..92d931d263788cb95a609d880e4fb8d19ced29df 100755 (executable)
@@ -23,7 +23,7 @@ TEST_SOURCES = \
        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
diff --git a/mcs/tests/test-148.cs b/mcs/tests/test-148.cs
new file mode 100644 (file)
index 0000000..5c29fe1
--- /dev/null
@@ -0,0 +1,82 @@
+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;
+       }
+}