Merge pull request #1718 from madewokherd/sgenthreadcleanup
[mono.git] / mono / tests / pinvoke3.cs
index 4b9a4b7f49a300186eb95ef72be806e21d897bfe..29ed8ea7eee8498f00e11aaf06d54b7109a8150d 100644 (file)
@@ -191,6 +191,14 @@ public class Tests {
        [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate_ref_delegate")]
        public static extern int mono_test_marshal_delegate_ref_delegate (DelegateByrefDelegate del);
 
+       [DllImport ("libtest", EntryPoint="mono_test_marshal_virtual_delegate")]
+       public static extern int mono_test_marshal_virtual_delegate (VirtualDelegate del);
+
+       [DllImport ("libtest", EntryPoint="mono_test_marshal_icall_delegate")]
+       public static extern int mono_test_marshal_icall_delegate (IcallDelegate del);
+
+       public delegate string IcallDelegate (IntPtr p);
+
        public delegate int TestDelegate (int a, ref SimpleStruct ss, int b);
 
        public delegate SimpleStruct SimpleDelegate2 (SimpleStruct ss);
@@ -215,6 +223,8 @@ public class Tests {
 
        public delegate int DelegateByrefDelegate (ref return_int_delegate del);
 
+       public delegate int VirtualDelegate (int i);
+
        public static int Main () {
                return TestDriver.RunTests (typeof (Tests));
        }
@@ -1134,4 +1144,32 @@ public class Tests {
                        return 0;
                }
     }
+
+       class Base {
+               public VirtualDelegate get_del () {
+                       return delegate_test;
+               }
+
+               public virtual int delegate_test (int i) {
+                       return i;
+               }
+       }
+
+       class Derived : Base {
+               public override int delegate_test (int i) {
+                       return i + 1;
+               }
+       }
+
+       public static int test_43_virtual () {
+               Base b = new Derived ();
+
+               return mono_test_marshal_virtual_delegate (b.get_del ());
+       }
+
+       public static int test_0_icall_delegate () {
+               var m = typeof (Marshal).GetMethod ("PtrToStringAnsi", new Type[] { typeof (IntPtr) });
+
+               return mono_test_marshal_icall_delegate ((IcallDelegate)Delegate.CreateDelegate (typeof (IcallDelegate), m));
+       }
 }