]> git.xonotic.org Git - xonotic/gmqcc.git/blob - tests/correct-logic.qc
Undo fix and actually use a macro in the accumulation test .. just incase.
[xonotic/gmqcc.git] / tests / correct-logic.qc
1 float test_s_not  (vector s)           { return !s; }
2 float test_s_and  (vector s, vector t) { return s && t; }
3 float test_s_or   (vector s, vector t) { return s || t; }
4 float test_s_if   (vector s)           { if (s) return 1; return 0; }
5 float test_s_ifnot(vector s)           { if not (s) return 1; return 0; }
6
7 void test(vector s, vector t) {
8     print(ftos(!!test_s_not  (s)), " ");
9     print(ftos(!!test_s_and  (s, t)), " ");
10     print(ftos(!!test_s_or   (s, t)), " ");
11     print(ftos(!!test_s_if   (s)), " ");
12     print(ftos(!!test_s_ifnot(s)), "\n");
13 }
14
15 void main() {
16     print("        ! & | i N\n");
17     print("0, 0 -> "); test('0 0 0', '0 0 0');
18     print("0, x -> "); test('0 0 0', '1 0 0');
19     print("x, 0 -> "); test('1 0 0', '0 0 0');
20     print("x, x -> "); test('1 0 0', '1 0 0');
21     print("0, y -> "); test('0 0 0', '0 1 0');
22     print("y, 0 -> "); test('0 1 0', '0 0 0');
23     print("y, y -> "); test('0 1 0', '0 1 0');
24 }