aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-06-04 01:05:58 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-06-04 01:05:58 +0200
commit17a25dd6d354a3ffe9e81fc9f827684c10f7eb7f (patch)
tree0e686350e91a74005080f7f1e68af1f5c44a8a8c
parent6960f8870fd6a65955db7f9f5ee04aa6848d56ac (diff)
Add tests
-rw-r--r--eval_test.go27
-rw-r--r--parse_test.go1
2 files changed, 14 insertions, 14 deletions
diff --git a/eval_test.go b/eval_test.go
index d60f7ab..89e957a 100644
--- a/eval_test.go
+++ b/eval_test.go
@@ -7,28 +7,27 @@ import (
func TestEval(t *testing.T) {
testCases := []struct {
- before J1
- after J1
- ins Instruction
+ begin, end J1
+ ins Instruction
}{
- {ins: ALU{}, before: J1{}, after: J1{pc: 1}},
- {ins: Jump(0xff), before: J1{}, after: J1{pc: 0xff}},
- {ins: Cond(0xff), before: J1{st0: 1, dsp: 1}, after: J1{pc: 1}},
- {ins: Cond(0xff), before: J1{st0: 0, dsp: 1}, after: J1{pc: 0xff}},
- {ins: Call(0xff), before: J1{}, after: J1{pc: 0xff, rstack: [32]uint16{1}, rsp: 1}},
- {ins: Lit(0xff), before: J1{}, after: J1{pc: 1, st0: 0xff, dstack: [32]uint16{0xff}, dsp: 1}},
+ {ins: ALU{}, begin: J1{}, end: J1{pc: 1}},
+ {ins: Jump(0xff), begin: J1{}, end: J1{pc: 0xff}},
+ {ins: Cond(0xff), begin: J1{st0: 1, dsp: 1}, end: J1{pc: 1}},
+ {ins: Cond(0xff), begin: J1{st0: 0, dsp: 1}, end: J1{pc: 0xff}},
+ {ins: Call(0xff), begin: J1{}, end: J1{pc: 0xff, rstack: [32]uint16{1}, rsp: 1}},
+ {ins: Lit(0xff), begin: J1{}, end: J1{pc: 1, st0: 0xff, dstack: [32]uint16{0xff}, dsp: 1}},
{ins: Lit(0xfe),
- before: J1{pc: 1, st0: 0xff, dstack: [32]uint16{0xff}, dsp: 1},
- after: J1{pc: 2, st0: 0xfe, dstack: [32]uint16{0xff, 0xfe}, dsp: 2}},
+ begin: J1{pc: 1, st0: 0xff, dstack: [32]uint16{0xff}, dsp: 1},
+ end: J1{pc: 2, st0: 0xfe, dstack: [32]uint16{0xff, 0xfe}, dsp: 2}},
// to be continued
}
for _, tc := range testCases {
t.Run(fmt.Sprint(tc.ins), func(t *testing.T) {
- state := &tc.before
+ state := &tc.begin
state.eval(tc.ins)
- if *state != tc.after {
- t.Errorf("got %v, want %v", state, &tc.after)
+ if *state != tc.end {
+ t.Errorf("got %v, want %v", state, &tc.end)
}
})
}
diff --git a/parse_test.go b/parse_test.go
index cb29333..168032f 100644
--- a/parse_test.go
+++ b/parse_test.go
@@ -19,6 +19,7 @@ func TestDecode(t *testing.T) {
{0x8000, Lit(0x0000)},
{0xffff, Lit(0x7fff)},
{0x6000, ALU{Opcode: 0}},
+ {0x6100, ALU{Opcode: 1}},
{0x7000, ALU{Opcode: 0, RtoPC: true}},
{0x6080, ALU{Opcode: 0, TtoN: true}},
{0x6040, ALU{Opcode: 0, TtoR: true}},