This commit is contained in:
Mike Farah
2021-11-14 10:59:50 +11:00
parent d912d7d178
commit 63f54563ea
4 changed files with 20 additions and 15 deletions
+12 -1
View File
@@ -92,9 +92,20 @@ func testScenario(t *testing.T, s *expressionScenario) {
func resultsToString(results *list.List) []string {
var pretty []string = make([]string, 0)
for el := results.Front(); el != nil; el = el.Next() {
n := el.Value.(*CandidateNode)
pretty = append(pretty, NodeToString(n))
var valueBuffer bytes.Buffer
printer := NewPrinterWithSingleWriter(bufio.NewWriter(&valueBuffer), YamlOutputFormat, true, false, 4, true)
printer.PrintResults(n.AsList())
tag := n.Node.Tag
if n.Node.Kind == yaml.DocumentNode {
tag = "doc"
} else if n.Node.Kind == yaml.AliasNode {
tag = "alias"
}
output := fmt.Sprintf(`D%v, P%v, (%v)::%v`, n.Document, n.Path, tag, valueBuffer.String())
pretty = append(pretty, output)
}
return pretty
}