2010-02-05 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Fri, 5 Feb 2010 20:21:51 +0000 (20:21 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Fri, 5 Feb 2010 20:21:51 +0000 (20:21 -0000)
*  MethodInfoTest.cs: New test for GetParameters() returning the
*  interned array.

* PropertyInfoTest.cs: New tests for GetIndexParameters().

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

mcs/class/corlib/Test/System.Reflection/ChangeLog
mcs/class/corlib/Test/System.Reflection/MethodInfoTest.cs
mcs/class/corlib/Test/System.Reflection/PropertyInfoTest.cs

index 5bc866dd836e658d295d405686bc1b1bcc9b4e53..b8de983c9d2b9a05e06119cdf35893bb71172992 100644 (file)
@@ -1,3 +1,9 @@
+2010-02-05 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       *  MethodInfoTest.cs: New test for GetParameters() returning the interned array.
+
+       * PropertyInfoTest.cs: New tests for GetIndexParameters().
+
 2010-01-19 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * MethodInfoTest.cs: Add a test for Invoke with generic variant
index bce57696759a8d0b52c45beb75ad3608cb3ab7a8..6f471e5d342b41416cebadfe64100d068ebb60c2 100644 (file)
@@ -670,6 +670,19 @@ namespace MonoTests.System.Reflection
                        Assert.AreSame (mi2, mi4.GetGenericMethodDefinition (), "#C3");
                }
 
+               public void TestMethod123(int a, int b) {}
+
+               [Test]
+               public void GetParametersDontReturnInternedArray ()
+               {
+                       var method = typeof (MethodInfoTest).GetMethod ("TestMethod123");
+                       var parms = method.GetParameters ();
+                       Assert.AreNotSame (parms, method.GetParameters (), "#1");
+
+                       parms [0] = null;
+                       Assert.IsNotNull (method.GetParameters () [0], "#2");
+               }
+
                [Test]
                public void Bug354757 ()
                {
index 7238321267d375d023c20675ca0c2ef46dab57cf..70143d7b016b42f873895d72db218d7a740476fd 100644 (file)
@@ -247,6 +247,54 @@ namespace MonoTests.System.Reflection
                        }
                }
 
+               static void RunTest (Type t, bool use_getter) {
+                       var p = t.GetProperty ("Item");
+                       var idx = p.GetIndexParameters ();
+                       var m_args = t.GetMethod (use_getter ? "get_Item" : "set_Item").GetParameters ();
+
+                       Assert.AreEqual (2, idx.Length, "#1");
+
+                       Assert.AreEqual (typeof (double), idx [0].ParameterType, "#2");
+                       Assert.AreEqual (p, idx [0].Member, "#3");
+                       Assert.AreEqual ("a", idx [0].Name, "#4");
+                       Assert.AreEqual (0, idx [0].Position, "#5");
+                       Assert.AreEqual (m_args [0].MetadataToken, idx [0].MetadataToken, "#6");
+                       Assert.AreEqual (ParameterAttributes.None, idx [0].Attributes, "#7");
+
+                       Assert.AreEqual (typeof (string), idx [1].ParameterType, "#8");
+                       Assert.AreEqual (p, idx [1].Member, "#9");
+                       Assert.AreEqual ("b", idx [1].Name, "#10");
+                       Assert.AreEqual (1, idx [1].Position, "#11");
+                       Assert.AreEqual (m_args [1].MetadataToken, idx [1].MetadataToken, "#12");
+                       Assert.AreEqual (ParameterAttributes.None, idx [1].Attributes, "#13");
+
+                       var idx2 = p.GetIndexParameters ();
+
+                       //No interning exposed
+                       Assert.AreNotSame (idx, idx2, "#14");
+                       Assert.AreNotSame (idx [0], idx2 [1], "#15");
+               }
+
+               [Test]
+               public void GetIndexerReturnsObjectsBoundToTheProperty ()
+               {
+
+               }
+
+               public class TestA {
+                       public int this[double a, string b] {
+                               set {}
+                       }
+               }
+
+               public class TestB {
+                       public int this[double a, string b] {
+                               get { return 1; }
+                               set {}
+                       }
+               }
+
+
 #if NET_2_0
                public class A<T>
                {
@@ -285,6 +333,7 @@ namespace MonoTests.System.Reflection
                }
 #endif
 
+
                static bool HasAttribute (object [] attrs, Type attributeType)
                {
                        foreach (object attr in attrs)