]> git.xonotic.org Git - xonotic/gmqcc.git/blob - tests/parens.qc
adding testcase for various parentheses and ternary combinations which to test the...
[xonotic/gmqcc.git] / tests / parens.qc
1 void(string...)   print  = #1;
2 string(float)     ftos   = #2;
3
4 float arr[2];
5
6 string gets() { return "S\n"; }
7 void main(float x) {
8     string s;
9
10     s = gets();                // 0 params
11     print(s);                  // 1 param
12     print("A ", "B\n");        // 2 params
13     print("A ", "B ", "C\n");  // more params
14     print(gets());             // 0-param call in call
15     print(gets(), "next\n");   // 0-param call and another
16     print("-> ", gets());      // param + 0-param call
17     print(ftos(x), "\n");      // param-call + another
18     print(x ? "xA\n" : "xB\n");      // ternary in PAREN_FUNC
19     print(!x ? "xA\n" : "xB\n");      // ternary in PAREN_FUNC
20     // PAREN_INDEX
21     arr[0] = 10;
22     arr[1] = 11;
23     // PAREN_TERNARY + PAREN_INDEX
24     arr[x ? 0 : 1] += 100;
25     print(ftos(arr[0]), "\n");
26     print(ftos(arr[1]), "\n");
27     print(ftos(arr[x ? 0 : 1]), "\n");
28     print(ftos(arr[!x ? 0 : 1]), "\n");
29
30     // loops with comma operators
31     float i, j;
32     for (i = 0, j = 0; i < x; ++i)
33         print("-");
34     print("\n");
35
36     // if + PAREN_TERNARY2
37     if (x ? 1 : 0)
38         print("OK\n");
39     if (x ? 0 : 1)
40         print("NO\n");
41
42     // PAREN_FUNC in PAREN_EXPR
43     print(("Is this wrong ", "now?\n"));
44 }