aboutsummaryrefslogtreecommitdiff
path: root/tester/tester.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2022-06-13 00:47:45 +0900
committerRyo Nihei <nihei.dev@gmail.com>2022-06-13 00:47:45 +0900
commit4b2cf7bc03efe6c4fc0b19ca5da071583bdcb900 (patch)
treeb68645aec68fe642de11992cda1b2f6123d6b6d4 /tester/tester.go
parentProhibit using a pattern in an alternative (diff)
downloadurubu-4b2cf7bc03efe6c4fc0b19ca5da071583bdcb900.tar.gz
urubu-4b2cf7bc03efe6c4fc0b19ca5da071583bdcb900.tar.xz
Support testing token's texts in vartan-test command
Diffstat (limited to 'tester/tester.go')
-rw-r--r--tester/tester.go6
1 files changed, 5 insertions, 1 deletions
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...)
}