]> git.xonotic.org Git - xonotic/gmqcc.git/blob - tests/truth-flags-2.qc
enum testcase
[xonotic/gmqcc.git] / tests / truth-flags-2.qc
1 void   print(...)   = #1;
2 string ftos (float) = #2;
3
4 float test_s_not  (string s)           { return !s; }
5 float test_s_and  (string s, string t) { return s && t; }
6 float test_s_or   (string s, string t) { return s || t; }
7 float test_s_if   (string s)           { if (s) return 1; return 0; }
8 float test_s_ifnot(string s)           { if not (s) return 1; return 0; }
9
10 void test(string s, string t) {
11     print(ftos(!!test_s_not  (s)), " ");
12     print(ftos(!!test_s_and  (s, t)), " ");
13     print(ftos(!!test_s_or   (s, t)), " ");
14     print(ftos(!!test_s_if   (s)), " ");
15     print(ftos(!!test_s_ifnot(s)), "\n");
16 }
17
18 string nuls;
19 void main() {
20     print("                ! & | i N\n");
21     print("'str', 'str' -> "); test("FULL", "FULL");
22     print("'str', ''    -> "); test("FULL", ""    );
23     print("'str', 0     -> "); test("FULL", nuls  );
24     print("'',    'str' -> "); test("",     "FULL");
25     print("'',    ''    -> "); test("",     ""    );
26     print("'',    0     -> "); test("",     nuls  );
27     print("0,     'str' -> "); test(nuls,   "FULL");
28     print("0,     ''    -> "); test(nuls,   ""    );
29     print("0,     0     -> "); test(nuls,   nuls  );
30 }