Jump tests
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user