} finally {
fin = 1;
}
- return res;
+ return fin;
}
// from bug #30487.
- static int foo() {
+ static int test20 () {
try {
return 0;
}
throw;
}
}
+
+ // from bug #31546
+ static int test21 () {
+ int res;
+
+ try {
+ res = 4;
+ return 3;
+ } catch (DivideByZeroException) {
+ res = 33;
+ } finally {
+ // Do nothing
+ }
+
+ return res;
+ }
+
+ // the same, but without the finally block.
+ static int test22 () {
+ int res;
+
+ try {
+ res = 4;
+ return 3;
+ } catch (DivideByZeroException) {
+ res = 33;
+ }
+
+ return res;
+ }
+
+ static int test23 (object obj, int a, out bool test) {
+ if (obj == null)
+ throw new ArgumentNullException ();
+
+ if (a == 5) {
+ test = false;
+ return 4;
+ } else {
+ test = true;
+ return 5;
+ }
+ }
+
+ static long test24 (int a) {
+ long b;
+
+ switch (a) {
+ case 0:
+ return 4;
+ }
+
+ if (a > 2) {
+ if (a == 5)
+ b = 4;
+ else if (a == 6)
+ b = 5;
+ else
+ return 7;
+
+ Console.WriteLine (b);
+ return b;
+ }
+
+ return 4;
+ }
+
+ static long test25 (int a) {
+ long b, c;
+
+ try {
+ b = 5;
+ } catch (NotSupportedException) {
+ throw new InvalidOperationException ();
+ }
+
+ try {
+ c = 5;
+ } catch {
+ throw new InvalidOperationException ();
+ }
+
+ return b + c;
+ }
+
+ //
+ // Tests that the flow analysis is preformed first in the for statement
+ // and later on the `increment' part of the for
+ //
+ static void test26 ()
+ {
+ int j;
+ for( int i=0; i<10; i=j )
+ j = i+1;
+ }
+
+ //
+ // Nested infinite loops. Bug #40670.
+ //
+ static int test27 ()
+ {
+ while (true) {
+ break;
+
+ while (true)
+ Console.WriteLine ("Test");
+ }
+
+ return 0;
+ }
+
+ //
+ // Bug #41657.
+ //
+ static void test28 (out object value)
+ {
+ if (true) {
+ try {
+ value = null;
+ return;
+ } catch {
+ }
+ }
+ value = null;
+ }
+
+ //
+ // Bug #47095
+ //
+ static bool test29 (out int a)
+ {
+ try {
+ a = 0;
+ return true;
+ } catch (System.Exception) {
+ a = -1;
+ return false;
+ }
+ }
+
+ //
+ // Bug #46949
+ //
+ public string test30 (out string outparam)
+ {
+ try {
+ if (true) {
+ outparam = "";
+ return "";
+ }
+ } catch {
+ }
+
+ outparam = null;
+ return null;
+ }
+
+ //
+ // Bug #49153
+ //
+ public string test31 (int blah)
+ {
+ switch(blah) {
+ case 1: return("foo"); break;
+ case 2: return("bar"); break;
+ case 3: return("baz"); break;
+
+ default:
+ throw new ArgumentException ("Value 0x"+blah.ToString ("x4")+" is not supported.");
+ }
+ }
+
+ //
+ // Bug #49359
+ //
+ public void test32 ()
+ {
+ while (true) {
+ System.Threading.Thread.Sleep (1);
+ }
+
+ Console.WriteLine ("Hello");
+ }
+
+ //
+ // Bug 49602
+ //
+ public int test33 ()
+ {
+ int i = 0;
+ return 0;
+ if (i == 0)
+ return 0;
+ }
+
+ //
+ // Bug 48962
+ //
+ public void test34 ()
+ {
+ int y, x = 3;
+ if (x > 3) {
+ y = 3;
+ goto end;
+ }
+ return;
+ end:
+ x = y;
+ }
+
+ //
+ // Bug 46640
+ //
+ public static void test35 (int a, bool test)
+ {
+ switch (a) {
+ case 3:
+ if (test)
+ break;
+ return;
+ default:
+ return;
+ }
+ }
+
+ //
+ // Bug 52625
+ //
+ public static void test36 ()
+ {
+ string myVar;
+ int counter = 0;
+
+ while (true)
+ {
+ if (counter < 3)
+ counter++;
+ else {
+ myVar = "assigned";
+ break;
+ }
+ }
+ Console.WriteLine (myVar);
+ }
+
+ //
+ // Bug 58322
+ //
+ public static void test37 ()
+ {
+ int x = 0;
+ int y = 0;
+ switch (x) {
+ case 0:
+ switch (y) {
+ case 0:
+ goto k_0;
+ default:
+ throw new Exception ();
+ }
+ }
+
+ k_0:
+ ;
+ }
+
+ //
+ // Bug 59429
+ //
+ public static int test38 ()
+ {
+ return 0;
+ foo:
+ ;
+ }
+
+ static int test40 (int stop)
+ {
+ int service;
+
+ int pos = 0;
+ do {
+ service = 1;
+ break;
+ } while (pos < stop);
+
+ return service;
+ }
}