This commit is contained in:
Chris Wanstrath 2025-10-05 18:38:22 -07:00
parent 4608ec7b9e
commit 2a280a10b3

View File

@ -1,7 +1,7 @@
import { test, expect } from "bun:test" import { test, expect } from "bun:test"
import { VM } from "#vm" import { VM } from "#vm"
import { OpCode } from "#opcode" import { OpCode } from "#opcode"
import { toValue, toNumber } from "#value" import { toValue, toNumber, toString } from "#value"
test("CALL_NATIVE - basic function call", async () => { test("CALL_NATIVE - basic function call", async () => {
const vm = new VM({ const vm = new VM({
@ -41,8 +41,8 @@ test("CALL_NATIVE - function with string manipulation", async () => {
}) })
vm.registerFunction('concat', (a, b) => { vm.registerFunction('concat', (a, b) => {
const aStr = a.type === 'string' ? a.value : String(a.value) const aStr = a.type === 'string' ? a.value : toString(a)
const bStr = b.type === 'string' ? b.value : String(b.value) const bStr = b.type === 'string' ? b.value : toString(b)
return toValue(aStr + ' ' + bStr) return toValue(aStr + ' ' + bStr)
}) })