Compare commits
2 Commits
78923b3eff
...
0bb0af6c1e
| Author | SHA1 | Date | |
|---|---|---|---|
| 0bb0af6c1e | |||
| 80183653f4 |
|
|
@ -26,9 +26,7 @@ export class VM {
|
||||||
this.scope = new Scope()
|
this.scope = new Scope()
|
||||||
}
|
}
|
||||||
|
|
||||||
registerFunction(name: string, fn: NativeFunction | Function) {
|
registerFunction(name: string, fn: Function) {
|
||||||
// If it's already a NativeFunction, use it directly
|
|
||||||
// Otherwise, assume it's a JS function and wrap it
|
|
||||||
const wrapped = isWrapped(fn) ? fn as NativeFunction : wrapNative(fn)
|
const wrapped = isWrapped(fn) ? fn as NativeFunction : wrapNative(fn)
|
||||||
this.nativeFunctions.set(name, wrapped)
|
this.nativeFunctions.set(name, wrapped)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ test("CALL_NATIVE - function not found", async () => {
|
||||||
|
|
||||||
const vm = new VM(bytecode)
|
const vm = new VM(bytecode)
|
||||||
|
|
||||||
await expect(vm.run()).rejects.toThrow('CALL_NATIVE: function not found: nonexistent')
|
expect(vm.run()).rejects.toThrow('CALL_NATIVE: function not found: nonexistent')
|
||||||
})
|
})
|
||||||
|
|
||||||
test("CALL_NATIVE - using result in subsequent operations", async () => {
|
test("CALL_NATIVE - using result in subsequent operations", async () => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user