]> git.xonotic.org Git - xonotic/gmqcc.git/blob - tests/switch.qc
add .gitignore file
[xonotic/gmqcc.git] / tests / switch.qc
1 void print(...) = #1;
2 string ftos(float) = #2;
3
4 void test(float param, float p2) {
5     float i;
6     float c80 = 80;
7     switch(param) {
8         case 3: print("Three, falling through to 2 - ");
9         case 2: print("Two\n"); break;
10         case 1: print("One\n"); break;
11         case 4: print("Four, falling through to default - ");
12         default: print("Other\n"); break;
13
14         case c80:
15             print("Enhanced 80\n");
16             break;
17
18         case 99:
19             if (p2 > 5) {
20                 print("early break\n");
21                 break;
22             }
23             for (i = 0; i < 5; i += 1)
24                 print(ftos(i), " ");
25             print(ftos(i), "\n");
26     }
27 }
28
29 void main() {
30     test(1,  0);
31     test(2,  0);
32     test(3,  0);
33     test(4,  0);
34     test(5,  0);
35     test(80, 0);
36     test(99, 0);
37     test(99, 6);
38 }