Forgot to actually commit the test cases...
authorPaolo Molaro <lupus@oddwiz.org>
Wed, 7 Nov 2001 07:42:46 +0000 (07:42 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Wed, 7 Nov 2001 07:42:46 +0000 (07:42 -0000)
svn path=/trunk/mono/; revision=1279

mono/tests/Makefile.am
mono/tests/array-init.cs [new file with mode: 0644]
mono/tests/field-layout.cs [new file with mode: 0644]

index ec2286ae3aeab23243fe83ea11e43270dbe2f5dc..1dddb7bd25d277084a212b366a49307891eac007 100644 (file)
@@ -7,6 +7,8 @@ CSC=csc
 BENCHSRC=fib.cs random.cs nested-loops.cs 
 
 TESTSRC=                       \
+       array-init.cs           \
+       field-layout.cs         \
        test-ops.cs             \
        obj.cs                  \
        switch.cs               \
diff --git a/mono/tests/array-init.cs b/mono/tests/array-init.cs
new file mode 100644 (file)
index 0000000..5ba9e3a
--- /dev/null
@@ -0,0 +1,15 @@
+using System;
+
+namespace Test {
+       public class Test {
+               private static int[] array = {0, 1, 2, 3};
+               public static int Main() {
+                       int t = 0;
+                       foreach (int i in array) {
+                               if (i != t++)
+                                       return 1;
+                       }
+                       return 0;
+               }
+       }
+}
diff --git a/mono/tests/field-layout.cs b/mono/tests/field-layout.cs
new file mode 100644 (file)
index 0000000..6e32df6
--- /dev/null
@@ -0,0 +1,59 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace Test {
+       [StructLayout ( LayoutKind.Explicit )]
+       public struct Doh {
+               [ FieldOffset(0) ] public int a;
+               [ FieldOffset(0) ] public byte a1;
+               [ FieldOffset(1) ] public byte a2;
+               [ FieldOffset(2) ] public byte a3;
+               [ FieldOffset(3) ] public byte a4;
+       }
+       [StructLayout ( LayoutKind.Explicit )]
+       public class Doh2 {
+               [ FieldOffset(0) ] public int a;
+               [ FieldOffset(0) ] public byte a1;
+               [ FieldOffset(1) ] public byte a2;
+               [ FieldOffset(2) ] public byte a3;
+               [ FieldOffset(3) ] public byte a4;
+       }
+       [StructLayout ( LayoutKind.Explicit )]
+       public class Doh3: Doh2 {
+               [ FieldOffset(0) ] public int b;
+       }
+       public class Test {
+               public static int Main() {
+                       Doh doh;
+                       Doh3 doh2 = new Doh3 ();
+                       bool success = false;
+                       // shut up the compiler
+                       doh.a1 = doh.a2 = doh.a3 = doh.a4 = 0;
+                       doh.a = 1;
+                       if (doh.a1 == 1 && doh.a2 == 0 && doh.a3 == 0 && doh.a4 == 0) {
+                               System.Console.WriteLine ("Little endian");
+                               success = true;
+                       } else if (doh.a1 == 0 && doh.a2 == 0 && doh.a3 == 0 && doh.a4 == 1) {
+                               System.Console.WriteLine ("Big endian");
+                               success = true;
+                       }
+                       if (!success)
+                               return 1;
+                       // shut up the compiler
+                       doh2.a1 = doh2.a2 = doh2.a3 = doh2.a4 = 0;
+                       doh2.a = 1;
+                       if (doh2.a1 == 1 && doh2.a2 == 0 && doh2.a3 == 0 && doh2.a4 == 0) {
+                               success = true;
+                       } else if (doh2.a1 == 0 && doh2.a2 == 0 && doh2.a3 == 0 && doh2.a4 == 1) {
+                               success = true;
+                       }
+                       doh2.b = 3;
+                       if (doh2.a != 3)
+                               success = false;
+                       if (!success)
+                               return 1;
+                       return 0;
+
+               }
+       }
+}