From: Wolfgang Bumiller Date: Tue, 8 Apr 2014 12:35:11 +0000 (+0200) Subject: add tests for INSTR_STATE and -femulate-state X-Git-Tag: xonotic-v0.8.1~9^2~33^2~2 X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;h=ba0ac9737272ac247c1850be891b51c446144732;p=xonotic%2Fgmqcc.git add tests for INSTR_STATE and -femulate-state --- diff --git a/tests/state-emu.tmpl b/tests/state-emu.tmpl new file mode 100644 index 0000000..1d96adc --- /dev/null +++ b/tests/state-emu.tmpl @@ -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) diff --git a/tests/state.qc b/tests/state.qc new file mode 100644 index 0000000..9f99ccc --- /dev/null +++ b/tests/state.qc @@ -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(); +}; diff --git a/tests/state.tmpl b/tests/state.tmpl new file mode 100644 index 0000000..6e9cf67 --- /dev/null +++ b/tests/state.tmpl @@ -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)