aboutsummaryrefslogtreecommitdiff
path: root/spec/test/parser_test.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--spec/test/parser_test.go77
1 files changed, 77 insertions, 0 deletions
diff --git a/spec/test/parser_test.go b/spec/test/parser_test.go
index 7a8984e..cbf96c0 100644
--- a/spec/test/parser_test.go
+++ b/spec/test/parser_test.go
@@ -330,6 +330,83 @@ foo
`,
parseErr: true,
},
+ // A node may have just one string node.
+ {
+ src: `test
+----
+foo bar
+----
+(foo (bar 'bar'))
+`,
+ tc: &TestCase{
+ Description: "test",
+ Source: []byte("foo bar"),
+ Output: NewNonTerminalTree("foo",
+ NewTerminalNode("bar", "bar"),
+ ).Fill(),
+ },
+ },
+ // A node may have just one pattern node.
+ {
+ src: `test
+----
+foo bar
+----
+(foo (bar "bar"))
+`,
+ tc: &TestCase{
+ Description: "test",
+ Source: []byte("foo bar"),
+ Output: NewNonTerminalTree("foo",
+ NewTerminalNode("bar", "bar"),
+ ).Fill(),
+ },
+ },
+ // A node may be the error node.
+ {
+ src: `test
+----
+foo x
+----
+(foo (error))
+`,
+ tc: &TestCase{
+ Description: "test",
+ Source: []byte("foo x"),
+ Output: NewNonTerminalTree("foo",
+ NewTerminalNode("error", ""),
+ ).Fill(),
+ },
+ },
+ // The error node cannot have a string node.
+ {
+ src: `test
+----
+foo x
+----
+(foo (error 'x'))
+`,
+ parseErr: true,
+ },
+ // The error node cannot have a pattern node.
+ {
+ src: `test
+----
+foo x
+----
+(foo (error "x"))
+`,
+ parseErr: true,
+ },
+ {
+ src: `test
+----
+foo x
+----
+(foo (error (_ (x 'x'))))
+`,
+ parseErr: true,
+ },
{
src: `test
---