]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
add tests for INSTR_STATE and -femulate-state
authorWolfgang Bumiller <wry.git@bumiller.com>
Tue, 8 Apr 2014 12:35:11 +0000 (14:35 +0200)
committerWolfgang Bumiller <wry.git@bumiller.com>
Tue, 8 Apr 2014 12:35:11 +0000 (14:35 +0200)
tests/state-emu.tmpl [new file with mode: 0644]
tests/state.qc [new file with mode: 0644]
tests/state.tmpl [new file with mode: 0644]

diff --git a/tests/state-emu.tmpl b/tests/state-emu.tmpl
new file mode 100644 (file)
index 0000000..1d96adc
--- /dev/null
@@ -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 (file)
index 0000000..9f99ccc
--- /dev/null
@@ -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 (file)
index 0000000..6e9cf67
--- /dev/null
@@ -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)