aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-01-06 22:53:30 +0100
committerDimitri Sokolyuk <demon@dim13.org>2018-01-06 22:53:30 +0100
commite995ee3c0b77708aa2b6f04a7c86a4ed4684d96a (patch)
tree962bdd9991eab4fe8413295d46d3dfd2c21caf6c
parent7c2738fce8a03c2bad0019a70457b299b93acfc7 (diff)
fix test
-rw-r--r--eval_test.go28
1 files changed, 23 insertions, 5 deletions
diff --git a/eval_test.go b/eval_test.go
index d3a3abc..9aacf09 100644
--- a/eval_test.go
+++ b/eval_test.go
@@ -5,6 +5,28 @@ import (
"testing"
)
+func cmp(t *testing.T, got, want J1) {
+ t.Helper()
+ if got.pc != want.pc {
+ t.Errorf("pc: got %0.4X, want %0.4X", got.pc, want.pc)
+ }
+ if got.st0 != want.st0 {
+ t.Errorf("st0: got %0.4X, want %0.4X", got.st0, want.st0)
+ }
+ if got.dsp != want.dsp {
+ t.Errorf("dsp: got %0.4X, want %0.4X", got.dsp, want.dsp)
+ }
+ if got.rsp != want.rsp {
+ t.Errorf("rsp: got %0.4X, want %0.4X", got.rsp, want.rsp)
+ }
+ if got.dstack != want.dstack {
+ t.Errorf("dstack: got %0.4X, want %0.4X", got.dstack, want.dstack)
+ }
+ if got.rstack != want.rstack {
+ t.Errorf("rstack: got %0.4X, want %0.4X", got.rstack, want.rstack)
+ }
+}
+
func TestEval(t *testing.T) {
testCases := []struct {
ins []Instruction
@@ -94,11 +116,7 @@ func TestEval(t *testing.T) {
for _, ins := range tc.ins {
state.eval(ins)
}
- if *state != tc.end {
- t.Logf("D=%v", state.dstack)
- t.Logf("R=%v", state.rstack)
- t.Errorf("got %v, want %v", state, &tc.end)
- }
+ cmp(t, *state, tc.end)
})
}
}