Codebase list golang-github-sanity-io-litter / 5542d98
New upstream version 1.5.4 Anthony Fok 1 year, 11 months ago
7 changed file(s) with 53 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
0 name: Test
1
2 on:
3 push:
4
5 jobs:
6 scheduled:
7 runs-on: ubuntu-latest
8 steps:
9 - name: Check out this repo
10 uses: actions/checkout@v2
11 - name: Set up Go
12 uses: actions/setup-go@v2
13 with: {go-version: '^1.16'}
14 - name: Download dependencies
15 run: go mod download
16 - name: Build
17 run: go build ./...
18 - name: Test
19 run: go test ./...
+0
-7
.travis.yml less more
0 arch:
1 - amd64
2 - ppc64le
3
4 language: go
5 go:
6 - 1.14.x
456456 }
457457
458458 // prepares a new state object for dumping the provided value
459 func newDumpState(value interface{}, options *Options, writer io.Writer) *dumpState {
459 func newDumpState(value reflect.Value, options *Options, writer io.Writer) *dumpState {
460460 result := &dumpState{
461461 config: options,
462 pointers: mapReusedPointers(reflect.ValueOf(value)),
462 pointers: mapReusedPointers(value),
463463 w: writer,
464464 }
465465
483483 // Dump a value to stdout according to the options
484484 func (o Options) Dump(values ...interface{}) {
485485 for i, value := range values {
486 state := newDumpState(value, &o, os.Stdout)
486 state := newDumpState(reflect.ValueOf(value), &o, os.Stdout)
487487 if i > 0 {
488488 state.write([]byte(o.Separator))
489489 }
499499 if i > 0 {
500500 _, _ = buf.Write([]byte(o.Separator))
501501 }
502 state := newDumpState(value, &o, buf)
502 state := newDumpState(reflect.ValueOf(value), &o, buf)
503503 state.dump(value)
504504 }
505505 return buf.String()
242242 })
243243 }
244244
245 func TestSdump_RecursiveMaps(t *testing.T) {
246 mp := make(map[*RecursiveStruct]*RecursiveStruct)
247 k1 := &RecursiveStruct{}
248 k1.Ptr = k1
249 v1 := &RecursiveStruct{}
250 v1.Ptr = v1
251 k2 := &RecursiveStruct{}
252 k2.Ptr = k2
253 v2 := &RecursiveStruct{}
254 v2.Ptr = v2
255 mp[k1] = v1
256 mp[k2] = v2
257 runTests(t, "recursive_maps", mp)
258 }
259
245260 var standardCfg = litter.Options{}
246261
247262 func runTestWithCfg(t *testing.T, name string, cfg *litter.Options, cases ...interface{}) {
00 module github.com/sanity-io/litter
11
2 go 1.14
2 go 1.16
33
44 require (
55 github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b // indirect
135135 options: &Config,
136136 })
137137 for _, key := range keys {
138 pv.consider(key)
138139 pv.consider(v.MapIndex(key))
139140 }
140141
0 map[*litter_test.RecursiveStruct]*litter_test.RecursiveStruct{
1 &litter_test.RecursiveStruct{ // p0
2 Ptr: p0,
3 }: &litter_test.RecursiveStruct{ // p1
4 Ptr: p1,
5 },
6 &litter_test.RecursiveStruct{ // p2
7 Ptr: p2,
8 }: &litter_test.RecursiveStruct{ // p3
9 Ptr: p3,
10 },
11 }