]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
operator tests
authorWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 23 Nov 2012 11:29:52 +0000 (12:29 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 23 Nov 2012 11:29:52 +0000 (12:29 +0100)
tests/operators.qc [new file with mode: 0644]
tests/operators.tmpl [new file with mode: 0644]

diff --git a/tests/operators.qc b/tests/operators.qc
new file mode 100644 (file)
index 0000000..ed617e9
--- /dev/null
@@ -0,0 +1,38 @@
+void   print(...)   = #1;
+string ftos (float) = #2;
+entity() spawn = #3;
+
+.float mem;
+
+void main() {
+       float a;
+
+       // regular binary+store
+       a = 5;
+       print(ftos(a += 1), " = ");
+       print(ftos(a), "\n");
+
+       entity e = spawn();
+    e.mem = 10;
+       print(ftos(e.mem += 1), " = ");
+       print(ftos(e.mem), "\n");
+
+    // prefix
+       print(ftos(++a), " = ");
+       print(ftos(a), "\n");
+       print(ftos(--a), " = ");
+       print(ftos(a), "\n");
+       print(ftos(++e.mem), " = ");
+       print(ftos(e.mem), "\n");
+
+       // suffix
+       print(ftos(a++), " = ");
+       print(ftos(a-1), "\n");
+       // the CLANG way:
+       a = 3;
+       print(ftos((a++ + a) + a), " = 11\n");
+
+       // check if minus translates
+       print(ftos(a--), "\n");
+       print(ftos(--a), "\n");
+}
diff --git a/tests/operators.tmpl b/tests/operators.tmpl
new file mode 100644 (file)
index 0000000..c0accef
--- /dev/null
@@ -0,0 +1,13 @@
+I: operators.qc
+D: compound and pre/postfix operators
+T: -execute
+C: -std=fteqcc
+M: 6 = 6
+M: 11 = 11
+M: 7 = 7
+M: 6 = 6
+M: 12 = 12
+M: 6 = 6
+M: 11 = 11
+M: 4
+M: 2