This commit is contained in:
2026-05-09 09:24:46 -05:00
parent 19b51fcaa0
commit a6adb9b723
2 changed files with 82 additions and 5 deletions

View File

@@ -242,8 +242,7 @@ do TEST "VM: functions"
assert_eq(vm:to_integer(-1), -1)
end
do
TEST "VM: jumps (jmp + bnz)"
do TEST "VM: jumps (jmp + bnz)"
local vm = VM.new():load(assemble [[
.func 0
jmp @x1
@@ -264,9 +263,8 @@ do
assert_eq(vm:to_integer(-1), 6)
end
do
TEST "VM: jumps (bz)"
local vm = VM.new():set_debug(true):load(assemble [[
do TEST "VM: jumps (bz)"
local vm = VM.new():load(assemble [[
.func 0
jmp @x1
pushi 5
@@ -286,5 +284,25 @@ do
assert_eq(vm:to_integer(-1), 7)
end
do TEST "VM: string from const"
local vm = VM.new():load(assemble [[
.const
0: "Hello"
.func 0
pushc 0
ret
]]):call(0)
assert_eq(vm:to_string(-1), "Hello")
end
do TEST "VM: managed strings"
local vm = VM.new():push_string("Hello")
assert_eq(vm:to_string(-1), "Hello")
end
-- TODO - concatenate strings
-- TODO - collect string (GC)
print('End.')