From 7da1ea96da91779ebb50f99700a443249c3397f4 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 19 Nov 2021 15:42:27 -1000 Subject: [PATCH] Jump tests --- test/opcode_test.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/opcode_test.go b/test/opcode_test.go index f9518d5..20c6d0f 100644 --- a/test/opcode_test.go +++ b/test/opcode_test.go @@ -279,3 +279,46 @@ functions: expectGlobalMemory(t, state, 1, 4) } + +func TestJmp(t *testing.T) { + state := assembleAndExecute(t, ` +functions: +- - [jmp, +2] + - [add, g0, 1] + - [add, g0, 2] + - [jmp, +1] + - [add, g0, 4] +`) + + expectGlobalMemory(t, state, 0, 6) +} + +func TestJmpT(t *testing.T) { + state := assembleAndExecute(t, ` +functions: +- - [eq, 0, 0] + - [jmpt, +2] + - [add, g0, 1] + - [eq, 0, 1] + - [jmpt, +2] + - [add, g0, 2] + - [add, g0, 4] +`) + + expectGlobalMemory(t, state, 0, 6) +} + +func TestJmpF(t *testing.T) { + state := assembleAndExecute(t, ` +functions: +- - [eq, 0, 0] + - [jmpf, +2] + - [add, g0, 1] + - [eq, 0, 1] + - [jmpf, +2] + - [add, g0, 2] + - [add, g0, 4] +`) + + expectGlobalMemory(t, state, 0, 5) +}