mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 14:12:36 +00:00
Adding short-logic testcase
This commit is contained in:
parent
f719a81e2a
commit
2f672cce1d
2 changed files with 58 additions and 0 deletions
49
tests/short-logic.qc
Normal file
49
tests/short-logic.qc
Normal file
|
@ -0,0 +1,49 @@
|
|||
void print(...) = #1;
|
||||
string ftos(float) = #2;
|
||||
|
||||
float glob1;
|
||||
float glob2;
|
||||
float glob3;
|
||||
|
||||
float side_effect_1(float r) {
|
||||
glob1 += 3;
|
||||
return r;
|
||||
}
|
||||
|
||||
float side_effect_2(float r) {
|
||||
glob2 += 3;
|
||||
return r;
|
||||
}
|
||||
|
||||
float side_effect_3(float r) {
|
||||
glob3 += 3;
|
||||
return r;
|
||||
}
|
||||
|
||||
void main() {
|
||||
glob1 = 10;
|
||||
glob2 = 20;
|
||||
glob3 = 30;
|
||||
|
||||
if (side_effect_1(0) || side_effect_2(1))
|
||||
print(ftos(glob1), "=13 ", ftos(glob2), "=23 OK\n");
|
||||
else
|
||||
print("Fail\n");
|
||||
|
||||
if (side_effect_3(1) || side_effect_1(1))
|
||||
print(ftos(glob1), "=13 ", ftos(glob3), "=33 OK\n");
|
||||
else
|
||||
print("Fail\n");
|
||||
|
||||
if (side_effect_1(0) && side_effect_3(1))
|
||||
print("Fail\n");
|
||||
else
|
||||
print(ftos(glob1), "=16 ", ftos(glob3), "=33 OK\n");
|
||||
|
||||
if (side_effect_2(1) && side_effect_3(1))
|
||||
print(ftos(glob2), "=26 ", ftos(glob3), "=36 OK\n");
|
||||
else
|
||||
print("Fail\n");
|
||||
|
||||
print(ftos(glob1), "=16 ", ftos(glob2), "=26 ", ftos(glob3), "=36 OK\n");
|
||||
}
|
9
tests/short-logic.tmpl
Normal file
9
tests/short-logic.tmpl
Normal file
|
@ -0,0 +1,9 @@
|
|||
I: short-logic.qc
|
||||
D: test short circuit logic
|
||||
T: -execute
|
||||
C: -std=fteqcc -fshort-logic
|
||||
M: 13=13 23=23 OK
|
||||
M: 13=13 33=33 OK
|
||||
M: 16=16 33=33 OK
|
||||
M: 26=26 36=36 OK
|
||||
M: 16=16 26=26 36=36 OK
|
Loading…
Reference in a new issue