Merge pull request #5382 from kumpera/pedump_fix
[mono.git] / mono / tests / runtime-invoke.cs
index b340cd13065c4eb7a00d1940f03a36a5d728d446..23fec490693ff134df0462fe9125fc60160bbd86 100644 (file)
@@ -215,4 +215,68 @@ class Tests
                var res = typeof (Tests).GetMethod ("pack_i1").Invoke (null, new object [] { (sbyte)-0x40 });
                return (bool)res ? 0 : 1;
        }
+
+       struct Point {
+               public int x, y;
+       }
+
+       struct Foo2 {
+               public Point Location {
+                       get {
+                               return new Point () { x = 10, y = 20 };
+                       }
+               }
+       }
+
+       public static int test_0_vtype_method_vtype_ret () {
+               var f = new Foo2 ();
+               var p = (Point)typeof (Foo2).GetMethod ("get_Location").Invoke (f, null);
+               if (p.x != 10 || p.y != 20)
+                       return 1;
+               return 0;
+       }
+
+       public static int test_0_array_get_set () {
+               int[,,] arr = new int [10, 10, 10];
+               arr [0, 1, 2] = 42;
+               var gm = arr.GetType ().GetMethod ("Get");
+               int i = (int) gm.Invoke (arr, new object [] { 0, 1, 2 });
+               if (i != 42)
+                       return 1;
+               var sm = arr.GetType ().GetMethod ("Set");
+               sm.Invoke (arr, new object [] { 0, 1, 2, 33 });
+               if (arr [0, 1, 2] != 33)
+                       return 2;
+               return 0;
+       }
+
+       public static int test_0_multi_dim_array_ctor () {
+        var type1 = Type.GetType ("System.Char[,]").GetTypeInfo ();
+
+               ConstructorInfo ci = null;
+               foreach (var c in type1.DeclaredConstructors) {
+                       if (c.GetParameters ().Length == 4)
+                               ci = c;
+               }
+        var res = ci.Invoke (new object[] { 1, 5, -10, 7 });
+               var a = (Array)res;
+               if (a.GetLength (0) != 5 || a.GetLowerBound (0) != 1 || a.GetLength (1) != 7 || a.GetLowerBound (1) != -10)
+                       return 1;
+               return 0;
+       }
+
+       private static void method_invoke_no_modify_by_value_arg_helper (int dummy)
+    {
+    }
+
+    public static int test_0_method_invoke_no_modify_by_value_arg ()
+    {
+        var args = new object[] { null };
+        var method = typeof (Tests).GetMethod ("method_invoke_no_modify_by_value_arg_helper", BindingFlags.NonPublic | BindingFlags.Static);
+        method.Invoke (null, args);
+        if (args[0] == null)
+            return 0;
+        else
+            return 1;
+    }
 }