Alternate signing constructs #1

Merged
lmika merged 12 commits from feature/assign into main 2025-05-24 00:12:24 +00:00
2 changed files with 11 additions and 11 deletions
Showing only changes of commit f79e91e26d - Show all commits

View file

@ -140,17 +140,17 @@ func TestStrs_Split(t *testing.T) {
want any
wantErr bool
}{
{desc: "split 1", eval: `strs:split "1,2,3" ","`, want: ucl.StringListObject{"1", "2", "3"}},
{desc: "split 2", eval: `strs:split "1,2,3" ";"`, want: ucl.StringListObject{"1,2,3"}},
{desc: "split 3", eval: `strs:split "" ";"`, want: ucl.StringListObject{""}},
{desc: "split 4", eval: `strs:split " " ";"`, want: ucl.StringListObject{" "}},
{desc: "split 1", eval: `strs:split "1,2,3" ","`, want: []string{"1", "2", "3"}},
{desc: "split 2", eval: `strs:split "1,2,3" ";"`, want: []string{"1,2,3"}},
{desc: "split 3", eval: `strs:split "" ";"`, want: []string{""}},
{desc: "split 4", eval: `strs:split " " ";"`, want: []string{" "}},
{desc: "split by char 1", eval: `strs:split "123"`, want: ucl.StringListObject{"1", "2", "3"}},
{desc: "split by char 1", eval: `strs:split "123"`, want: []string{"1", "2", "3"}},
{desc: "split max 1", eval: `strs:split "1,2,3" "," -max 2`, want: ucl.StringListObject{"1", "2,3"}},
{desc: "split max 2", eval: `strs:split "1,2,3" "," -max 5`, want: ucl.StringListObject{"1", "2", "3"}},
{desc: "split max 1", eval: `strs:split "1,2,3" "," -max 2`, want: []string{"1", "2,3"}},
{desc: "split max 2", eval: `strs:split "1,2,3" "," -max 5`, want: []string{"1", "2", "3"}},
{desc: "split by char max 1", eval: `strs:split "12345" -max 3`, want: ucl.StringListObject{"1", "2", "345"}},
{desc: "split by char max 1", eval: `strs:split "12345" -max 3`, want: []string{"1", "2", "345"}},
{desc: "err 1", eval: `strs:split "1,2,3" -max []`, wantErr: true},
}

View file

@ -151,7 +151,7 @@ func (inst *Inst) Eval(ctx context.Context, expr string) (any, error) {
goRes, ok := toGoValue(res)
if !ok {
return nil, ErrNotConvertable
return res, nil
}
return goRes, nil
@ -207,7 +207,7 @@ func (n nativePseudoVarHandler) set(ctx context.Context, name string, v Object)
gv, ok := toGoValue(v)
if !ok {
return errors.New("cannot set non-matching type")
return mpvh.Set(ctx, v)
}
return mpvh.Set(ctx, gv)
@ -233,7 +233,7 @@ func (n nativeMissingPseudoVarHandler) set(ctx context.Context, name string, v O
gv, ok := toGoValue(v)
if !ok {
return errors.New("cannot set non-matching type")
return mpvh.Set(ctx, name, v)
}
return mpvh.Set(ctx, name, gv)