diff options
| author | Mel <einebeere@gmail.com> | 2022-08-29 22:43:27 +0000 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2022-08-29 22:43:27 +0000 |
| commit | 1afe662ccd02d686f46f596242055c3ea23e645f (patch) | |
| tree | 487433f18fad06785584aa5bd02f28328008f18f /pkg/lang/vm | |
| parent | 646b2fbe0dc12b89f807569d554e23051cf17ffb (diff) | |
| download | jinx-1afe662ccd02d686f46f596242055c3ea23e645f.tar.zst jinx-1afe662ccd02d686f46f596242055c3ea23e645f.zip | |
Add simple memory leak test
Diffstat (limited to 'pkg/lang/vm')
| -rw-r--r-- | pkg/lang/vm/vm_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/pkg/lang/vm/vm_test.go b/pkg/lang/vm/vm_test.go index 8c31d1f..ea4123f 100644 --- a/pkg/lang/vm/vm_test.go +++ b/pkg/lang/vm/vm_test.go @@ -525,6 +525,42 @@ func TestSetAtArray(t *testing.T) { test(t, src, "[2, 2]") } +func TestNoBasicLeak(t *testing.T) { + // NOTE: The loop count should be changed in accordance to the Mem memory limit. + src := ` + push_int 0 + + @check: + get_local 0 + push_int 10000 + lt + jf @end + + push_array + + get_local 1 + get_member "push" + push_int 123 + call 1 + drop 1 + + get_local 0 + push_int 1 + add + set_local 0 + + drop 1 + + jmp @check + + @end: + push_string "done" + halt + ` + + test(t, src, "\"done\"") +} + func test(t *testing.T, src string, expected string) { bc := compile(t, src) vm := vm.New(modules.NewUnknownModule(&bc), vm.NewEmptyOutput()) |
