Updated with review feedback.
[mono.git] / mcs / tests / test-876.cs
1 using System;
2
3 class T
4 {
5         public static int Main ()
6         {
7                 Test1 ();
8                 Test2 ();
9                 Test3 (0, 1);
10                 Test4 ();
11                 Test5 ();
12                 
13                 switch (1) {
14                 case 1:
15                         return 0;
16                 default:
17                         break;
18                 }
19         }
20
21         static void Test1 ()
22         {
23                 int g = 9;
24         A:
25                 switch (g) {
26                 case 4:
27                         return;
28                 case 5:
29                         goto A;
30                 }
31
32                 switch (g) {
33                 case 9:
34                         break;
35                 }
36
37                 return;
38         }
39         
40         static void Test2 ()
41         {
42                 int a,b;
43                 int g = 9;
44                 if (g > 0) {
45                         a = 1;
46                         goto X;
47                 } else {
48                         b = 2;
49                         goto Y;
50                 }
51
52         X:
53                 Console.WriteLine (a);
54                 return;
55         Y:
56                 Console.WriteLine (b);
57                 return;
58         }
59         
60         static uint Test3 (int self, uint data)
61         {
62                 uint rid;
63                 switch (self) {
64                 case 0:
65                         rid = 2;
66                         switch (data & 3) {
67                         case 0:
68                                 goto ret;
69                         default:
70                                 goto exit;
71                         }
72                 default:
73                         goto exit;
74                 }
75         ret:
76                 return rid;
77         exit:
78                 return 0;
79         }
80
81         static void Test4 ()
82         {
83                 bool v;
84                 try {
85                         throw new NotImplementedException ();
86                 } catch (System.Exception) {
87                         v = false;
88                 }
89                 
90                 Console.WriteLine (v);
91         }
92
93         static void Test5 ()
94         {
95                 int i = 8;
96                 switch (10) {
97                 case 5:
98                         if (i != 10)
99                                 throw new ApplicationException ();
100                         
101                         Console.WriteLine (5);
102                         break;
103                 case 10:
104                         i = 10;
105                         Console.WriteLine (10);
106                         goto default;
107                 default:
108                         Console.WriteLine ("default");
109                         goto case 5;
110                 }
111         }
112 }