Skip to content

Commit 7974483

Browse files
committed
align-go
1 parent 8215692 commit 7974483

File tree

12 files changed

+735
-3130
lines changed

12 files changed

+735
-3130
lines changed

go/testutil/direct.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,79 +19,79 @@ func DirectTest() {
1919
// console.log('OUT-A0', out, errs)
2020
/*
2121
errs = voxgigstruct.ListRefCreate[any]()
22-
out, _ = voxgigstruct.ValidateCollect(1, "`$STRING`", nil, errs)
22+
out, _ = voxgigstruct.Validate(1, "`$STRING`", &voxgigstruct.Injection{Errs: errs})
2323
fmt.Println("OUT-A0", out, errs.List)
2424
2525
// errs = []
2626
// out = validate({ a: 1 }, { a: '`$STRING`' }, undefined, errs)
2727
// console.log('OUT-A1', out, errs)
2828
errs = voxgigstruct.ListRefCreate[any]()
29-
out, _ = voxgigstruct.ValidateCollect(map[string]any{"a": 1}, map[string]any{"a": "`$STRING`"}, nil, errs)
29+
out, _ = voxgigstruct.Validate(map[string]any{"a": 1}, map[string]any{"a": "`$STRING`"}, &voxgigstruct.Injection{Errs: errs})
3030
fmt.Println("OUT-A1", out, errs.List)
3131
3232
// errs = []
3333
// out = validate(true, ['`$ONE`', '`$STRING`', '`$NUMBER`'], undefined, errs)
3434
// console.log('OUT-B0', out, errs)
3535
errs = voxgigstruct.ListRefCreate[any]()
36-
out, _ = voxgigstruct.ValidateCollect(true, []any{"`$ONE`", "`$STRING`", "`$NUMBER`"}, nil, errs)
36+
out, _ = voxgigstruct.Validate(true, []any{"`$ONE`", "`$STRING`", "`$NUMBER`"}, &voxgigstruct.Injection{Errs: errs})
3737
fmt.Println("OUT-B0", out, errs.List)
3838
3939
// errs = []
4040
// out = validate(true, ['`$ONE`', '`$STRING`'], undefined, errs)
4141
// console.log('OUT-B1', out, errs)
4242
errs = voxgigstruct.ListRefCreate[any]()
43-
out, _ = voxgigstruct.ValidateCollect(true, []any{"`$ONE`", "`$STRING`"}, nil, errs)
43+
out, _ = voxgigstruct.Validate(true, []any{"`$ONE`", "`$STRING`"}, &voxgigstruct.Injection{Errs: errs})
4444
fmt.Println("OUT-B1", out, errs.List)
4545
4646
// errs = []
4747
// out = validate(3, ['`$EXACT`', 4], undefined, errs)
4848
// console.log('OUT', out, errs)
4949
errs = voxgigstruct.ListRefCreate[any]()
50-
out, _ = voxgigstruct.ValidateCollect(3, []any{"`$EXACT`", 4}, nil, errs)
50+
out, _ = voxgigstruct.Validate(3, []any{"`$EXACT`", 4}, &voxgigstruct.Injection{Errs: errs})
5151
fmt.Println("OUT", out, errs.List)
5252
5353
// errs = []
5454
// out = validate({ a: 3 }, { a: ['`$EXACT`', 4] }, undefined, errs)
5555
// console.log('OUT', out, errs)
5656
errs = voxgigstruct.ListRefCreate[any]()
57-
out, _ = voxgigstruct.ValidateCollect(map[string]any{"a": 3}, map[string]any{"a": []any{"`$EXACT`", 4}}, nil, errs)
57+
out, _ = voxgigstruct.Validate(map[string]any{"a": 3}, map[string]any{"a": []any{"`$EXACT`", 4}}, &voxgigstruct.Injection{Errs: errs})
5858
fmt.Println("OUT", out, errs.List)
5959
6060
// errs = []
6161
// out = validate({}, { '`$EXACT`': 1 }, undefined, errs)
6262
// console.log('OUT', out, errs)
6363
errs = voxgigstruct.ListRefCreate[any]()
64-
out, _ = voxgigstruct.ValidateCollect(map[string]any{}, map[string]any{"`$EXACT`": 1}, nil, errs)
64+
out, _ = voxgigstruct.Validate(map[string]any{}, map[string]any{"`$EXACT`": 1}, &voxgigstruct.Injection{Errs: errs})
6565
fmt.Println("OUT", out, errs.List)
6666
6767
// errs = []
6868
// out = validate({}, { a: '`$EXACT`' }, undefined, errs)
6969
// console.log('OUT', out, errs)
7070
errs = voxgigstruct.ListRefCreate[any]()
71-
out, _ = voxgigstruct.ValidateCollect(map[string]any{}, map[string]any{"a": "`$EXACT`"}, nil, errs)
71+
out, _ = voxgigstruct.Validate(map[string]any{}, map[string]any{"a": "`$EXACT`"}, &voxgigstruct.Injection{Errs: errs})
7272
fmt.Println("OUT", out, errs.List)
7373
7474
// errs = []
7575
// out = validate({}, { a: [1, '`$EXACT`'] }, undefined, errs)
7676
// console.log('OUT', out, errs)
7777
errs = voxgigstruct.ListRefCreate[any]()
78-
out, _ = voxgigstruct.ValidateCollect(map[string]any{}, map[string]any{"a": []any{1, "`$EXACT`"}}, nil, errs)
78+
out, _ = voxgigstruct.Validate(map[string]any{}, map[string]any{"a": []any{1, "`$EXACT`"}}, &voxgigstruct.Injection{Errs: errs})
7979
fmt.Println("OUT", out, errs.List)
8080
8181
// errs = []
8282
// out = validate({}, { a: ['`$ONE`', '`$STRING`', '`$NUMBER`'] }, undefined, errs)
8383
// console.log('OUT', out, errs)
8484
errs = voxgigstruct.ListRefCreate[any]()
85-
out, _ = voxgigstruct.ValidateCollect(map[string]any{}, map[string]any{"a": []any{"`$ONE`", "`$STRING`", "`$NUMBER`"}}, nil, errs)
85+
out, _ = voxgigstruct.Validate(map[string]any{}, map[string]any{"a": []any{"`$ONE`", "`$STRING`", "`$NUMBER`"}}, &voxgigstruct.Injection{Errs: errs})
8686
fmt.Println("OUT", out, errs.List)
8787
*/
8888

8989
// This is the only uncommented test from direct.ts
9090
errs = voxgigstruct.ListRefCreate[any]()
91-
out, _ = voxgigstruct.ValidateCollect(
91+
out, _ = voxgigstruct.Validate(
9292
map[string]any{
9393
// kind: undefined
94-
},
94+
},
9595
map[string]any{
9696
// name: '`$STRING`',
9797
// kind: ['`$EXACT`', 'req', 'res'],
@@ -108,9 +108,8 @@ func DirectTest() {
108108
// data: ['`$ONE`', {}, []],
109109
// state: {},
110110
// check: {},
111-
},
112-
nil,
113-
errs)
111+
},
112+
&voxgigstruct.Injection{Errs: errs})
114113
fmt.Println("OUT", out, errs.List)
115114
}
116115

go/testutil/runner.go

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,52 @@ type StructUtility struct {
3434
IsNode func(val any) bool
3535
Clone func(val any) any
3636
CloneFlags func(val any, flags map[string]bool) any
37-
GetPath func(path any, store any) any
38-
Inject func(val any, store any) any
37+
GetPath func(path any, store any, injdefs ...*voxgigstruct.Injection) any
38+
Inject func(val any, store any, injdefs ...*voxgigstruct.Injection) any
3939
Items func(val any) [][2]any
4040
Stringify func(val any, maxlen ...int) string
4141
Walk func(val any, apply voxgigstruct.WalkApply, opts ...any) any
42+
43+
DelProp func(parent any, key any) any
44+
EscRe func(s string) string
45+
EscUrl func(s string) string
46+
Filter func(val any, check func([2]any) bool) []any
47+
Flatten func(list any, depths ...int) any
48+
GetDef func(val any, alt any) any
49+
GetElem func(val any, key any, alts ...any) any
50+
GetProp func(val any, key any, alts ...any) any
51+
HasKey func(val any, key any) bool
52+
IsEmpty func(val any) bool
53+
IsFunc func(val any) bool
54+
IsKey func(val any) bool
55+
IsList func(val any) bool
56+
IsMap func(val any) bool
57+
Join func(arr []any, args ...any) string
58+
Jsonify func(val any, flags ...map[string]any) string
59+
KeysOf func(val any) []string
60+
Merge func(val any, maxdepths ...int) any
61+
Pad func(str any, args ...any) string
62+
Pathify func(val any, from ...int) string
63+
Select func(children any, query any) []any
64+
SetPath func(store any, path any, val any, injdefs ...map[string]any) any
65+
SetProp func(parent any, key any, newval any) any
66+
Size func(val any) int
67+
Slice func(val any, args ...any) any
68+
StrKey func(key any) string
69+
Transform func(data any, spec any, injdefs ...*voxgigstruct.Injection) any
70+
Typify func(value any) int
71+
Typename func(t int) string
72+
Validate func(data any, spec any, injdefs ...*voxgigstruct.Injection) (any, error)
73+
74+
SKIP any
75+
DELETE any
76+
77+
Jo func(kv ...any) map[string]any
78+
Ja func(v ...any) []any
79+
80+
CheckPlacement func(modes int, ijname string, parentTypes int, inj *voxgigstruct.Injection) bool
81+
InjectorArgs func(argTypes []int, args []any) []any
82+
InjectChild func(child any, store any, inj *voxgigstruct.Injection) *voxgigstruct.Injection
4283
}
4384

4485

@@ -890,8 +931,7 @@ func NullModifier(
890931
val any,
891932
key any,
892933
parent any,
893-
state *voxgigstruct.Injection,
894-
current any,
934+
inj *voxgigstruct.Injection,
895935
store any,
896936
) {
897937
switch v := val.(type) {

go/testutil/sdk.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,47 @@ func NewSDK(opts map[string]any) *SDK {
7575
Items: voxgigstruct.Items,
7676
Stringify: voxgigstruct.Stringify,
7777
Walk: voxgigstruct.Walk,
78+
79+
DelProp: voxgigstruct.DelProp,
80+
EscRe: voxgigstruct.EscRe,
81+
EscUrl: voxgigstruct.EscUrl,
82+
Filter: voxgigstruct.Filter,
83+
Flatten: voxgigstruct.Flatten,
84+
GetDef: voxgigstruct.GetDef,
85+
GetElem: voxgigstruct.GetElem,
86+
GetProp: voxgigstruct.GetProp,
87+
HasKey: voxgigstruct.HasKey,
88+
IsEmpty: voxgigstruct.IsEmpty,
89+
IsFunc: voxgigstruct.IsFunc,
90+
IsKey: voxgigstruct.IsKey,
91+
IsList: voxgigstruct.IsList,
92+
IsMap: voxgigstruct.IsMap,
93+
Join: voxgigstruct.Join,
94+
Jsonify: voxgigstruct.Jsonify,
95+
KeysOf: voxgigstruct.KeysOf,
96+
Merge: voxgigstruct.Merge,
97+
Pad: voxgigstruct.Pad,
98+
Pathify: voxgigstruct.Pathify,
99+
Select: voxgigstruct.Select,
100+
SetPath: voxgigstruct.SetPath,
101+
SetProp: voxgigstruct.SetProp,
102+
Size: voxgigstruct.Size,
103+
Slice: voxgigstruct.Slice,
104+
StrKey: voxgigstruct.StrKey,
105+
Transform: voxgigstruct.Transform,
106+
Typify: voxgigstruct.Typify,
107+
Typename: voxgigstruct.Typename,
108+
Validate: voxgigstruct.Validate,
109+
110+
SKIP: voxgigstruct.SKIP,
111+
DELETE: voxgigstruct.DELETE,
112+
113+
Jo: voxgigstruct.Jo,
114+
Ja: voxgigstruct.Ja,
115+
116+
CheckPlacement: voxgigstruct.CheckPlacement,
117+
InjectorArgs: voxgigstruct.InjectorArgs,
118+
InjectChild: voxgigstruct.InjectChild,
78119
}
79120

80121
// Create the utility

0 commit comments

Comments
 (0)