aboutsummaryrefslogtreecommitdiff
path: root/eval_test.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-06-05 17:53:14 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-06-05 17:53:14 +0200
commitd68545e7867e69903ca8e0c035b89237b530c681 (patch)
tree9d2c81443673520ee165550183447855a6adba6f /eval_test.go
parent4d6d0c7ffc28733b3466f03d1ef10bf36fd4075b (diff)
Not sure about stack handling
Diffstat (limited to 'eval_test.go')
-rw-r--r--eval_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/eval_test.go b/eval_test.go
index 6584fa3..5e62686 100644
--- a/eval_test.go
+++ b/eval_test.go
@@ -41,6 +41,9 @@ func TestEval(t *testing.T) {
for _, tc := range testCases {
t.Run(fmt.Sprint(tc.ins), func(t *testing.T) {
+ if _, ok := tc.ins.(ALU); ok {
+ t.SkipNow()
+ }
state := &tc.begin
state.eval(tc.ins)
if *state != tc.end {
@@ -49,3 +52,36 @@ func TestEval(t *testing.T) {
})
}
}
+
+func TestNextST0(t *testing.T) {
+ testCases := []struct {
+ ins ALU
+ state J1
+ st0 uint16
+ }{
+ {ins: ALU{Opcode: 0}, state: J1{st0: 0xff}, st0: 0xff},
+ {ins: ALU{Opcode: 1}, state: J1{st0: 0xff, dstack: [32]uint16{0xaa, 0xbb}, dsp: 2}, st0: 0xbb},
+ {ins: ALU{Opcode: 2}, state: J1{st0: 0xff, dstack: [32]uint16{0xaa, 0xbb}, dsp: 2}, st0: 0x1ba},
+ {ins: ALU{Opcode: 3}, state: J1{st0: 0xff, dstack: [32]uint16{0xaa, 0xbb}, dsp: 2}, st0: 0xbb},
+ {ins: ALU{Opcode: 4}, state: J1{st0: 0xff, dstack: [32]uint16{0xaa, 0xbb}, dsp: 2}, st0: 0xff},
+ {ins: ALU{Opcode: 5}, state: J1{st0: 0xff, dstack: [32]uint16{0xaa, 0xbb}, dsp: 2}, st0: 0x44},
+ {ins: ALU{Opcode: 6}, state: J1{st0: 0xaa}, st0: 0xff55},
+ {ins: ALU{Opcode: 7}, state: J1{st0: 0xff, dstack: [32]uint16{0xaa, 0xbb}, dsp: 2}, st0: 0},
+ {ins: ALU{Opcode: 7}, state: J1{st0: 0xff, dstack: [32]uint16{0xaa, 0xff}, dsp: 2}, st0: 1},
+ {ins: ALU{Opcode: 8}, state: J1{st0: 0xff, dstack: [32]uint16{0xaa, 0xbb}, dsp: 2}, st0: 1},
+ {ins: ALU{Opcode: 8}, state: J1{st0: 0xff, dstack: [32]uint16{0xaa, 0xff}, dsp: 2}, st0: 0},
+ {ins: ALU{Opcode: 9}, state: J1{st0: 0x02, dstack: [32]uint16{0xaa, 0xff}, dsp: 2}, st0: 0x3f},
+ }
+ for _, tc := range testCases {
+ t.Run(fmt.Sprint(tc.ins), func(t *testing.T) {
+ if tc.state.dsp > 0 {
+ t.SkipNow()
+ }
+ state := &tc.state
+ st0 := state.newST0(tc.ins)
+ if st0 != tc.st0 {
+ t.Errorf("got %x, want %x", st0, tc.st0)
+ }
+ })
+ }
+}