From 007c56348c4a57b7c9b70e01bbdf6c14a18988de Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 19 Nov 2021 15:38:28 -1000 Subject: [PATCH] Signed comparison tests --- test/opcode_test.go | 72 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/test/opcode_test.go b/test/opcode_test.go index 7068f51..f9518d5 100644 --- a/test/opcode_test.go +++ b/test/opcode_test.go @@ -154,6 +154,24 @@ functions: expectGlobalMemory(t, state, 1, 3) } +func TestLTS(t *testing.T) { + state := assembleAndExecute(t, ` +functions: +- - [mov, g0, 0] + - [lts, g0, -1] + - [jmpt, +2] + - [add, g1, 1] + - [lts, g0, 0] + - [jmpt, +2] + - [add, g1, 2] + - [lts, g0, 1] + - [jmpt, +2] + - [add, g1, 4] +`) + + expectGlobalMemory(t, state, 1, 3) +} + func TestGTU(t *testing.T) { state := assembleAndExecute(t, ` functions: @@ -172,6 +190,24 @@ functions: expectGlobalMemory(t, state, 1, 6) } +func TestGTS(t *testing.T) { + state := assembleAndExecute(t, ` +functions: +- - [mov, g0, 0] + - [gts, g0, -1] + - [jmpt, +2] + - [add, g1, 1] + - [gts, g0, 0] + - [jmpt, +2] + - [add, g1, 2] + - [gts, g0, 1] + - [jmpt, +2] + - [add, g1, 4] +`) + + expectGlobalMemory(t, state, 1, 6) +} + func TestLTEU(t *testing.T) { state := assembleAndExecute(t, ` functions: @@ -190,6 +226,24 @@ functions: expectGlobalMemory(t, state, 1, 1) } +func TestLTES(t *testing.T) { + state := assembleAndExecute(t, ` +functions: +- - [mov, g0, 0] + - [ltes, g0, -1] + - [jmpt, +2] + - [add, g1, 1] + - [ltes, g0, 0] + - [jmpt, +2] + - [add, g1, 2] + - [ltes, g0, 1] + - [jmpt, +2] + - [add, g1, 4] +`) + + expectGlobalMemory(t, state, 1, 1) +} + func TestGTEU(t *testing.T) { state := assembleAndExecute(t, ` functions: @@ -207,3 +261,21 @@ functions: expectGlobalMemory(t, state, 1, 4) } + +func TestGTES(t *testing.T) { + state := assembleAndExecute(t, ` +functions: +- - [mov, g0, 0] + - [gtes, g0, -1] + - [jmpt, +2] + - [add, g1, 1] + - [gtes, g0, 0] + - [jmpt, +2] + - [add, g1, 2] + - [gtes, g0, 1] + - [jmpt, +2] + - [add, g1, 4] +`) + + expectGlobalMemory(t, state, 1, 4) +}