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) +}