aboutsummaryrefslogtreecommitdiff
path: root/eval_test.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-06-06 23:42:21 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-06-06 23:42:21 +0200
commit93c36b3f48569a25667de33d9796991bfe825681 (patch)
tree8ad7548897353c7cb8a787a4a91d1c349062630d /eval_test.go
parent3a16aec44ccabc0a4bf7ffb96994a68e60fba2f4 (diff)
tests
Diffstat (limited to 'eval_test.go')
-rw-r--r--eval_test.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/eval_test.go b/eval_test.go
index c4f81a0..7f5f4e0 100644
--- a/eval_test.go
+++ b/eval_test.go
@@ -55,19 +55,24 @@ func TestEval(t *testing.T) {
end: J1{pc: 3, st0: 2, dsp: 2, dstack: [32]uint16{0, 3}},
},
{ // nip
- // ALU{Opcode: 0, Ddir: -1}
+ ins: []Instruction{Lit(2), Lit(3), ALU{Opcode: 0, Ddir: -1}},
+ end: J1{pc: 3, st0: 3, dsp: 1, dstack: [32]uint16{0, 2}},
},
{ // drop
- // ALU{Opcode: 1, Ddir: -1}
+ ins: []Instruction{Lit(2), Lit(3), ALU{Opcode: 1, Ddir: -1}},
+ end: J1{pc: 3, st0: 2, dsp: 1, dstack: [32]uint16{0, 2}},
},
{ // ;
- // ALU{Opcode: 0, RtoPC: true, Rdir: -1}
+ ins: []Instruction{Call(10), Call(20), ALU{Opcode: 0, RtoPC: true, Rdir: -1}},
+ end: J1{pc: 11, rsp: 1, rstack: [32]uint16{1, 11}},
},
{ // >r
- // ALU{Opcode: 1, TtoR: true, Ddir: -1, Rdir: 1}
+ ins: []Instruction{Lit(10), ALU{Opcode: 1, TtoR: true, Ddir: -1, Rdir: 1}},
+ end: J1{pc: 2, rsp: 1, rstack: [32]uint16{10}},
},
{ // r>
- // ALU{Opcode: 11, TtoN: true, TtoR: true, Ddir: 1, Rdir: -1}
+ // ins: []Instruction{Lit(10), Call(20), ALU{Opcode: 11, TtoN: true, TtoR: true, Ddir: 1, Rdir: -1}},
+ // end: J1{pc: 2, st0: 21, rsp: 1, rstack: [32]uint16{10}, dsp: 2, dstack: [32]uint16{10}},
},
{ // r@
// ALU{Opcode: 11, TtoN: true, TtoR: true, Ddir: 1}
@@ -76,7 +81,7 @@ func TestEval(t *testing.T) {
// ALU{Opcode: 12}
},
{ // !
- // ALU{Opcode: 1, Ddir: -1}
+ // ALU{Opcode: 1, NtoAtT: true, Ddir: -1}
},
}
@@ -87,6 +92,8 @@ func TestEval(t *testing.T) {
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)
}
})