From 4b2cf7bc03efe6c4fc0b19ca5da071583bdcb900 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Mon, 13 Jun 2022 00:47:45 +0900 Subject: Support testing token's texts in vartan-test command --- tester/tester.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tester/tester.go') diff --git a/tester/tester.go b/tester/tester.go index a39026a..187e36c 100644 --- a/tester/tester.go +++ b/tester/tester.go @@ -166,6 +166,10 @@ func runTest(g *gspec.CompiledGrammar, c *TestCaseWithMetadata) *TestResult { } func ConvertSyntaxTreeToTestableTree(dTree *driver.Node) *tspec.Tree { + if dTree.Text != "" { + return tspec.NewTerminalNode(dTree.KindName, dTree.Text) + } + var children []*tspec.Tree if len(dTree.Children) > 0 { children = make([]*tspec.Tree, len(dTree.Children)) @@ -173,5 +177,5 @@ func ConvertSyntaxTreeToTestableTree(dTree *driver.Node) *tspec.Tree { children[i] = ConvertSyntaxTreeToTestableTree(c) } } - return tspec.NewTree(dTree.KindName, children...) + return tspec.NewNonTerminalTree(dTree.KindName, children...) } -- cgit v1.2.3