moved a subset of source file to the kern package

This commit is contained in:
2026-04-27 19:43:37 +02:00
parent f100adead3
commit 4d910dd069
107 changed files with 2080 additions and 1380 deletions
+11 -9
View File
@@ -9,6 +9,8 @@ import (
"reflect"
"strings"
"testing"
"git.portale-stac.it/go-pkg/expr/kern"
)
type inputType struct {
@@ -17,7 +19,7 @@ type inputType struct {
wantErr any
}
func runCtxTestSuiteSpec(t *testing.T, ctx ExprContext, section string, inputs []inputType, spec ...int) {
func runCtxTestSuiteSpec(t *testing.T, ctx kern.ExprContext, section string, inputs []inputType, spec ...int) {
succeeded := 0
failed := 0
for _, count := range spec {
@@ -36,7 +38,7 @@ func runTestSuiteSpec(t *testing.T, section string, inputs []inputType, spec ...
runCtxTestSuiteSpec(t, nil, section, inputs, spec...)
}
func runCtxTestSuite(t *testing.T, ctx ExprContext, section string, inputs []inputType) {
func runCtxTestSuite(t *testing.T, ctx kern.ExprContext, section string, inputs []inputType) {
succeeded := 0
failed := 0
@@ -68,8 +70,8 @@ func getWantedError(input *inputType) error {
return wantErr
}
func doTest(t *testing.T, ctx ExprContext, section string, input *inputType, count int) (good bool) {
var expr Expr
func doTest(t *testing.T, ctx kern.ExprContext, section string, input *inputType, count int) (good bool) {
var ast Expr
var gotResult any
var gotErr error
var eq, eqDone bool
@@ -87,13 +89,13 @@ func doTest(t *testing.T, ctx ExprContext, section string, input *inputType, cou
scanner := NewScanner(r, DefaultTranslations())
good = true
if expr, gotErr = parser.Parse(scanner); gotErr == nil {
gotResult, gotErr = expr.Eval(ctx)
if ast, gotErr = parser.Parse(scanner); gotErr == nil {
gotResult, gotErr = ast.Eval(ctx)
}
if input.wantResult != nil && gotResult != nil {
if ls1, ok := input.wantResult.(*ListType); ok {
if ls2, ok := gotResult.(*ListType); ok {
if ls1, ok := input.wantResult.(*kern.ListType); ok {
if ls2, ok := gotResult.(*kern.ListType); ok {
eq = ls1.Equals(*ls2)
eqDone = true
}
@@ -105,7 +107,7 @@ func doTest(t *testing.T, ctx ExprContext, section string, input *inputType, cou
}
if !eq /*gotResult != input.wantResult*/ {
t.Errorf("%d: `%s` -> result = %v [%s], want = %v [%s]", count, input.source, gotResult, TypeName(gotResult), input.wantResult, TypeName(input.wantResult))
t.Errorf("%d: `%s` -> result = %v [%s], want = %v [%s]", count, input.source, gotResult, kern.TypeName(gotResult), input.wantResult, kern.TypeName(input.wantResult))
good = false
}