From: Wolfgang Bumiller Date: Sat, 22 Dec 2012 16:36:06 +0000 (+0100) Subject: Adding truth-flags testsuite for strings X-Git-Tag: 0.2~12^2~11 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d858237010edd160b5e8331682f6491c17615df0;p=xonotic%2Fgmqcc.git Adding truth-flags testsuite for strings --- diff --git a/tests/truth-flags-1-s.tmpl b/tests/truth-flags-1-s.tmpl new file mode 100644 index 0000000..770f306 --- /dev/null +++ b/tests/truth-flags-1-s.tmpl @@ -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 diff --git a/tests/truth-flags-1.tmpl b/tests/truth-flags-1.tmpl new file mode 100644 index 0000000..7562374 --- /dev/null +++ b/tests/truth-flags-1.tmpl @@ -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 diff --git a/tests/truth-flags-2-s.tmpl b/tests/truth-flags-2-s.tmpl new file mode 100644 index 0000000..3de75eb --- /dev/null +++ b/tests/truth-flags-2-s.tmpl @@ -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 diff --git a/tests/truth-flags-2.qc b/tests/truth-flags-2.qc new file mode 100644 index 0000000..0c10708 --- /dev/null +++ b/tests/truth-flags-2.qc @@ -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 ); +} diff --git a/tests/truth-flags-2.tmpl b/tests/truth-flags-2.tmpl new file mode 100644 index 0000000..d9bb543 --- /dev/null +++ b/tests/truth-flags-2.tmpl @@ -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 diff --git a/tests/truth-flags-3-s.tmpl b/tests/truth-flags-3-s.tmpl new file mode 100644 index 0000000..1ebd56b --- /dev/null +++ b/tests/truth-flags-3-s.tmpl @@ -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 diff --git a/tests/truth-flags-3.tmpl b/tests/truth-flags-3.tmpl new file mode 100644 index 0000000..f166dda --- /dev/null +++ b/tests/truth-flags-3.tmpl @@ -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