update readme

This commit is contained in:
wgroeneveld 2018-12-05 09:47:45 +01:00
parent 3031d576f5
commit 1144a2a750
1 changed files with 24 additions and 1 deletions

View File

@ -11,10 +11,33 @@ from opbtest import OpbTestCase
class MyTestCase(OpbTestCase):
def test_my_cool_procedure_should_set_some_register(self):
assert_that = self.load_file("functions.psm4").testproc("my_cool_procedure").execute()
assert_that = self.load_file("functions.psm4")\
.testproc("add_registers")\
.setregs({"s0": 1, "s1": 2})\
.execute()
assert_that.reg("s5").contains(3)
````
Given the following Assembly:
```
jump main
proc add_registers(s0 is one, s1 is two, s5 is result) {
load result, 0
loop1:
add result, 1
sub one, 1
jump NZ, loop1
loop2:
add result, 1
sub two, 1
jump NZ, loop2
}
main:
; this should not be executed
load result, 42
```
That's it! Load your Assembly file, apply setup (mocks, inputs), and verify expectations.
opbtest relies on [opbasm and opbsim](https://kevinpt.github.io/opbasm) to compile and evaluate your code.