-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathall_test.go
More file actions
46 lines (40 loc) · 988 Bytes
/
all_test.go
File metadata and controls
46 lines (40 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package cuerious_test
import (
"fmt"
"testing"
"cuelang.org/go/cue"
"cuelang.org/go/cue/cuecontext"
"cuelang.org/go/cue/format"
"github.com/sdboyer/cuerious"
"github.com/sdboyer/cuerious/internal/cuetxtar"
)
// func TestMain(m *testing.M) {
// os.Exit(testscript.RunMain(m, map[string]func() int{}))
// }
func TestDumpExprTree(t *testing.T) {
test := cuetxtar.TxTarTest{
Root: "testdata",
Name: "exprtree",
}
test.Run(t, func(tc *cuetxtar.Test) {
ctx := cuecontext.New()
v := ctx.BuildInstance(tc.Instance())
if v.Err() != nil {
tc.Fatalf("errors in cue input: %s", v.Err())
}
iter, err := v.Fields(cue.All())
if err != nil {
tc.Fatal(err)
}
for iter.Next() {
w := tc.Writer(iter.Selector().String())
n := cuerious.ExprTree(iter.Value())
sb, err := format.Node(n.V.Source())
if err != nil {
t.Fatalf("could not format node: %s", err)
}
fmt.Fprintf(w, "%s\n\n", string(sb))
fmt.Fprintf(w, "%s\n\n", n.String())
}
})
}