about summary refs log tree commit diff
path: root/pkg/lang/vm/vm_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/lang/vm/vm_test.go')
-rw-r--r--pkg/lang/vm/vm_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/pkg/lang/vm/vm_test.go b/pkg/lang/vm/vm_test.go
index 178d756..8f961ef 100644
--- a/pkg/lang/vm/vm_test.go
+++ b/pkg/lang/vm/vm_test.go
@@ -510,6 +510,33 @@ func TestCoreSay(t *testing.T) {
 	require.Equal(t, "\"Meow!!\"", string(result))
 }
 
+func TestSetAtArray(t *testing.T) {
+	src := `
+	push_array
+
+	get_local 0
+	get_member "push"
+	push_int 1
+	call 1
+	drop 1
+
+	get_local 0
+	get_member "push"
+	push_int 2
+	call 1
+	drop 1
+
+	get_local 0
+	push_int 0
+	push_int 2
+	set_at_index
+
+	get_local 0
+	`
+
+	test(t, src, "[2, 2]")
+}
+
 func test(t *testing.T, src string, expected string) {
 	bc := compile(t, src)
 	vm := vm.New(modules.NewUnknownModule(&bc))