Add a test.
[mono.git] / mono / tests / dtest-app.cs
index 96c2e5f00f303ff867954d14ce2039929c264272..fe6e4529495f9faea9b3dfa48bd0afcd64ee851b 100644 (file)
@@ -51,6 +51,7 @@ public struct AStruct {
        public int i;
        public string s;
        public byte k;
+       public IntPtr j;
 
        [MethodImplAttribute (MethodImplOptions.NoInlining)]
        public int foo (int val) {
@@ -66,6 +67,16 @@ public struct AStruct {
        public int invoke_return_int () {
                return i;
        }
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       public static int invoke_static () {
+               return 5;
+       }
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       public IntPtr invoke_return_intptr () {
+               return j;
+       }
 }
 
 public class GClass<T> {
@@ -79,6 +90,13 @@ public class GClass<T> {
 
 public struct GStruct<T> {
        public T i;
+
+       public int j;
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       public int invoke_return_int () {
+               return j;
+       }
 }
 
 public class Tests : TestsBase
@@ -98,6 +116,7 @@ public class Tests : TestsBase
        float field_float;
        double field_double;
        Thread field_class;
+       IntPtr field_intptr;
        static int static_i = 55;
        static string static_s = "A";
        public const int literal_i = 56;
@@ -217,8 +236,13 @@ public class Tests : TestsBase
                ss1 ();
                ss2 ();
                ss3 ();
+               ss3_2 ();
                ss4 ();
                ss5 (new int [] { 1, 2, 3 }, new Func<int, bool> (is_even));
+               try {
+                       ss6 (true);
+               } catch {
+               }
        }
 
        [MethodImplAttribute (MethodImplOptions.NoInlining)]
@@ -239,6 +263,15 @@ public class Tests : TestsBase
                return sum;
        }
 
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       public static void ss3_2 () {
+               ss3_2_2 ();
+       }
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       public static void ss3_2_2 () {
+       }
+
        [MethodImplAttribute (MethodImplOptions.NoInlining)]
        public static int ss4 () {
                ss1 (); ss1 ();
@@ -252,6 +285,18 @@ public class Tests : TestsBase
                arr.Count (selector);
        }
 
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       public static void ss6 (bool b) {
+               if (b) {
+                       ss7 ();
+                       throw new Exception ();
+               }
+       }
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       public static void ss7 () {
+       }
+
        [MethodImplAttribute (MethodImplOptions.NoInlining)]
        public static bool is_even (int i) {
                return i % 2 == 0;
@@ -291,7 +336,7 @@ public class Tests : TestsBase
 
        [MethodImplAttribute (MethodImplOptions.NoInlining)]
        public static void objects () {
-               Tests t = new Tests () { field_i = 42, field_bool1 = true, field_bool2 = false, field_char = 'A', field_byte = 129, field_sbyte = -33, field_short = Int16.MaxValue - 5, field_ushort = UInt16.MaxValue - 5, field_long = Int64.MaxValue - 5, field_ulong = UInt64.MaxValue - 5, field_float = 3.14f, field_double = 3.14f, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B, field_class = null };
+               Tests t = new Tests () { field_i = 42, field_bool1 = true, field_bool2 = false, field_char = 'A', field_byte = 129, field_sbyte = -33, field_short = Int16.MaxValue - 5, field_ushort = UInt16.MaxValue - 5, field_long = Int64.MaxValue - 5, field_ulong = UInt64.MaxValue - 5, field_float = 3.14f, field_double = 3.14f, field_s = "S", base_field_i = 43, base_field_s = "T", field_enum = AnEnum.B, field_class = null, field_intptr = new IntPtr (Int32.MaxValue - 5) };
                t.o1 (new Tests2 () { field_j = 43 }, new GClass <int> { field = 42 }, new GClass <string> { field = "FOO" });
                o2 (new string [] { "BAR", "BAZ" }, new int[] { 42, 43 }, new int [,] { { 1, 2 }, { 3, 4 }}, (int[,])Array.CreateInstance (typeof (int), new int [] { 2, 2}, new int [] { 1, 3}), new int[] { 0 });
        }
@@ -409,7 +454,7 @@ public class Tests : TestsBase
                unsafe {
                        AStruct s = new AStruct () { i = 42, s = "S", k = 43 };
 
-                       ti2 (new string [] { "BAR", "BAZ" }, new int[] { 42, 43 }, new int [,] { { 1, 2 }, { 3, 4 }}, ref val, (int*)IntPtr.Zero, 5, s, new Tests (), new Tests2 (), new GClass <int> ());
+                       ti2 (new string [] { "BAR", "BAZ" }, new int[] { 42, 43 }, new int [,] { { 1, 2 }, { 3, 4 }}, ref val, (int*)IntPtr.Zero, 5, s, new Tests (), new Tests2 (), new GClass <int> (), AnEnum.B);
                }
        }
 
@@ -422,7 +467,7 @@ public class Tests : TestsBase
        }
 
        [MethodImplAttribute (MethodImplOptions.NoInlining)]
-       public static unsafe string ti2 (string[] s2, int[] s3, int[,] s4, ref int ri, int* ptr, int i, AStruct s, Tests t, Tests2 t2, GClass<int> g) {
+       public static unsafe string ti2 (string[] s2, int[] s3, int[,] s4, ref int ri, int* ptr, int i, AStruct s, Tests t, Tests2 t2, GClass<int> g, AnEnum ae) {
                return s2 [0] + s3 [0] + s4 [0, 0];
        }
 
@@ -439,11 +484,11 @@ public class Tests : TestsBase
 
        [MethodImplAttribute (MethodImplOptions.NoInlining)]
        public static void invoke () {
-               new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42 });
+               new Tests ().invoke1 (new Tests2 (), new AStruct () { i = 42, j = (IntPtr)43 }, new GStruct<int> { j = 42 });
        }
 
        [MethodImplAttribute (MethodImplOptions.NoInlining)]
-       public void invoke1 (Tests2 t, AStruct s) {
+       public void invoke1 (Tests2 t, AStruct s, GStruct<int> g) {
                invoke2 ();
        }
 
@@ -533,6 +578,10 @@ public class Tests : TestsBase
                        throw new ArgumentException ();
                } catch (Exception) {
                }
+               try {
+                       throw new OverflowException ();
+               } catch (Exception) {
+               }
 
                object o = null;
                try {