aboutsummaryrefslogtreecommitdiff
path: root/driver/parser_test.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2022-05-03 21:40:43 +0900
committerRyo Nihei <nihei.dev@gmail.com>2022-05-10 23:14:34 +0900
commitf7484ef11af39585989dbbcad701551c561fa67c (patch)
tree828b4225802ed442e92017a81d01b5442d2b4fb6 /driver/parser_test.go
parentUpdate CHANGELOG (diff)
downloadurubu-f7484ef11af39585989dbbcad701551c561fa67c.tar.gz
urubu-f7484ef11af39585989dbbcad701551c561fa67c.tar.xz
Add --json option to vartan-parse command
Diffstat (limited to 'driver/parser_test.go')
-rw-r--r--driver/parser_test.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/driver/parser_test.go b/driver/parser_test.go
index fa8307e..4795e29 100644
--- a/driver/parser_test.go
+++ b/driver/parser_test.go
@@ -11,6 +11,7 @@ import (
func termNode(kind string, text string, children ...*Node) *Node {
return &Node{
+ Type: NodeTypeTerminal,
KindName: kind,
Text: text,
Children: children,
@@ -19,13 +20,14 @@ func termNode(kind string, text string, children ...*Node) *Node {
func errorNode() *Node {
return &Node{
+ Type: NodeTypeError,
KindName: "error",
- Error: true,
}
}
func nonTermNode(kind string, children ...*Node) *Node {
return &Node{
+ Type: NodeTypeNonTerminal,
KindName: kind,
Children: children,
}
@@ -131,8 +133,8 @@ bar_text: "bar";
`,
src: ``,
cst: nonTermNode("s",
- termNode("foo", ""),
- termNode("bar", ""),
+ nonTermNode("foo"),
+ nonTermNode("bar"),
),
},
// The driver can reduce productions that have the empty alternative and can generate a CST (and AST) node.
@@ -154,7 +156,7 @@ bar_text: "bar";
`,
src: `bar`,
cst: nonTermNode("s",
- termNode("foo", ""),
+ nonTermNode("foo"),
nonTermNode("bar",
termNode("bar_text", "bar"),
),
@@ -716,7 +718,7 @@ bar: 'bar';
func testTree(t *testing.T, node, expected *Node) {
t.Helper()
- if node.KindName != expected.KindName || node.Text != expected.Text || node.Error != expected.Error {
+ if node.Type != expected.Type || node.KindName != expected.KindName || node.Text != expected.Text {
t.Fatalf("unexpected node; want: %+v, got: %+v", expected, node)
}
if len(node.Children) != len(expected.Children) {