Signed comparison tests

This commit is contained in:
Ian Gulliver
2021-11-19 15:38:28 -10:00
parent 4988893b10
commit 007c56348c

View File

@@ -154,6 +154,24 @@ functions:
expectGlobalMemory(t, state, 1, 3) 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) { func TestGTU(t *testing.T) {
state := assembleAndExecute(t, ` state := assembleAndExecute(t, `
functions: functions:
@@ -172,6 +190,24 @@ functions:
expectGlobalMemory(t, state, 1, 6) 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) { func TestLTEU(t *testing.T) {
state := assembleAndExecute(t, ` state := assembleAndExecute(t, `
functions: functions:
@@ -190,6 +226,24 @@ functions:
expectGlobalMemory(t, state, 1, 1) 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) { func TestGTEU(t *testing.T) {
state := assembleAndExecute(t, ` state := assembleAndExecute(t, `
functions: functions:
@@ -207,3 +261,21 @@ functions:
expectGlobalMemory(t, state, 1, 4) 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)
}