]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - misc/source/gmqcc-src/tests/short-logic.qc
By fteqcc, hello gmqcc
[voretournament/voretournament.git] / misc / source / gmqcc-src / tests / short-logic.qc
diff --git a/misc/source/gmqcc-src/tests/short-logic.qc b/misc/source/gmqcc-src/tests/short-logic.qc
new file mode 100644 (file)
index 0000000..9dd0550
--- /dev/null
@@ -0,0 +1,46 @@
+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");
+}