From 448d4ebd75a83c35e130bf00b6879c6e310ab930 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Fri, 23 Nov 2012 12:29:52 +0100 Subject: [PATCH] operator tests --- tests/operators.qc | 38 ++++++++++++++++++++++++++++++++++++++ tests/operators.tmpl | 13 +++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 tests/operators.qc create mode 100644 tests/operators.tmpl 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 -- 2.39.2