Add test for func

This commit is contained in:
Neemek 2025-03-10 16:24:07 +01:00
parent 634a4a2b61
commit 40a538b73d
Signed by: neemek
GPG key ID: 28360A8951CD0E9B

View file

@ -21,6 +21,30 @@ func GetAllTestCases() map[string]AllTestCase {
}, },
}, },
}, },
"func": {
"func sum(a, b) {\n\treturn a + b\n}\nsum(1, 2)",
[]Value{
&VariableValue{
"sum",
FunctionValue{
Name: "sum",
Params: []string{"a", "b"},
Chunk: &Chunk{
Bytecode: []Bytecode{
InstructionDescend,
InstructionGetLocal, 0,
InstructionGetLocal, 1,
InstructionAdd,
InstructionReturn,
InstructionAscend,
},
Constants: []Value{StringValue("a"), StringValue("b")},
},
},
0,
},
},
},
} }
} }