operator tests

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-11-23 12:29:52 +01:00
parent 1223e04e05
commit 448d4ebd75
2 changed files with 51 additions and 0 deletions

38
tests/operators.qc Normal file
View file

@ -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");
}

13
tests/operators.tmpl Normal file
View file

@ -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