From 1ebed922b8c642b6ff4cec71820f24ceeb331c18 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sun, 29 May 2022 15:55:53 +0900 Subject: Support testable tree output in vartan-parse command --- tester/tester.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tester') diff --git a/tester/tester.go b/tester/tester.go index ef3ca61..70d4800 100644 --- a/tester/tester.go +++ b/tester/tester.go @@ -152,7 +152,7 @@ func runTest(g *gspec.CompiledGrammar, c *TestCaseWithMetadata) *TestResult { } // When a parse tree exists, the test continues regardless of whether or not syntax errors occurred. - diffs := tspec.DiffTree(genTree(tb.Tree()).Fill(), c.TestCase.Output) + diffs := tspec.DiffTree(ConvertSyntaxTreeToTestableTree(tb.Tree()).Fill(), c.TestCase.Output) if len(diffs) > 0 { return &TestResult{ TestCasePath: c.FilePath, @@ -165,12 +165,12 @@ func runTest(g *gspec.CompiledGrammar, c *TestCaseWithMetadata) *TestResult { } } -func genTree(dTree *driver.Node) *tspec.Tree { +func ConvertSyntaxTreeToTestableTree(dTree *driver.Node) *tspec.Tree { var children []*tspec.Tree if len(dTree.Children) > 0 { children = make([]*tspec.Tree, len(dTree.Children)) for i, c := range dTree.Children { - children[i] = genTree(c) + children[i] = ConvertSyntaxTreeToTestableTree(c) } } return tspec.NewTree(dTree.KindName, children...) -- cgit v1.2.3