moved a subset of source file to the kern package
This commit is contained in:
+10
-8
@@ -6,6 +6,8 @@ package expr
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.portale-stac.it/go-pkg/expr/kern"
|
||||
)
|
||||
|
||||
func TestFuncs(t *testing.T) {
|
||||
@@ -47,12 +49,12 @@ func TestFuncs(t *testing.T) {
|
||||
runTestSuite(t, section, inputs)
|
||||
}
|
||||
|
||||
func dummy(ctx ExprContext, name string, args map[string]any) (result any, err error) {
|
||||
func dummy(ctx kern.ExprContext, name string, args map[string]any) (result any, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func TestFunctionToStringSimple(t *testing.T) {
|
||||
source := NewGolangFunctor(dummy)
|
||||
source := kern.NewGolangFunctor(dummy)
|
||||
want := "func(){}"
|
||||
got := source.ToString(0)
|
||||
if got != want {
|
||||
@@ -61,8 +63,8 @@ func TestFunctionToStringSimple(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFunctionGetFunc(t *testing.T) {
|
||||
source := NewGolangFunctor(dummy)
|
||||
want := ExprFunc(nil)
|
||||
source := kern.NewGolangFunctor(dummy)
|
||||
want := kern.ExprFunc(nil)
|
||||
got := source.GetFunc()
|
||||
if got != want {
|
||||
t.Errorf(`(func() -> result = %v [%T], want = %v [%T]`, got, got, want, want)
|
||||
@@ -76,16 +78,16 @@ func TestGoFunction(t *testing.T) {
|
||||
/* 2 */ {`myName("Peppino")`, "Peppino", nil},
|
||||
}
|
||||
|
||||
myName := func(ctx ExprContext, name string, args map[string]any) (result any, err error) {
|
||||
myName := func(ctx kern.ExprContext, name string, args map[string]any) (result any, err error) {
|
||||
var ok bool
|
||||
if result, ok = args["name"].(string); !ok {
|
||||
err = ErrWrongParamType(name, "name", TypeString, args["name"])
|
||||
err = kern.ErrWrongParamType(name, "name", kern.TypeString, args["name"])
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
ctx := NewSimpleStore()
|
||||
ctx.RegisterFunc("myName", NewGolangFunctor(myName), TypeString, []ExprFuncParam{
|
||||
ctx := NewSimpleStoreWithoutGlobalContext()
|
||||
ctx.RegisterFunc("myName", kern.NewGolangFunctor(myName), kern.TypeString, []kern.ExprFuncParam{
|
||||
NewFuncParamFlagDef("name", PfOptional|PfDefault, "Celestino Amoroso"),
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user