New upstream version 1.5.4
Anthony Fok
1 year, 11 months ago
|
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 | |
arch:
|
1 | |
- amd64
|
2 | |
- ppc64le
|
3 | |
|
4 | |
language: go
|
5 | |
go:
|
6 | |
- 1.14.x
|
456 | 456 |
}
|
457 | 457 |
|
458 | 458 |
// 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 {
|
460 | 460 |
result := &dumpState{
|
461 | 461 |
config: options,
|
462 | |
pointers: mapReusedPointers(reflect.ValueOf(value)),
|
|
462 |
pointers: mapReusedPointers(value),
|
463 | 463 |
w: writer,
|
464 | 464 |
}
|
465 | 465 |
|
|
483 | 483 |
// Dump a value to stdout according to the options
|
484 | 484 |
func (o Options) Dump(values ...interface{}) {
|
485 | 485 |
for i, value := range values {
|
486 | |
state := newDumpState(value, &o, os.Stdout)
|
|
486 |
state := newDumpState(reflect.ValueOf(value), &o, os.Stdout)
|
487 | 487 |
if i > 0 {
|
488 | 488 |
state.write([]byte(o.Separator))
|
489 | 489 |
}
|
|
499 | 499 |
if i > 0 {
|
500 | 500 |
_, _ = buf.Write([]byte(o.Separator))
|
501 | 501 |
}
|
502 | |
state := newDumpState(value, &o, buf)
|
|
502 |
state := newDumpState(reflect.ValueOf(value), &o, buf)
|
503 | 503 |
state.dump(value)
|
504 | 504 |
}
|
505 | 505 |
return buf.String()
|
242 | 242 |
})
|
243 | 243 |
}
|
244 | 244 |
|
|
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 |
|
245 | 260 |
var standardCfg = litter.Options{}
|
246 | 261 |
|
247 | 262 |
func runTestWithCfg(t *testing.T, name string, cfg *litter.Options, cases ...interface{}) {
|
0 | 0 |
module github.com/sanity-io/litter
|
1 | 1 |
|
2 | |
go 1.14
|
|
2 |
go 1.16
|
3 | 3 |
|
4 | 4 |
require (
|
5 | 5 |
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b // indirect
|
|
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 |
}⏎
|