Permalink
Browse files

Forgot to actually commit the test cases...

svn path=/trunk/mono/; revision=1279
  • Loading branch information...
illupus committed Nov 7, 2001
1 parent 533093c commit 6bc3046d5d61c25368c9b67b4067f4b8bc145c87
Showing with 76 additions and 0 deletions.
  1. +2 −0 mono/tests/Makefile.am
  2. +15 −0 mono/tests/array-init.cs
  3. +59 −0 mono/tests/field-layout.cs
View
@@ -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 \
View
@@ -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;
+ }
+ }
+}
View
@@ -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;
+
+ }
+ }
+}

0 comments on commit 6bc3046

Please sign in to comment.