From ba0ac9737272ac247c1850be891b51c446144732 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 8 Apr 2014 14:35:11 +0200 Subject: [PATCH] add tests for INSTR_STATE and -femulate-state --- tests/state-emu.tmpl | 9 +++++++++ tests/state.qc | 39 +++++++++++++++++++++++++++++++++++++++ tests/state.tmpl | 9 +++++++++ 3 files changed, 57 insertions(+) create mode 100644 tests/state-emu.tmpl create mode 100644 tests/state.qc create mode 100644 tests/state.tmpl 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) -- 2.39.2