mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-31 03:50:36 +00:00
Adding truth-flags testsuite for strings
This commit is contained in:
parent
1f070b740f
commit
d858237010
7 changed files with 114 additions and 0 deletions
14
tests/truth-flags-1-s.tmpl
Normal file
14
tests/truth-flags-1-s.tmpl
Normal file
|
@ -0,0 +1,14 @@
|
|||
I: truth-flags-2.qc
|
||||
D: logic flags
|
||||
T: -execute
|
||||
C: -std=fteqcc -fshort-logic
|
||||
M: ! & | i N
|
||||
M: 'str', 'str' -> 0 1 1 1 0
|
||||
M: 'str', '' -> 0 1 1 1 0
|
||||
M: 'str', 0 -> 0 0 1 1 0
|
||||
M: '', 'str' -> 1 1 1 1 0
|
||||
M: '', '' -> 1 1 1 1 0
|
||||
M: '', 0 -> 1 0 1 1 0
|
||||
M: 0, 'str' -> 1 0 1 0 1
|
||||
M: 0, '' -> 1 0 1 0 1
|
||||
M: 0, 0 -> 1 0 0 0 1
|
14
tests/truth-flags-1.tmpl
Normal file
14
tests/truth-flags-1.tmpl
Normal file
|
@ -0,0 +1,14 @@
|
|||
I: truth-flags-2.qc
|
||||
D: logic flags
|
||||
T: -execute
|
||||
C: -std=fteqcc
|
||||
M: ! & | i N
|
||||
M: 'str', 'str' -> 0 1 1 1 0
|
||||
M: 'str', '' -> 0 1 1 1 0
|
||||
M: 'str', 0 -> 0 0 1 1 0
|
||||
M: '', 'str' -> 1 1 1 1 0
|
||||
M: '', '' -> 1 1 1 1 0
|
||||
M: '', 0 -> 1 0 1 1 0
|
||||
M: 0, 'str' -> 1 0 1 0 1
|
||||
M: 0, '' -> 1 0 1 0 1
|
||||
M: 0, 0 -> 1 0 0 0 1
|
14
tests/truth-flags-2-s.tmpl
Normal file
14
tests/truth-flags-2-s.tmpl
Normal file
|
@ -0,0 +1,14 @@
|
|||
I: truth-flags-2.qc
|
||||
D: logic flags
|
||||
T: -execute
|
||||
C: -std=fteqcc -fshort-logic -ftrue-empty-strings
|
||||
M: ! & | i N
|
||||
M: 'str', 'str' -> 0 1 1 1 0
|
||||
M: 'str', '' -> 0 1 1 1 0
|
||||
M: 'str', 0 -> 0 0 1 1 0
|
||||
M: '', 'str' -> 0 1 1 1 0
|
||||
M: '', '' -> 0 1 1 1 0
|
||||
M: '', 0 -> 0 0 1 1 0
|
||||
M: 0, 'str' -> 1 0 1 0 1
|
||||
M: 0, '' -> 1 0 1 0 1
|
||||
M: 0, 0 -> 1 0 0 0 1
|
30
tests/truth-flags-2.qc
Normal file
30
tests/truth-flags-2.qc
Normal file
|
@ -0,0 +1,30 @@
|
|||
void print(...) = #1;
|
||||
string ftos (float) = #2;
|
||||
|
||||
float test_s_not (string s) { return !s; }
|
||||
float test_s_and (string s, string t) { return s && t; }
|
||||
float test_s_or (string s, string t) { return s || t; }
|
||||
float test_s_if (string s) { if (s) return 1; return 0; }
|
||||
float test_s_ifnot(string s) { if not (s) return 1; return 0; }
|
||||
|
||||
void test(string s, string t) {
|
||||
print(ftos(!!test_s_not (s)), " ");
|
||||
print(ftos(!!test_s_and (s, t)), " ");
|
||||
print(ftos(!!test_s_or (s, t)), " ");
|
||||
print(ftos(!!test_s_if (s)), " ");
|
||||
print(ftos(!!test_s_ifnot(s)), "\n");
|
||||
}
|
||||
|
||||
string nuls;
|
||||
void main() {
|
||||
print(" ! & | i N\n");
|
||||
print("'str', 'str' -> "); test("FULL", "FULL");
|
||||
print("'str', '' -> "); test("FULL", "" );
|
||||
print("'str', 0 -> "); test("FULL", nuls );
|
||||
print("'', 'str' -> "); test("", "FULL");
|
||||
print("'', '' -> "); test("", "" );
|
||||
print("'', 0 -> "); test("", nuls );
|
||||
print("0, 'str' -> "); test(nuls, "FULL");
|
||||
print("0, '' -> "); test(nuls, "" );
|
||||
print("0, 0 -> "); test(nuls, nuls );
|
||||
}
|
14
tests/truth-flags-2.tmpl
Normal file
14
tests/truth-flags-2.tmpl
Normal file
|
@ -0,0 +1,14 @@
|
|||
I: truth-flags-2.qc
|
||||
D: logic flags
|
||||
T: -execute
|
||||
C: -std=fteqcc -ftrue-empty-strings
|
||||
M: ! & | i N
|
||||
M: 'str', 'str' -> 0 1 1 1 0
|
||||
M: 'str', '' -> 0 1 1 1 0
|
||||
M: 'str', 0 -> 0 0 1 1 0
|
||||
M: '', 'str' -> 0 1 1 1 0
|
||||
M: '', '' -> 0 1 1 1 0
|
||||
M: '', 0 -> 0 0 1 1 0
|
||||
M: 0, 'str' -> 1 0 1 0 1
|
||||
M: 0, '' -> 1 0 1 0 1
|
||||
M: 0, 0 -> 1 0 0 0 1
|
14
tests/truth-flags-3-s.tmpl
Normal file
14
tests/truth-flags-3-s.tmpl
Normal file
|
@ -0,0 +1,14 @@
|
|||
I: truth-flags-2.qc
|
||||
D: logic flags
|
||||
T: -execute
|
||||
C: -std=fteqcc -fshort-logic -ffalse-empty-strings
|
||||
M: ! & | i N
|
||||
M: 'str', 'str' -> 0 1 1 1 0
|
||||
M: 'str', '' -> 0 0 1 1 0
|
||||
M: 'str', 0 -> 0 0 1 1 0
|
||||
M: '', 'str' -> 1 0 1 0 1
|
||||
M: '', '' -> 1 0 0 0 1
|
||||
M: '', 0 -> 1 0 0 0 1
|
||||
M: 0, 'str' -> 1 0 1 0 1
|
||||
M: 0, '' -> 1 0 0 0 1
|
||||
M: 0, 0 -> 1 0 0 0 1
|
14
tests/truth-flags-3.tmpl
Normal file
14
tests/truth-flags-3.tmpl
Normal file
|
@ -0,0 +1,14 @@
|
|||
I: truth-flags-2.qc
|
||||
D: logic flags
|
||||
T: -execute
|
||||
C: -std=fteqcc -ffalse-empty-strings
|
||||
M: ! & | i N
|
||||
M: 'str', 'str' -> 0 1 1 1 0
|
||||
M: 'str', '' -> 0 0 1 1 0
|
||||
M: 'str', 0 -> 0 0 1 1 0
|
||||
M: '', 'str' -> 1 0 1 0 1
|
||||
M: '', '' -> 1 0 0 0 1
|
||||
M: '', 0 -> 1 0 0 0 1
|
||||
M: 0, 'str' -> 1 0 1 0 1
|
||||
M: 0, '' -> 1 0 0 0 1
|
||||
M: 0, 0 -> 1 0 0 0 1
|
Loading…
Reference in a new issue