From: Wolfgang (Blub) Bumiller Date: Fri, 23 Nov 2012 11:29:52 +0000 (+0100) Subject: operator tests X-Git-Tag: 0.1.9~315 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=448d4ebd75a83c35e130bf00b6879c6e310ab930;p=xonotic%2Fgmqcc.git operator tests --- diff --git a/tests/operators.qc b/tests/operators.qc new file mode 100644 index 0000000..ed617e9 --- /dev/null +++ b/tests/operators.qc @@ -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 index 0000000..c0accef --- /dev/null +++ b/tests/operators.tmpl @@ -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