the assign operators, '=' and ':=', can set the value of dict items
This commit is contained in:
+28
-3
@@ -36,11 +36,36 @@ func TestDictParser(t *testing.T) {
|
||||
/* 13 */ {`D={"a":1, "b":2}; D."a"`, int64(1), nil},
|
||||
/* 14 */ {`D={"a":1, "b":2}; D.a`, int64(1), nil},
|
||||
/* 15 */ {`D={1:"a", 2:"b", 3:"c"}; D.(1+2)`, "c", nil},
|
||||
/* 16 */ {`D={"a":1, "b":2}; D.a`, int64(1), nil},
|
||||
/* 16 */ {`D={1:"a"}; D.2`, nil, `[1:15] key 2 not found`},
|
||||
/* 17 */ {`D={1:"a"}; D."2"`, nil, `[1:17] key "2" not found`},
|
||||
/* 18 */ {`D={"a":1, "b":2}; D.a = 10; D.a`, int64(10), nil},
|
||||
// /* 19 */ {`D={"a": {"one": 1}}; D.a."one" = 10; D["a"]["one"]`, int64(10), nil},
|
||||
}
|
||||
|
||||
runTestSuiteSpec(t, section, inputs, 16)
|
||||
// runTestSuite(t, section, inputs)
|
||||
// runTestSuiteSpec(t, section, inputs, 16)
|
||||
runTestSuite(t, section, inputs)
|
||||
}
|
||||
|
||||
func _TestPoc(t *testing.T) {
|
||||
section := "Dict-Assign-Item"
|
||||
ctx := NewSimpleStore()
|
||||
ctx.UnsafeSetVar(
|
||||
"D",
|
||||
kern.NewDict(map[any]any{
|
||||
"a": kern.NewDict(map[any]any{
|
||||
"uno": int64(10),
|
||||
},
|
||||
),
|
||||
}),
|
||||
) // D={"a": {"uno":1}}
|
||||
|
||||
inputs := []inputType{
|
||||
/* 1 */ {`D.a.uno`, int64(10), nil},
|
||||
/* 2 */ {`D.a.uno = 111; D.a."uno"`, int64(111), nil},
|
||||
/* 3 */ {`D["a"]["uno"]`, int64(111), nil},
|
||||
}
|
||||
runCtxTestSuiteSpec(t, ctx, section, inputs, 3)
|
||||
// runCtxTestSuite(t, ctx, section, inputs)
|
||||
}
|
||||
|
||||
func TestDictToStringMultiLine(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user