mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-21 02:40:56 +00:00
adding testcase for various parentheses and ternary combinations which to test the newly refactored code; includes some cases not hit by xonotic
This commit is contained in:
parent
dca9dd56d1
commit
62af1659eb
2 changed files with 66 additions and 0 deletions
44
tests/parens.qc
Normal file
44
tests/parens.qc
Normal file
|
@ -0,0 +1,44 @@
|
|||
void(string...) print = #1;
|
||||
string(float) ftos = #2;
|
||||
|
||||
float arr[2];
|
||||
|
||||
string gets() { return "S\n"; }
|
||||
void main(float x) {
|
||||
string s;
|
||||
|
||||
s = gets(); // 0 params
|
||||
print(s); // 1 param
|
||||
print("A ", "B\n"); // 2 params
|
||||
print("A ", "B ", "C\n"); // more params
|
||||
print(gets()); // 0-param call in call
|
||||
print(gets(), "next\n"); // 0-param call and another
|
||||
print("-> ", gets()); // param + 0-param call
|
||||
print(ftos(x), "\n"); // param-call + another
|
||||
print(x ? "xA\n" : "xB\n"); // ternary in PAREN_FUNC
|
||||
print(!x ? "xA\n" : "xB\n"); // ternary in PAREN_FUNC
|
||||
// PAREN_INDEX
|
||||
arr[0] = 10;
|
||||
arr[1] = 11;
|
||||
// PAREN_TERNARY + PAREN_INDEX
|
||||
arr[x ? 0 : 1] += 100;
|
||||
print(ftos(arr[0]), "\n");
|
||||
print(ftos(arr[1]), "\n");
|
||||
print(ftos(arr[x ? 0 : 1]), "\n");
|
||||
print(ftos(arr[!x ? 0 : 1]), "\n");
|
||||
|
||||
// loops with comma operators
|
||||
float i, j;
|
||||
for (i = 0, j = 0; i < x; ++i)
|
||||
print("-");
|
||||
print("\n");
|
||||
|
||||
// if + PAREN_TERNARY2
|
||||
if (x ? 1 : 0)
|
||||
print("OK\n");
|
||||
if (x ? 0 : 1)
|
||||
print("NO\n");
|
||||
|
||||
// PAREN_FUNC in PAREN_EXPR
|
||||
print(("Is this wrong ", "now?\n"));
|
||||
}
|
22
tests/parens.tmpl
Normal file
22
tests/parens.tmpl
Normal file
|
@ -0,0 +1,22 @@
|
|||
I: parens.qc
|
||||
D: parentheses, SYA stuff
|
||||
T: -execute
|
||||
C: -std=fteqcc
|
||||
E: -float 4
|
||||
M: S
|
||||
M: A B
|
||||
M: A B C
|
||||
M: S
|
||||
M: S
|
||||
M: next
|
||||
M: -> S
|
||||
M: 4
|
||||
M: xA
|
||||
M: xB
|
||||
M: 110
|
||||
M: 11
|
||||
M: 110
|
||||
M: 11
|
||||
M: ----
|
||||
M: OK
|
||||
M: now?
|
Loading…
Reference in a new issue