[interp] basic filter clause support
[mono.git] / mono / mini / exceptions.cs
index 4e11a7d4157c07e17bcc9151b92114dae72c3c1d..c7b10b3a4c1517217b7c56e798bf9379bced451c 100644 (file)
@@ -981,7 +981,6 @@ class Tests
                return 0;
        }
        
-       [Category ("!INTERPRETER")]
        public static int test_0_int_cast () {
                int a;
                long l;
@@ -1463,7 +1462,6 @@ class Tests
                return 0;
        }
        
-       [Category ("!INTERPRETER")]
        [Category ("NaClDisable")]
        public static int test_0_div_zero () {
                int d = 1;
@@ -1635,7 +1633,6 @@ class Tests
                return 0;
        }
 
-       [Category ("!INTERPRETER")]
        [Category ("NaClDisable")]
        public static int test_0_long_div_zero () {
                long d = 1;
@@ -1803,7 +1800,6 @@ class Tests
                return 0;
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_3_checked_cast_un () {
                 ulong i = 0x8000000034000000;
                 long j;
@@ -1819,7 +1815,6 @@ class Tests
                return 3;
        }
        
-       [Category ("!INTERPRETER")]
        public static int test_4_checked_cast () {
                 long i;
                 ulong j;
@@ -1847,7 +1842,6 @@ 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[,];
@@ -1884,7 +1878,6 @@ class Tests
                o = "buddy";
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_2_array_mismatch () {
                string[] a = { "hello", "world" };
                object[] b = a;
@@ -2237,7 +2230,6 @@ class Tests
                }
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_0_exception_in_cctor () {
                try {
                        Broken.DoSomething ();
@@ -2389,7 +2381,6 @@ class Tests
                }
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_0_array_size () {
                bool failed;
 
@@ -2716,7 +2707,6 @@ 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;
@@ -2856,6 +2846,72 @@ class Tests
                }
                return 0;
        }
+
+       public class MyException : Exception {
+               public int marker = 0;
+               public string res = "";
+
+               public MyException (String res) {
+                       this.res = res;
+               }
+
+               public bool FilterWithoutState () {
+                       return this.marker == 0x666;
+               }
+
+               public bool FilterWithState () {
+                       bool ret = this.marker == 0x566;
+                       this.marker += 0x100;
+                       return ret;
+               }
+
+               public bool FilterWithStringState () {
+                       bool ret = this.marker == 0x777;
+                       this.res = "fromFilter_" + this.res;
+                       return ret;
+               }
+       }
+
+       public static int test_1_basic_filter_catch () {
+               try {
+                       MyException e = new MyException ("");
+                       e.marker = 0x1337;
+                       throw e;
+               } catch (MyException ex) when (ex.marker == 0x1337) {
+                       return 1;
+               }
+               return 0;
+       }
+
+       public static int test_1234_complicated_filter_catch () {
+               string res = "init";
+               try {
+                       MyException e = new MyException (res);
+                       e.marker = 0x566;
+                       try {
+                               try {
+                                       throw e;
+                               } catch (MyException ex) when (ex.FilterWithoutState ()) {
+                                       res = "WRONG_" + res;
+                               } finally {
+                                       e.marker = 0x777;
+                                       res = "innerFinally_" + res;
+                               }
+                       } catch (MyException ex) when (ex.FilterWithState ()) {
+                               res = "2ndcatch_" + res;
+                       }
+                       // "2ndcatch_innerFinally_init"
+                       // Console.WriteLine ("res1: " + res);
+                       e.res = res;
+                       throw e;
+               } catch (MyException ex) when (ex.FilterWithStringState ()) {
+                       res = "fwos_" + ex.res;
+               } finally {
+                       res = "outerFinally_" + res;
+               }
+               // Console.WriteLine ("res2: " + res);
+               return "outerFinally_fwos_fromFilter_2ndcatch_innerFinally_init" == res ? 1234 : 0;
+       }
 }
 
 #if !__MOBILE__