]> git.xonotic.org Git - xonotic/gmqcc.git/blob - tests/xor.qc
b2820eff3304259bbebee694f2d42801a1f6b2d1
[xonotic/gmqcc.git] / tests / xor.qc
1 void main() {
2     float x = 5;
3     float y = 3;
4     float z = x ^ y; // 6
5     
6     float a = 2;
7     float b = 10;
8     float c = a ^ b; // 8
9     
10     print(ftos(z), "\n");
11     print(ftos(c), "\n");
12     
13     // commutative?
14     if (x ^ y == y ^ x)
15         print("commutative\n");
16     
17     // assocative?
18     if (x ^ (y ^ z) == (x ^ y) ^ z)
19         print("assocative\n");
20         
21     // elements are their own inverse?
22     if (x ^ 0 == x)
23         print("inverse\n");
24         
25     // vector ^ vector
26     // vector ^ float
27     // are legal in constant expressions (currently)
28     const vector v3 = '5 2 5' ^ '3 10 3';
29     const vector v4 = '5 2 5' ^ 10;
30     
31     print("vv: ", vtos(v3), "\n");
32     print("vf: ", vtos(v4), "\n");
33 }