failing function test
This commit is contained in:
parent
173fd28d6f
commit
4898a6bb5a
|
|
@ -401,9 +401,8 @@ export class VM {
|
|||
const key = this.stack.pop()!
|
||||
namedPairs.unshift({ key: toString(key), value })
|
||||
}
|
||||
for (const pair of namedPairs) {
|
||||
for (const pair of namedPairs)
|
||||
namedArgs.set(pair.key, pair.value)
|
||||
}
|
||||
|
||||
// Pop positional arguments from stack
|
||||
const positionalArgs: Value[] = []
|
||||
|
|
|
|||
|
|
@ -376,6 +376,29 @@ test("CALL - named args with defaults on fixed params", async () => {
|
|||
expect(result).toEqual({ type: 'number', value: 5 })
|
||||
})
|
||||
|
||||
test("CALL - fixed params can be named", async () => {
|
||||
const bytecode = toBytecode(`
|
||||
MAKE_FUNCTION (a b) .func_0
|
||||
STORE minus
|
||||
TRY_LOAD minus
|
||||
PUSH 200
|
||||
PUSH 'a'
|
||||
PUSH 900
|
||||
PUSH 1
|
||||
PUSH 1
|
||||
CALL
|
||||
HALT
|
||||
.func_0:
|
||||
TRY_LOAD a
|
||||
TRY_LOAD b
|
||||
SUB
|
||||
RETURN
|
||||
`)
|
||||
|
||||
const result = await run(bytecode)
|
||||
expect(result).toEqual(toValue(700))
|
||||
})
|
||||
|
||||
test("TRY_CALL - calls function if found", async () => {
|
||||
const bytecode = toBytecode([
|
||||
["MAKE_FUNCTION", [], ".body"],
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user