1
2
3
4
5 package unify
6
7 import (
8 "reflect"
9 "slices"
10 "testing"
11 )
12
13 func ExampleClosure_All_tuple() {
14 v := mustParse(`
15 - !sum [1, 2]
16 - !sum [3, 4]
17 `)
18 printYaml(slices.Collect(v.All()))
19
20
21
22
23
24
25 }
26
27 func ExampleClosure_All_def() {
28 v := mustParse(`
29 a: !sum [1, 2]
30 b: !sum [3, 4]
31 c: 5
32 `)
33 printYaml(slices.Collect(v.All()))
34
35
36
37
38
39
40 }
41
42 func checkDecode[T any](t *testing.T, got *Value, want T) {
43 var gotT T
44 if err := got.Decode(&gotT); err != nil {
45 t.Fatalf("Decode failed: %v", err)
46 }
47 if !reflect.DeepEqual(&gotT, &want) {
48 t.Fatalf("got:\n%s\nwant:\n%s", prettyYaml(gotT), prettyYaml(want))
49 }
50 }
51
View as plain text