File: statements-selection.vala

package info (click to toggle)
vala 0.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 13,756 kB
  • ctags: 12,353
  • sloc: ansic: 116,516; sh: 9,897; yacc: 1,218; makefile: 837; xml: 657; lex: 285
file content (83 lines) | stat: -rw-r--r-- 1,139 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using GLib;

class Maman.Bar : Object {
	static bool test_switch_control_flow_graph () {
		int a = 0;
		switch (a) {
		case 1:
			return false;
		default:
			return true;
		}
	}

	static int main (string[] args) {
		stdout.printf ("For Test: 1");

		int i;
		for (i = 2; i < 7; i++) {
			stdout.printf (" %d", i);
		}
		
		stdout.printf (" 7\n");

		stdout.printf ("Switch statement: 1");

		var foo = new Foo ();
		foo.run ();

		stdout.printf (" 7\n");

		test_switch_control_flow_graph ();

		return 0;
	}
}

class Maman.Foo : Object {
	public void run () {
		stdout.printf (" 2");
		
		switch (23) {
		case 23:
			stdout.printf (" 3");
			break;
		default:
			stdout.printf (" BAD");
			break;
		}
		
		switch (inc ()) {
		case 0:
			stdout.printf (" 4");
			break;
		case 1:
			stdout.printf (" BAD");
			break;
		default:
			stdout.printf (" BAD");
			break;
		}
		
		switch (42) {
		case 0:
			stdout.printf (" BAD");
			break;
		default:
			stdout.printf (" 5");
			break;
		case 1:
			stdout.printf (" BAD");
			break;
		}
		
		stdout.printf (" 6");
	}
	
	public int inc () {
		return counter++;
	}
	
	private int counter = 0;
}