]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Adding short-logic testcase
authorWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 22 Nov 2012 19:03:53 +0000 (20:03 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 22 Nov 2012 19:32:40 +0000 (20:32 +0100)
tests/short-logic.qc [new file with mode: 0644]
tests/short-logic.tmpl [new file with mode: 0644]

diff --git a/tests/short-logic.qc b/tests/short-logic.qc
new file mode 100644 (file)
index 0000000..a62ed79
--- /dev/null
@@ -0,0 +1,49 @@
+void   print(...) = #1;
+string ftos(float) = #2;
+
+float glob1;
+float glob2;
+float glob3;
+
+float side_effect_1(float r) {
+    glob1 += 3;
+    return r;
+}
+
+float side_effect_2(float r) {
+    glob2 += 3;
+    return r;
+}
+
+float side_effect_3(float r) {
+    glob3 += 3;
+    return r;
+}
+
+void main() {
+    glob1 = 10;
+    glob2 = 20;
+    glob3 = 30;
+
+    if (side_effect_1(0) || side_effect_2(1))
+        print(ftos(glob1), "=13 ", ftos(glob2), "=23 OK\n");
+    else
+        print("Fail\n");
+
+    if (side_effect_3(1) || side_effect_1(1))
+        print(ftos(glob1), "=13 ", ftos(glob3), "=33 OK\n");
+    else
+        print("Fail\n");
+
+    if (side_effect_1(0) && side_effect_3(1))
+        print("Fail\n");
+    else
+        print(ftos(glob1), "=16 ", ftos(glob3), "=33 OK\n");
+
+    if (side_effect_2(1) && side_effect_3(1))
+        print(ftos(glob2), "=26 ", ftos(glob3), "=36 OK\n");
+    else
+        print("Fail\n");
+
+    print(ftos(glob1), "=16 ", ftos(glob2), "=26 ", ftos(glob3), "=36 OK\n");
+}
diff --git a/tests/short-logic.tmpl b/tests/short-logic.tmpl
new file mode 100644 (file)
index 0000000..e137af9
--- /dev/null
@@ -0,0 +1,9 @@
+I: short-logic.qc
+D: test short circuit logic
+T: -execute
+C: -std=fteqcc -fshort-logic
+M: 13=13 23=23 OK
+M: 13=13 33=33 OK
+M: 16=16 33=33 OK
+M: 26=26 36=36 OK
+M: 16=16 26=26 36=36 OK