Added tests for passing structures as arguments to calls.
authorMark Mason <glowingpurple@gmail.com>
Mon, 20 Nov 2006 23:38:11 +0000 (23:38 -0000)
committerMark Mason <glowingpurple@gmail.com>
Mon, 20 Nov 2006 23:38:11 +0000 (23:38 -0000)
Changes contributed under the MIT/X11 license.

svn path=/trunk/mono/; revision=68227

mono/mini/ChangeLog
mono/mini/basic-calls.cs

index 4c99c20753d5111d86b3af1156bbdc373a6142d9..8bae1df95089022190323152d1126c3a66b9bc5a 100644 (file)
@@ -1,3 +1,7 @@
+2006-11-20  Mark Mason  <mason@broadcom.com>
+
+       * basic-calls.cs: added tests for passing structures as arguments
+       to calls.
 
 Mon Nov 20 19:40:11 CET 2006 Paolo Molaro <lupus@ximian.com>
 
index 276f4b9cd8c65133bbeb5e92e46806685292fd9b..863b6eb0274bcf95bf9eb4b91bd3809724099327 100644 (file)
@@ -265,6 +265,54 @@ class Tests {
                return 0;
        }
 
+       struct struct1 {
+               public int      a;
+               public int      b;
+       };
+
+       static int check_struct1(struct1 x) {
+               if (x.a != 1)
+                       return 1;
+               if (x.b != 2)
+                       return 2;
+               return 0;
+       }
+
+       static int pass_struct1(int a, int b, struct1 x) {
+               if (a != 3)
+                       return 3;
+               if (b != 4)
+                       return 4;
+               return check_struct1(x);
+       }
+
+       static int pass_struct1(int a, struct1 x) {
+               if (a != 3)
+                       return 3;
+               return check_struct1(x);
+       }
+
+       static int pass_struct1(struct1 x) {
+               return check_struct1(x);
+       }
+
+       static int test_0_struct1_args () {
+               int r;
+               struct1 x;
+
+               x.a = 1;
+               x.b = 2;
+               if ((r = check_struct1(x)) != 0)
+                       return r;
+               if ((r = pass_struct1(x)) != 0)
+                       return r + 10;
+               if ((r = pass_struct1(3, x)) != 0)
+                       return r + 20;
+               if ((r = pass_struct1(3, 4, x)) != 0)
+                       return r + 30;
+               return 0;
+       }
+
        static void doit (double value, out long m) {
                m = (long) value;
        }