From 975de3792795280b52c6de79217e7e9eebe6cb0f Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 28 Aug 2022 22:45:46 -0400 Subject: [PATCH] Added and passed jump instruction test --- creature_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/creature_test.go b/creature_test.go index e148dd4..50a4244 100644 --- a/creature_test.go +++ b/creature_test.go @@ -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() + } +}