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