diff options
| author | Mel <einebeere@gmail.com> | 2022-05-20 21:04:37 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2022-05-20 21:04:37 +0200 |
| commit | 3f4efe745a0404953266476ec52db54b182de2f8 (patch) | |
| tree | 107542d587c97b99f749c537870e84d196058210 /pkg/lang/vm/vm_test.go | |
| parent | 25eb5ca1b0a8b9b35f36deedec4901bca02bf43e (diff) | |
| download | jinx-3f4efe745a0404953266476ec52db54b182de2f8.tar.zst jinx-3f4efe745a0404953266476ec52db54b182de2f8.zip | |
Call and return from functions
Diffstat (limited to 'pkg/lang/vm/vm_test.go')
| -rw-r--r-- | pkg/lang/vm/vm_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/lang/vm/vm_test.go b/pkg/lang/vm/vm_test.go index f87182f..298cfb2 100644 --- a/pkg/lang/vm/vm_test.go +++ b/pkg/lang/vm/vm_test.go @@ -90,6 +90,24 @@ func TestFibonacci(t *testing.T) { test(t, src, "[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]") } +func TestFunction(t *testing.T) { + src := ` + push_int 44 + push_function @subtract_two + call + halt + + @subtract_two: + shift 1 + push_int 2 + get_local 0 + sub + ret + ` + + test(t, src, "42") +} + func test(t *testing.T, src string, expected string) { bc := compile(t, src) |
