libgda-4.0, gedit-2.20: Fix gedit typo and GdaXaTransactionId.data
[vala-lang.git] / tests / control-flow / switch.vala
blob9ea363fd1b586685ed42a43c8fdec20bba52687e
1 using GLib;
3 class Maman.Bar : Object {
4 static bool test_switch_control_flow_graph () {
5 int a = 0;
6 switch (a) {
7 case 1:
8 return false;
9 default:
10 return true;
14 public static int main () {
15 stdout.printf ("For Test: 1");
17 int i;
18 for (i = 2; i < 7; i++) {
19 stdout.printf (" %d", i);
22 stdout.printf (" 7\n");
24 stdout.printf ("Switch statement: 1");
26 var foo = new Foo ();
27 foo.run ();
29 stdout.printf (" 7\n");
31 test_switch_control_flow_graph ();
33 return 0;
37 class Maman.Foo : Object {
38 public void run () {
39 stdout.printf (" 2");
41 switch (23) {
42 case 23:
43 stdout.printf (" 3");
44 break;
45 default:
46 stdout.printf (" BAD");
47 break;
50 switch (inc ()) {
51 case 0:
52 stdout.printf (" 4");
53 break;
54 case 1:
55 stdout.printf (" BAD");
56 break;
57 default:
58 stdout.printf (" BAD");
59 break;
62 switch (42) {
63 case 0:
64 stdout.printf (" BAD");
65 break;
66 default:
67 stdout.printf (" 5");
68 break;
69 case 1:
70 stdout.printf (" BAD");
71 break;
74 stdout.printf (" 6");
77 public int inc () {
78 return counter++;
81 private int counter = 0;
85 void main () {
86 Maman.Bar.main ();