2 using System.Collections;
6 public static int Main ()
8 // This is a compilation-only test.
12 // All code paths throw an exception, no need to set out parameters.
13 public static void test1 (out float f)
15 throw new NotSupportedException ();
18 // The while loop breaks but does not return, so this is ok.
19 public static void test2 (int a, out float f)
25 Console.WriteLine (a);
31 // a has been assigned in all code paths which do not return.
32 public static void test3 (long[] b, int c)
36 throw new ArgumentException ();
40 Console.WriteLine (a);
43 // Forward goto, it's ok to set f after the target label.
44 public static int test4 (int b, out float f)
48 Console.WriteLine ("Hello World");
55 Console.WriteLine (a);
62 // try { ... } catch { ... } finally { ... } block
63 static public int test5 (out float f, long d)
75 } catch (NotSupportedException e) {
77 } catch (Exception e) {
86 // Passing out parameter to method invocation
87 static public int test6 (out float f)
89 return test5 (out f, 50);
92 // Loop-variable of foreach() and for() loop.
93 static public long test7 (int[] a, int stop)
99 for (int i = 1; i < stop; i++)
105 // Initializing locals in initialize or test of for block
106 static public long test8 (int stop)
110 for (i = 1; (b = stop) > 3; i++) {
117 // Initializing locals in test of while block
118 static public long test9 (int stop)
121 while ((b = stop) > 3) {
128 // Return in subblock
129 public static void test10 (int a, out float f)
140 public static long test11 (int a)
160 // Try block which rethrows exception.
161 public static void test12 (out float f)
166 throw new NotSupportedException ();
170 // Return in subblock.
171 public static void test13 (int a, out float f)
184 // Switch block with goto case / goto default.
185 public static long test14 (int a, out float f)
210 // Forward goto, it's ok to set f before the jump.
211 public static int test15 (int b, out float f)
215 Console.WriteLine ("Hello World");
223 Console.WriteLine (a);
228 // `continue' breaks unless we're a loop block.
229 public static void test16 ()
233 for (int i = 0; i < 5; ++i) {
246 // `continue' in a nested if.
247 public static void test17 ()
253 while (charCount > 0) {
258 throw new Exception ();
265 Console.WriteLine (value);
269 // `out' parameter assigned after conditional exception.
270 static void test18 (int a, out int f)
274 throw new Exception ();
277 } catch (IndexOutOfRangeException) {
278 throw new FormatException ();
282 // code after try/catch block is unreachable. always returns.
283 static int test19 () {
285 int a = Environment.NewLine.Length;
290 throw new NotImplementedException ();
291 } catch (NotImplementedException e) {
293 throw new NotImplementedException ();
301 static int test20 () {
311 static int test21 () {
317 } catch (DivideByZeroException) {
326 // the same, but without the finally block.
327 static int test22 () {
333 } catch (DivideByZeroException) {
340 static int test23 (object obj, int a, out bool test) {
342 throw new ArgumentNullException ();
353 static long test24 (int a) {
369 Console.WriteLine (b);
376 static long test25 (int a) {
381 } catch (NotSupportedException) {
382 throw new InvalidOperationException ();
388 throw new InvalidOperationException ();
395 // Tests that the flow analysis is preformed first in the for statement
396 // and later on the `increment' part of the for
398 static void test26 ()
401 for( int i=0; i<10; i=j )
406 // Nested infinite loops. Bug #40670.
414 Console.WriteLine ("Test");
423 static void test28 (out object value)
438 static bool test29 (out int a)
443 } catch (System.Exception) {
452 public string test30 (out string outparam)
469 public string test31 (int blah)
472 case 1: return("foo"); break;
473 case 2: return("bar"); break;
474 case 3: return("baz"); break;
477 throw new ArgumentException ("Value 0x"+blah.ToString ("x4")+" is not supported.");
484 public void test32 ()
487 System.Threading.Thread.Sleep (1);
490 Console.WriteLine ("Hello");
507 public void test34 ()
522 public static void test35 (int a, bool test)
537 public static void test36 ()
551 Console.WriteLine (myVar);
557 public static void test37 ()
567 throw new Exception ();