From 7392283d9e6b8c1ee31a3ad74ce8d13d4e8b19ec Mon Sep 17 00:00:00 2001 From: Mel Date: Tue, 26 Jul 2022 19:52:31 +0000 Subject: Fix cloning of outlets and don't drop nil cells --- pkg/lang/vm/vm_test.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'pkg/lang/vm/vm_test.go') diff --git a/pkg/lang/vm/vm_test.go b/pkg/lang/vm/vm_test.go index 7e749a4..ae0b8e6 100644 --- a/pkg/lang/vm/vm_test.go +++ b/pkg/lang/vm/vm_test.go @@ -184,6 +184,45 @@ func TestEscapedEnv(t *testing.T) { test(t, src, "[1, 2, 3]") } +func TestEnvNotEscaped(t *testing.T) { + /* + var x = 1 + + fn f() { + x = x + 1 + return + } + + f() + var result = x + */ + + src := ` + push_int 1 + + push_function @f + add_to_env 0 + get_local 1 + + call 0 + drop 1 + + get_local 0 + halt + + @f: + get_env 0 + push_int 1 + add + set_env 0 + + push_null + ret + ` + + test(t, src, "2") +} + func TestMember(t *testing.T) { src := ` push_array -- cgit 1.4.1