mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-23 20:33:05 +00:00
add tests for INSTR_STATE and -femulate-state
This commit is contained in:
parent
8dafdfc5e2
commit
ba0ac97372
3 changed files with 57 additions and 0 deletions
9
tests/state-emu.tmpl
Normal file
9
tests/state-emu.tmpl
Normal file
|
@ -0,0 +1,9 @@
|
|||
I: state.qc
|
||||
D: test emulated state ops
|
||||
T: -execute
|
||||
C: -std=gmqcc -femulate-state
|
||||
M: st1, .frame=1, .nextthink=10.1 (now: 10)
|
||||
M: st2, .frame=2, .nextthink=11.1 (now: 11)
|
||||
M: st3, .frame=0, .nextthink=12.1 (now: 12)
|
||||
M: st1, .frame=1, .nextthink=13.1 (now: 13)
|
||||
M: st2, .frame=2, .nextthink=14.1 (now: 14)
|
39
tests/state.qc
Normal file
39
tests/state.qc
Normal file
|
@ -0,0 +1,39 @@
|
|||
float time;
|
||||
entity self;
|
||||
|
||||
.void() think;
|
||||
.float nextthink;
|
||||
.float frame;
|
||||
|
||||
void stprint(string fun) {
|
||||
print(fun,
|
||||
", .frame=", ftos(self.frame),
|
||||
", .nextthink=", ftos(self.nextthink),
|
||||
" (now: ", ftos(time), ")\n");
|
||||
}
|
||||
|
||||
void st1() = [1, st2] { stprint("st1"); }
|
||||
void st2() = [2, st3] { stprint("st2"); }
|
||||
void st3() = [0, st1] { stprint("st3"); }
|
||||
|
||||
void main() {
|
||||
entity ea = spawn();
|
||||
entity eb = spawn();
|
||||
|
||||
time = 10;
|
||||
self = ea;
|
||||
|
||||
self.think = st1;
|
||||
self.nextthink = time;
|
||||
self.frame = 100;
|
||||
|
||||
self.think();
|
||||
time = 11;
|
||||
self.think();
|
||||
time = 12;
|
||||
self.think();
|
||||
time = 13;
|
||||
self.think();
|
||||
time = 14;
|
||||
self.think();
|
||||
};
|
9
tests/state.tmpl
Normal file
9
tests/state.tmpl
Normal file
|
@ -0,0 +1,9 @@
|
|||
I: state.qc
|
||||
D: test state ops
|
||||
T: -execute
|
||||
C: -std=gmqcc
|
||||
M: st1, .frame=1, .nextthink=10.1 (now: 10)
|
||||
M: st2, .frame=2, .nextthink=11.1 (now: 11)
|
||||
M: st3, .frame=0, .nextthink=12.1 (now: 12)
|
||||
M: st1, .frame=1, .nextthink=13.1 (now: 13)
|
||||
M: st2, .frame=2, .nextthink=14.1 (now: 14)
|
Loading…
Reference in a new issue