X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Ftests%2Ftest-19.cs;h=f63dff5295805505f56bb0939eae68308119929d;hb=3e622175b40b11d2e29295e209b6c7788377eb0b;hp=c9a5d63c7976bea33e23642b49b2f372ee29667d;hpb=eb41a60d0e0445f72ad68370b7b5216141ac45b3;p=mono.git diff --git a/mcs/tests/test-19.cs b/mcs/tests/test-19.cs index c9a5d63c797..f63dff52958 100755 --- a/mcs/tests/test-19.cs +++ b/mcs/tests/test-19.cs @@ -1,5 +1,6 @@ using System; using System.Threading; +using System.Reflection; class I { @@ -40,14 +41,20 @@ class X { Console.WriteLine ("Answer is : " + result); } + static bool MyFilter (MemberInfo mi, object criteria) + { + Console.WriteLine ("You passed in : " + criteria); + return true; + } public static int Main () { I.GetTextFn _ = I.GetText; - X t = new X (); + Console.WriteLine ("Value: " + I.GetText); + X x = new X (); - Thread thr = new Thread (new ThreadStart (t.Thread_func)); + Thread thr = new Thread (new ThreadStart (x.Thread_func)); thr.Start (); Console.WriteLine ("Inside main "); @@ -55,10 +62,53 @@ class X { Console.WriteLine (_("Hello")); - t.Bar (); + x.Bar (); + + MemberFilter filter = new MemberFilter (MyFilter); + + Type t = x.GetType (); + + MemberInfo [] mi = t.FindMembers (MemberTypes.Method, BindingFlags.Static | BindingFlags.NonPublic, + Type.FilterName, "MyFilter"); + + Console.WriteLine ("FindMembers called, mi = " + mi); + Console.WriteLine (" Count: " + mi.Length); + if (!filter (mi [0], "MyFilter")) + return 1; + + // + // This test is used to call into a delegate defined in a separate + // namespace, but which is still not a nested delegate inside a class + // + NameSpace.TestDelegate td = new NameSpace.TestDelegate (multiply_by_three); + + if (td (8) != 24) + return 30; + + // + // Check the names that were used to define the delegates + // + if (td.GetType ().FullName != "NameSpace.TestDelegate") + return 31; + if (_.GetType ().FullName != "I+GetTextFn") + return 32; + Console.WriteLine ("Test passes"); return 0; } + + static int multiply_by_three (int v) + { + return v * 3; + } + } + +namespace NameSpace { + + public delegate int TestDelegate (int a); + +} +