'join' operator renamed as 'cat'

This commit is contained in:
2026-05-09 10:34:46 +02:00
parent 5950630cf7
commit 5285b61320
3 changed files with 12 additions and 10 deletions
+6 -6
View File
@@ -1,7 +1,7 @@
// Copyright (c) 2024-2026 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.
// operator-join.go
// operator-cat.go
package expr
import (
@@ -12,19 +12,19 @@ import (
"git.portale-stac.it/go-pkg/expr/scan"
)
//-------- join term
//-------- cat term
func newJoinTerm(tk *scan.Token) (inst *scan.Term) {
func newCatTerm(tk *scan.Token) (inst *scan.Term) {
return &scan.Term{
Tk: *tk,
Children: make([]*scan.Term, 0, 2),
Position: scan.PosInfix,
Priority: scan.PriIterOp,
EvalFunc: evalJoin,
EvalFunc: evalCat,
}
}
func evalJoin(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
func evalCat(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
var leftValue, rightValue any
var itLeft, itRight kern.Iterator
var item any
@@ -69,5 +69,5 @@ func evalJoin(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
// init
func init() {
scan.RegisterTermConstructor(scan.SymKwJoin, newJoinTerm)
scan.RegisterTermConstructor(scan.SymKwCat, newCatTerm)
}
+2
View File
@@ -122,6 +122,7 @@ const (
SymKwMap
SymKwFilter
SymKwDigest
SymKwCat
SymKwGroupBy
SymKwJoin
SymKwNil
@@ -141,6 +142,7 @@ func init() {
"IN": SymKwIn,
"INCLUDE": SymKwInclude,
"MAP": SymKwMap,
"CAT": SymKwCat,
"FILTER": SymKwFilter,
"NOT": SymKwNot,
"OR": SymKwOr,
+4 -4
View File
@@ -75,11 +75,11 @@ func TestOperatorDigest(t *testing.T) {
runTestSuite(t, section, inputs)
}
func TestOperatorJoin(t *testing.T) {
section := "Operator-Join"
func TestOperatorCat(t *testing.T) {
section := "Operator-Cat"
inputs := []inputType{
/* 1 */ {`["a","b"] join ["x"]`, kern.NewList([]any{"a", "b", "x"}), nil},
/* 2 */ {`["a","b"] join ["x"-true]`, nil, `[1:21] left operand 'x' [string] and right operand 'true' [bool] are not compatible with operator "-"`},
/* 1 */ {`["a","b"] cat ["x"]`, kern.NewList([]any{"a", "b", "x"}), nil},
/* 2 */ {`["a","b"] cat ["x"-true]`, nil, `[1:20] left operand 'x' [string] and right operand 'true' [bool] are not compatible with operator "-"`},
}
// runTestSuiteSpec(t, section, inputs, 2)