diff options
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) |
