new operator 'groupby'

This commit is contained in:
2026-05-02 14:46:28 +02:00
parent d5ced343c4
commit 3b2ef7927b
12 changed files with 271 additions and 58 deletions
+17 -13
View File
@@ -6,7 +6,6 @@ package expr
import (
"errors"
"reflect"
"strings"
"testing"
@@ -74,7 +73,6 @@ func doTest(t *testing.T, ctx kern.ExprContext, section string, input *inputType
var ast Expr
var gotResult any
var gotErr error
var eq, eqDone bool
wantErr := getWantedError(input)
@@ -93,18 +91,24 @@ func doTest(t *testing.T, ctx kern.ExprContext, section string, input *inputType
gotResult, gotErr = ast.Eval(ctx)
}
if input.wantResult != nil && gotResult != nil {
if ls1, ok := input.wantResult.(*kern.ListType); ok {
if ls2, ok := gotResult.(*kern.ListType); ok {
eq = ls1.Equals(*ls2)
eqDone = true
}
}
}
eq := kern.Equal(gotResult, input.wantResult)
// if input.wantResult != nil && gotResult != nil {
// if ls1, ok := input.wantResult.(*kern.ListType); ok {
// if ls2, ok := gotResult.(*kern.ListType); ok {
// eq = ls1.Equals(*ls2)
// eqDone = true
// }
// } else if dict1, ok := input.wantResult.(*kern.DictType); ok {
// if dict2, ok := gotResult.(*kern.DictType); ok {
// eq = dict1.Equals(*dict2)
// eqDone = true
// }
// }
// }
if !eqDone {
eq = reflect.DeepEqual(gotResult, input.wantResult)
}
// if !eqDone {
// eq = reflect.DeepEqual(gotResult, input.wantResult)
// }
if !eq /*gotResult != input.wantResult*/ {
t.Errorf(">>>%s/%d: `%s` -> result = %v [%s], want = %v [%s]", section, count, input.source, gotResult, kern.TypeName(gotResult), input.wantResult, kern.TypeName(input.wantResult))