2009-12-09 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Wed, 9 Dec 2009 13:33:09 +0000 (13:33 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 9 Dec 2009 13:33:09 +0000 (13:33 -0000)
* MethodBaseTest.cs: Remove all NET_2_0 directives. Add test
for GetCurrentMethod and generics.

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

mcs/class/corlib/Test/System.Reflection/ChangeLog
mcs/class/corlib/Test/System.Reflection/MethodBaseTest.cs

index 3daba96d9eb776226ec9995fdaa013fc52983a2b..451792c66930ef0797ba79dd3a0c006489324aea 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-09 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * MethodBaseTest.cs: Remove all NET_2_0 directives. Add test
+       for GetCurrentMethod and generics.
+
 2009-12-08 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * MethodInfoTest.cs: Add some tests for MS compatible behavior of
index 2991c4ad6de9f015554f67d9686eaeec63b821c8..67c4d1e91ab69a55ac3a9b6f987fea966335abbb 100644 (file)
@@ -33,7 +33,6 @@ using NUnit.Framework;
 
 namespace MonoTests.System.Reflection
 {
-#if NET_2_0
        public class Generic<T> {
                public void Foo () {
                }
@@ -53,12 +52,37 @@ namespace MonoTests.System.Reflection
 
                }
        }
-#endif
+
 
        [TestFixture]
        public class MethodBaseTest
        {
-#if NET_2_0
+               public static MethodInfo Where<T> (T a) {
+                       return (MethodInfo) MethodBase.GetCurrentMethod ();
+               }
+
+               public class Foo<K>
+               {
+                       public static MethodInfo Where<T> (T a, K b) {
+                               return (MethodInfo) MethodBase.GetCurrentMethod ();
+                       }
+               }
+
+               [Test]
+               public void GetCurrentMethodDropsAllGenericArguments ()
+               {
+                       MethodInfo a = Where<int> (10);
+                       MethodInfo b = Foo<int>.Where <double> (10, 10);
+
+                       Assert.IsTrue (a.IsGenericMethodDefinition, "#1");
+                       Assert.IsTrue (b.IsGenericMethodDefinition, "#2");
+
+                       Assert.IsTrue (b.DeclaringType.IsGenericTypeDefinition, "#3");
+
+                       Assert.AreSame (a, typeof (MethodBaseTest).GetMethod ("Where"), "#4");
+                       Assert.AreSame (b, typeof (Foo<>).GetMethod ("Where"), "#5");
+               }
+
                [Test] // GetMethodFromHandle (RuntimeMethodHandle)
                public void GetMethodFromHandle1_Handle_Generic ()
                {
@@ -79,7 +103,6 @@ namespace MonoTests.System.Reflection
                                // GetMethodFromHandle
                        }
                }
-#endif
 
                [Test] // GetMethodFromHandle (RuntimeMethodHandle)
                public void GetMethodFromHandle1_Handle_Zero ()
@@ -112,7 +135,6 @@ namespace MonoTests.System.Reflection
                        Assert.AreEqual (0, parameters.Length, "#5");
                }
 
-#if NET_2_0
                [Test]
                public void GetMethodFromHandle_NonGenericType_DeclaringTypeZero ()
                {
@@ -304,7 +326,5 @@ namespace MonoTests.System.Reflection
                        } catch (ArgumentException) {
                        }
                }
-
-#endif
        }
 }