]> git.xonotic.org Git - xonotic/gmqcc.git/blob - tests/ternary.qc
More ternary fixes
[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     float a, b;
16         test(0, -99, 1, 1);
17         test(0, -99, 1, 2);
18         test(0, -99, 1, 3);
19         test(0, -99, 0, 1);
20         test(0, -99, 0, 2);
21         test(0, -99, 0, 3);
22         test(1, 1, -99, 1);
23         test(1, 1, -99, 2);
24         test(1, 1, -99, 3);
25         test(1, 0, -99, 1);
26         test(1, 0, -99, 2);
27         test(1, 0, -99, 3);
28
29         b = 5;
30         a = b ? 5 : 6;
31         print(ftos(a), "\n");
32         b ? a = 9 : a = 10;
33         print(ftos(a), "\n");
34         !b ? a = 9 : a = 10;
35         print(ftos(a), "\n");
36 }