Merge pull request #1326 from BrzVlad/master
[mono.git] / mono / mini / objects.cs
index 3d849c64d053102816256281fcd9861c664dcda0..0e8ea1a4d7b4d2adc725597559b547ad8c2d5a78 100644 (file)
@@ -26,6 +26,11 @@ using System.Runtime.CompilerServices;
  * the IL code looks.
  */
 
+#if MOBILE
+namespace ObjectTests
+{
+#endif
+
 struct Simple {
        public int a;
        public byte b;
@@ -114,9 +119,11 @@ struct Gamma {
 
 class Tests {
 
-       static int Main () {
-               return TestDriver.RunTests (typeof (Tests));
+#if !MOBILE
+       public static int Main (string[] args) {
+               return TestDriver.RunTests (typeof (Tests), args);
        }
+#endif
        
        public static int test_0_return () {
                Simple s;
@@ -1078,7 +1085,8 @@ class Tests {
        }
        public static int test_0_cond_branch_side_effects () {
                counter = 5;
-               if (WriteStuff());
+               if (WriteStuff()) {
+               }
                if (counter == 10)
                        return 0;
                return 1;
@@ -1500,5 +1508,139 @@ ncells ) {
                return 0;
        }
 
+       public static bool flag;
+
+       class B {
+
+               internal static B[] d;
+
+               static B () {
+                       flag = true;
+               }
+       }
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       static int regress_679467_inner () {
+               if (flag == true)
+                       return 1;
+               var o = B.d;
+               var o2 = B.d;
+               return 0;
+       }
+
+       /*
+        * FIXME: This fails with AOT #703317.
+        */
+       /*
+       static int test_0_multiple_cctor_calls_regress_679467 () {
+               flag = false;
+               return regress_679467_inner ();
+       }
+       */
+
+       static int test_0_char_ctor () {
+               string s = new String (new char[] { 'A', 'B' }, 0, 1);
+               return 0;
+       }
+
+       static object mInstance = null;
+
+       [MethodImpl(MethodImplOptions.Synchronized)]
+       public static object getInstance() {
+               if (mInstance == null)
+                       mInstance = new object();
+               return mInstance;
+       }
+
+       static int test_0_synchronized () {
+               getInstance ();
+               return 0;
+       }
+
+       struct BStruct {
+               public Type t;
+       }
+
+       class Del<T> {
+               public static BStruct foo () {
+                       return new BStruct () { t = typeof (T) };
+               }
+       }
+
+       delegate BStruct ADelegate ();
+
+       static int test_0_regress_10601 () {
+               var act = (ADelegate)(Del<string>.foo);
+               BStruct b = act ();
+               if (b.t != typeof (string))
+                       return 1;
+               return 0;
+       }
+
+       static int test_0_regress_11058 () {
+               int foo = -252674008;
+               int foo2 = (int)(foo ^ 0xF0F0F0F0); // = 28888
+               var arr = new byte[foo2].Length;
+               return 0;
+       }
+
+       public static void do_throw () {
+               throw new Exception ();
+       }
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       static void empty () {
+       }
+
+       // #11297
+       public static int test_0_llvm_inline_throw () {
+               try {
+                       empty ();
+               } catch (Exception) {
+                       do_throw ();
+               }
+
+               return 0;
+       }
+
+       enum ByteEnum : byte {
+        Zero = 0
+    }
+
+    struct BugStruct {
+        public ByteEnum f1;
+        public ByteEnum f2;
+        public ByteEnum f3;
+        public byte f4;
+        public byte f5;
+        public byte f6;
+        public byte f7;
+    }
+
+       public static int test_0_14217 () {
+               t_14217_inner (new BugStruct ());
+               return 0;
+       }
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       static void t_14217_inner (BugStruct bug) {
+    }
+
+       [StructLayout(LayoutKind.Sequential)]
+       public struct EmptyStruct {
+       }
+
+       class EmptyClass {
+               public static EmptyStruct s;
+       }
+
+       // #20349
+       static int test_0_empty_struct_as_static () {
+               var s = EmptyClass.s;
+               return 0;
+       }
 }
 
+#if MOBILE
+}
+#endif