]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Test cases for -fcorrect-logic
authorWolfgang Bumiller <blub@speed.at>
Sat, 22 Dec 2012 16:55:55 +0000 (17:55 +0100)
committerWolfgang Bumiller <blub@speed.at>
Sat, 22 Dec 2012 16:55:55 +0000 (17:55 +0100)
tests/correct-logic-1-s.tmpl [new file with mode: 0644]
tests/correct-logic-1.tmpl [new file with mode: 0644]
tests/correct-logic-2-s.tmpl [new file with mode: 0644]
tests/correct-logic-2.tmpl [new file with mode: 0644]
tests/correct-logic.qc [new file with mode: 0644]

diff --git a/tests/correct-logic-1-s.tmpl b/tests/correct-logic-1-s.tmpl
new file mode 100644 (file)
index 0000000..e3f3451
--- /dev/null
@@ -0,0 +1,12 @@
+I: correct-logic.qc
+D: vector logic flags
+T: -execute
+C: -std=fteqcc -fshort-logic
+M:          ! & | i N
+M: 0, 0 -> 1 0 0 0 1
+M: 0, x -> 1 0 1 0 1
+M: x, 0 -> 0 0 1 1 0
+M: x, x -> 0 1 1 1 0
+M: 0, y -> 1 0 0 0 1
+M: y, 0 -> 0 0 0 0 1
+M: y, y -> 0 0 0 0 1
diff --git a/tests/correct-logic-1.tmpl b/tests/correct-logic-1.tmpl
new file mode 100644 (file)
index 0000000..b151f46
--- /dev/null
@@ -0,0 +1,12 @@
+I: correct-logic.qc
+D: vector logic flags
+T: -execute
+C: -std=fteqcc
+M:          ! & | i N
+M: 0, 0 -> 1 0 0 0 1
+M: 0, x -> 1 0 1 0 1
+M: x, 0 -> 0 0 1 1 0
+M: x, x -> 0 1 1 1 0
+M: 0, y -> 1 0 0 0 1
+M: y, 0 -> 0 0 0 0 1
+M: y, y -> 0 0 0 0 1
diff --git a/tests/correct-logic-2-s.tmpl b/tests/correct-logic-2-s.tmpl
new file mode 100644 (file)
index 0000000..a7ada6e
--- /dev/null
@@ -0,0 +1,12 @@
+I: correct-logic.qc
+D: vector logic flags
+T: -execute
+C: -std=fteqcc -fcorrect-logic -fshort-logic
+M:          ! & | i N
+M: 0, 0 -> 1 0 0 0 1
+M: 0, x -> 1 0 1 0 1
+M: x, 0 -> 0 0 1 1 0
+M: x, x -> 0 1 1 1 0
+M: 0, y -> 1 0 1 0 1
+M: y, 0 -> 0 0 1 1 0
+M: y, y -> 0 1 1 1 0
diff --git a/tests/correct-logic-2.tmpl b/tests/correct-logic-2.tmpl
new file mode 100644 (file)
index 0000000..7ecd3df
--- /dev/null
@@ -0,0 +1,12 @@
+I: correct-logic.qc
+D: vector logic flags
+T: -execute
+C: -std=fteqcc -fcorrect-logic
+M:          ! & | i N
+M: 0, 0 -> 1 0 0 0 1
+M: 0, x -> 1 0 1 0 1
+M: x, 0 -> 0 0 1 1 0
+M: x, x -> 0 1 1 1 0
+M: 0, y -> 1 0 1 0 1
+M: y, 0 -> 0 0 1 1 0
+M: y, y -> 0 1 1 1 0
diff --git a/tests/correct-logic.qc b/tests/correct-logic.qc
new file mode 100644 (file)
index 0000000..cb9a38d
--- /dev/null
@@ -0,0 +1,27 @@
+void   print(...)   = #1;
+string ftos (float) = #2;
+
+float test_s_not  (vector s)           { return !s; }
+float test_s_and  (vector s, vector t) { return s && t; }
+float test_s_or   (vector s, vector t) { return s || t; }
+float test_s_if   (vector s)           { if (s) return 1; return 0; }
+float test_s_ifnot(vector s)           { if not (s) return 1; return 0; }
+
+void test(vector s, vector 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");
+}
+
+void main() {
+    print("        ! & | i N\n");
+    print("0, 0 -> "); test('0 0 0', '0 0 0');
+    print("0, x -> "); test('0 0 0', '1 0 0');
+    print("x, 0 -> "); test('1 0 0', '0 0 0');
+    print("x, x -> "); test('1 0 0', '1 0 0');
+    print("0, y -> "); test('0 0 0', '0 1 0');
+    print("y, 0 -> "); test('0 1 0', '0 0 0');
+    print("y, y -> "); test('0 1 0', '0 1 0');
+}