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