[interp] throw overflow exception on long to ulong cast where long is negative
[mono.git] / mono / mini / exceptions.cs
index e06be608cf5366c5d5b5a710a7c4c45e042c9098..cf1fbb9ec1ce80955cdb54121f5ec3ff130581b6 100644 (file)
@@ -24,14 +24,14 @@ using System.Runtime.CompilerServices;
  * the IL code looks.
  */
 
-#if MOBILE
+#if __MOBILE__
 class ExceptionTests
 #else
 class Tests
 #endif
 {
 
-#if !MOBILE
+#if !__MOBILE__
        public static int Main (string[] args) {
                return TestDriver.RunTests (typeof (Tests), args);
        }
@@ -1842,6 +1842,7 @@ class Tests
                7, 0, 7, 1, 7, 2, 7, 3, 7, 4, 7, 5, 7, 6, 7, 7, 7, 8,
        };
 
+       [Category ("!INTERPRETER")]
        public static int test_0_multi_dim_array_access () {
                int [,] a = System.Array.CreateInstance (typeof (int),
                        new int [] {3,6}, new int [] {2,2 }) as int[,];
@@ -1878,6 +1879,7 @@ class Tests
                o = "buddy";
        }
 
+       [Category ("!INTERPRETER")]
        public static int test_2_array_mismatch () {
                string[] a = { "hello", "world" };
                object[] b = a;
@@ -2230,6 +2232,7 @@ class Tests
                }
        }
 
+       [Category ("!INTERPRETER")]
        public static int test_0_exception_in_cctor () {
                try {
                        Broken.DoSomething ();
@@ -2318,6 +2321,8 @@ class Tests
                Console.WriteLine ();
        }
 
+       [Category ("!INTERPRETER")]
+       [Category ("!BITCODE")]
        public static int test_0_rethrow_stacktrace () {
                // Check that rethrowing an exception preserves the original stack trace
                try {
@@ -2379,6 +2384,7 @@ class Tests
                }
        }
 
+       [Category ("!INTERPRETER")]
        public static int test_0_array_size () {
                bool failed;
 
@@ -2589,7 +2595,7 @@ class Tests
        public static int test_0_lmf_filter () {
                try {
                        // The invoke calls a runtime-invoke wrapper which has a filter clause
-#if MOBILE
+#if __MOBILE__
                        typeof (ExceptionTests).GetMethod ("lmf_filter").Invoke (null, new object [] { });
 #else
                        typeof (Tests).GetMethod ("lmf_filter").Invoke (null, new object [] { });
@@ -2705,6 +2711,7 @@ class Tests
                public static Foo* pFoo;
        }
 
+       [Category ("!INTERPRETER")]
        /* MS.NET doesn't seem to throw in this case */
        public unsafe static int test_0_ldflda_null_pointer () {
                int* pi = &Foo.pFoo->i;
@@ -2795,10 +2802,59 @@ class Tests
                }
                return 1;
        }
+
+       static bool finally_called = false;
+
+       static void regress_30472 (int a, int b) {
+                       checked {
+                               try {
+                                       int sum = a + b;
+                               } finally {
+                                       finally_called = true;
+                               }
+            }
+               }
+
+       public static int test_0_regress_30472 () {
+               finally_called = false;
+               try {
+                   regress_30472 (Int32.MaxValue - 1, 2);
+               } catch (Exception ex) {
+               }
+               return finally_called ? 0 : 1;
+       }
+
+       static int array_len_1 = 1;
+
+       public static int test_0_bounds_check_negative_constant () {
+               try {
+                       byte[] arr = new byte [array_len_1];
+                       byte b = arr [-1];
+                       return 1;
+               } catch {
+               }
+               try {
+                       byte[] arr = new byte [array_len_1];
+                       arr [-1] = 1;
+                       return 2;
+               } catch {
+               }
+               return 0;
+       }
+
+       public static int test_0_string_bounds_check_negative_constant () {
+               try {
+                       string s = "A";
+                       char c = s [-1];
+                       return 1;
+               } catch {
+               }
+               return 0;
+       }
 }
 
-#if !MOBILE
+#if !__MOBILE__
 class ExceptionTests : Tests
 {
 }
-#endif
\ No newline at end of file
+#endif