Added and passed jump instruction test

This commit is contained in:
Sasha Koshka 2022-08-28 22:45:46 -04:00
parent c77925a7e0
commit 975de37927
1 changed files with 28 additions and 0 deletions

View File

@ -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()
}
}