[2019-12] [threads] Add back mono_threads_attach_tools_thread as a public API (#18074)
[mono-project.git] / mono / tests / exception4.cs
blob4ac6173091e92495bfa79498d8af4eeb1e2c50c7
1 using System;
3 public class MyEx : Exception {
4 public MyEx () {}
7 public class Ex {
9 public static int test (int a) {
10 int res;
11 int fin = 0;
12 try {
13 res = 10/a;
14 throw new MyEx ();
15 } catch (Exception ex) {
16 ex = new MyEx ();
17 throw;
18 } finally {
19 fin = 1;
21 return res;
23 public static int Main () {
24 int catched = 0;
25 try {
26 test (1);
27 } catch (MyEx ex) {
28 catched = 1;
30 if (catched != 1)
31 return 2;
32 try {
33 test (0);
34 } catch (MyEx ex) {
35 catched = 2;
36 } catch {
37 // we should get here because rethrow rethrows the dividebyzero ex
38 // not the exception assigned to the local var (a MyEx)
39 catched = 3;
41 if (catched != 3)
42 return 3;
43 return 0;