New test file for specific code section or data type

This commit is contained in:
2024-06-01 16:31:50 +02:00
parent f41ea96d17
commit f66cd1fdb1
19 changed files with 488 additions and 214 deletions
+2 -28
View File
@@ -25,10 +25,10 @@ func newFuncCallTerm(tk *Token, args []*term) *term {
func checkFunctionCall(ctx ExprContext, name string, params []any) (err error) {
if info, exists, owner := GetFuncInfo(ctx, name); exists {
if info.MinArgs() > len(params) {
err = errTooFewParams(info.MinArgs(), info.MaxArgs(), len(params))
err = errTooFewParams(name, info.MinArgs(), info.MaxArgs(), len(params))
}
if err == nil && info.MaxArgs() >= 0 && info.MaxArgs() < len(params) {
err = errTooMuchParams(info.MaxArgs(), len(params))
err = errTooMuchParams(name, info.MaxArgs(), len(params))
}
if err == nil && owner != ctx {
// ctx.RegisterFunc(name, info.Functor(), info.MinArgs(), info.MaxArgs())
@@ -75,32 +75,6 @@ func newFuncDefTerm(tk *Token, args []*term) *term {
}
// -------- eval func def
// TODO
// type funcDefFunctor struct {
// params []string
// expr Expr
// }
// func (funcDef *funcDefFunctor) Invoke(ctx ExprContext, name string, args []any) (result any, err error) {
// for i, p := range funcDef.params {
// if i < len(args) {
// arg := args[i]
// if functor, ok := arg.(Functor); ok {
// // ctx.RegisterFunc(p, functor, 0, -1)
// ctx.RegisterFunc2(p, functor, typeAny, []ExprFuncParam{
// newFuncParam(paramValue),
// })
// } else {
// ctx.UnsafeSetVar(p, arg)
// }
// } else {
// ctx.UnsafeSetVar(p, nil)
// }
// }
// result, err = funcDef.expr.eval(ctx, false)
// return
// }
func evalFuncDef(ctx ExprContext, self *term) (v any, err error) {
bodySpec := self.value()
if expr, ok := bodySpec.(*ast); ok {