]> git.xonotic.org Git - xonotic/gmqcc.git/blob - tests/ternary.qc
Checking in test for nested ternaries; this is more a test of the ast than the parser
[xonotic/gmqcc.git] / tests / ternary.qc
1 void     print(...)   = #1;
2 string   ftos (float) = #2;
3
4 void test(float cond, float v1, float v2, float a) {
5         print(ftos(cond ? v1 : v2), " ");
6         print( (cond ? v1 : v2) ? ( (a == 1) ? "a=1"
7                                   : (a == 2) ? "a=2"
8                                   : "a=other"
9                                   )
10                                 : "not met",
11               "\n");
12 }
13
14 void main() {
15         test(0, -99, 1, 1);
16         test(0, -99, 1, 2);
17         test(0, -99, 1, 3);
18         test(0, -99, 0, 1);
19         test(0, -99, 0, 2);
20         test(0, -99, 0, 3);
21         test(1, 1, -99, 1);
22         test(1, 1, -99, 2);
23         test(1, 1, -99, 3);
24         test(1, 0, -99, 1);
25         test(1, 0, -99, 2);
26         test(1, 0, -99, 3);
27 }