Added and passed jump instruction test
This commit is contained in:
parent
c77925a7e0
commit
975de37927
@ -199,3 +199,31 @@ func TestHalt(test *testing.T) {
|
||||
test.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestJump(test *testing.T) {
|
||||
machine := runMachineTest ([]int {
|
||||
PUSH, 1,
|
||||
PUSH, 8,
|
||||
JMP,
|
||||
|
||||
PUSH, 3,
|
||||
HALT,
|
||||
|
||||
PUSH, 0,
|
||||
PUSH, 16,
|
||||
JMP,
|
||||
|
||||
PUSH, 4,
|
||||
HALT,
|
||||
|
||||
PUSH, 5,
|
||||
}, nil, test)
|
||||
|
||||
result := machine.Pop()
|
||||
test.Log("popped:", result)
|
||||
|
||||
if result != 4 {
|
||||
test.Log("result should be", 4)
|
||||
test.Fail()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user