Add -H command-line option to generate C header file for public API, stub
[vala-lang.git] / tests / control-flow / switch.test
blob1ee8bb7356bfae8cc716a20bf60bfb2eac1e3772
2 Program: test
4 using GLib;
6 class Maman.Bar : Object {
7         static bool test_switch_control_flow_graph () {
8                 int a = 0;
9                 switch (a) {
10                 case 1:
11                         return false;
12                 default:
13                         return true;
14                 }
15         }
17         static int main (string[] args) {
18                 stdout.printf ("For Test: 1");
20                 int i;
21                 for (i = 2; i < 7; i++) {
22                         stdout.printf (" %d", i);
23                 }
24                 
25                 stdout.printf (" 7\n");
27                 stdout.printf ("Switch statement: 1");
29                 var foo = new Foo ();
30                 foo.run ();
32                 stdout.printf (" 7\n");
34                 test_switch_control_flow_graph ();
36                 return 0;
37         }
40 class Maman.Foo : Object {
41         public void run () {
42                 stdout.printf (" 2");
43                 
44                 switch (23) {
45                 case 23:
46                         stdout.printf (" 3");
47                         break;
48                 default:
49                         stdout.printf (" BAD");
50                         break;
51                 }
52                 
53                 switch (inc ()) {
54                 case 0:
55                         stdout.printf (" 4");
56                         break;
57                 case 1:
58                         stdout.printf (" BAD");
59                         break;
60                 default:
61                         stdout.printf (" BAD");
62                         break;
63                 }
64                 
65                 switch (42) {
66                 case 0:
67                         stdout.printf (" BAD");
68                         break;
69                 default:
70                         stdout.printf (" 5");
71                         break;
72                 case 1:
73                         stdout.printf (" BAD");
74                         break;
75                 }
76                 
77                 stdout.printf (" 6");
78         }
79         
80         public int inc () {
81                 return counter++;
82         }
83         
84         private int counter = 0;