alias operators: '<<' same as '<+', '>>' same as '+>'. Insert and append operation optimized with linked lists

This commit is contained in:
2026-05-16 17:18:23 +02:00
parent 3a4e217891
commit e6844ad1e8
7 changed files with 386 additions and 34 deletions
+19
View File
@@ -43,6 +43,25 @@ func TestOperator(t *testing.T) {
runTestSuite(t, section, inputs)
}
func TestOperatorInsert(t *testing.T) {
section := "Operator-Insert"
inputs := []inputType{
/* 1 */ {`["a", "b"] << nil`, kern.NewListA("a", "b"), nil},
/* 2 */ {`["a", "b"] << []`, kern.NewListA("a", "b"), nil},
/* 3 */ {`["a", "b"] << 3`, kern.NewListA("a", "b", int64(3)), nil},
/* 4 */ {`3 << ["a", "b"]`, nil, `[1:5] left operand '3' [integer] and right operand '["a", "b"]' [list] are not compatible with operator "<<"`},
/* 5 */ {`nil >> ["a", "b"]`, kern.NewListA("a", "b"), nil},
/* 6 */ {`[] >> ["a", "b"]`, kern.NewListA("a", "b"), nil},
/* 7 */ {`["a", "b"] << $([1,2,3])`, kern.NewListA("a", "b", int64(1), int64(2), int64(3)), nil},
/* 8 */ {`L=["a", "b"]; L << $([1,2,3])`, kern.NewListA("a", "b", int64(1), int64(2), int64(3)), nil},
/* 9 */ {`L=["a", "b"]; L << $([1,2,3]); L`, kern.NewListA("a", "b", int64(1), int64(2), int64(3)), nil},
/* 10 */ {`L << $([1,2,3])`, nil, `undefined variable or function "L"`},
}
// runTestSuiteSpec(t, section, inputs, 9)
runTestSuite(t, section, inputs)
}
func TestOperatorDigest(t *testing.T) {
section := "Operator-Digest"
inputs := []inputType{