about summary refs log tree commit diff
path: root/pkg/lang
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/lang')
-rw-r--r--pkg/lang/vm/vm_test.go36
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())