Jump tests

This commit is contained in:
Ian Gulliver
2021-11-19 15:42:27 -10:00
parent 007c56348c
commit 7da1ea96da

View File

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