]> git.xonotic.org Git - xonotic/gmqcc.git/blob - tests/truth-flags-2.qc
renaming the length operator to _length and fixing the lexing of that operator, gener...
[xonotic/gmqcc.git] / tests / truth-flags-2.qc
1 float test_s_not  (string s)           { return !s; }
2 float test_s_and  (string s, string t) { return s && t; }
3 float test_s_or   (string s, string t) { return s || t; }
4 float test_s_if   (string s)           { if (s) return 1; return 0; }
5 float test_s_ifnot(string s)           { if not (s) return 1; return 0; }
6
7 void test(string s, string 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 string nuls;
16 void main() {
17     print("                ! & | i N\n");
18     print("'str', 'str' -> "); test("FULL", "FULL");
19     print("'str', ''    -> "); test("FULL", ""    );
20     print("'str', 0     -> "); test("FULL", nuls  );
21     print("'',    'str' -> "); test("",     "FULL");
22     print("'',    ''    -> "); test("",     ""    );
23     print("'',    0     -> "); test("",     nuls  );
24     print("0,     'str' -> "); test(nuls,   "FULL");
25     print("0,     ''    -> "); test(nuls,   ""    );
26     print("0,     0     -> "); test(nuls,   nuls  );
27 }