]> git.xonotic.org Git - xonotic/gmqcc.git/blob - tests/short-logic.qc
Allow unary minus in ftepp_if_value
[xonotic/gmqcc.git] / tests / short-logic.qc
1 void   print(...) = #1;
2 string ftos(float) = #2;
3
4 float glob1;
5 float glob2;
6 float glob3;
7
8 float side_effect_1(float r) {
9     glob1 += 3;
10     return r;
11 }
12
13 float side_effect_2(float r) {
14     glob2 += 3;
15     return r;
16 }
17
18 float side_effect_3(float r) {
19     glob3 += 3;
20     return r;
21 }
22
23 void main() {
24     glob1 = 10;
25     glob2 = 20;
26     glob3 = 30;
27
28     if (side_effect_1(0) || side_effect_2(1))
29         print(ftos(glob1), "=13 ", ftos(glob2), "=23 OK\n");
30     else
31         print("Fail\n");
32
33     if (side_effect_3(1) || side_effect_1(1))
34         print(ftos(glob1), "=13 ", ftos(glob3), "=33 OK\n");
35     else
36         print("Fail\n");
37
38     if (side_effect_1(0) && side_effect_3(1))
39         print("Fail\n");
40     else
41         print(ftos(glob1), "=16 ", ftos(glob3), "=33 OK\n");
42
43     if (side_effect_2(1) && side_effect_3(1))
44         print(ftos(glob2), "=26 ", ftos(glob3), "=36 OK\n");
45     else
46         print("Fail\n");
47
48     print(ftos(glob1), "=16 ", ftos(glob2), "=26 ", ftos(glob3), "=36 OK\n");
49 }