new operator ':=', it assigns a value to a variable by deep copy

This commit is contained in:
2026-05-17 05:02:07 +02:00
parent 08617378e0
commit 0c719025cd
9 changed files with 201 additions and 198 deletions
+14 -1
View File
@@ -54,7 +54,7 @@ func TestOperatorInsert(t *testing.T) {
/* 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},
/* 9 */ {`L=["a", "b"]; L << $([1,2,3]); L`, kern.NewListA("a", "b"), nil},
/* 10 */ {`L << $([1,2,3])`, nil, `undefined variable or function "L"`},
}
@@ -62,6 +62,19 @@ func TestOperatorInsert(t *testing.T) {
runTestSuite(t, section, inputs)
}
func TestOperatorDeepAssign(t *testing.T) {
section := "Operator-DeepAssign"
inputs := []inputType{
/* 1 */ {`DD={"uno": 1, "due": 2}; D=DD; D["uno"]=11; DD`, kern.NewDict(map[any]any{"uno": int64(11), "due": int64(2)}), nil},
/* 2 */ {`DD={"uno": 1, "due": 2}; D:=DD; D["uno"]=11; DD`, kern.NewDict(map[any]any{"uno": int64(1), "due": int64(2)}), nil},
/* 3 */ {`LL=["a", "b"]; L=LL; L[0]="x"; LL`, kern.NewListA("x", "b"), nil},
/* 4 */ {`LL=["a", "b"]; L:=LL; L[0]="x"; LL`, kern.NewListA("a", "b"), nil},
}
// runTestSuiteSpec(t, section, inputs, 4)
runTestSuite(t, section, inputs)
}
func TestOperatorDigest(t *testing.T) {
section := "Operator-Digest"
inputs := []inputType{