mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-17 17:11:32 +00:00
operator tests
This commit is contained in:
parent
1223e04e05
commit
448d4ebd75
2 changed files with 51 additions and 0 deletions
38
tests/operators.qc
Normal file
38
tests/operators.qc
Normal 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
13
tests/operators.tmpl
Normal 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
|
Loading…
Reference in a new issue