aboutsummaryrefslogtreecommitdiff
path: root/spec/lexer_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lexer_test.go')
-rw-r--r--spec/lexer_test.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/spec/lexer_test.go b/spec/lexer_test.go
index 7701ce7..bd7fbf0 100644
--- a/spec/lexer_test.go
+++ b/spec/lexer_test.go
@@ -14,7 +14,7 @@ func TestLexer_Run(t *testing.T) {
}{
{
caption: "the lexer can recognize all kinds of tokens",
- src: `id"terminal":|;@#`,
+ src: `id"terminal":|;@#'()$1...`,
tokens: []*token{
newIDToken("id"),
newTerminalPatternToken("terminal"),
@@ -23,6 +23,10 @@ func TestLexer_Run(t *testing.T) {
newSymbolToken(tokenKindSemicolon),
newSymbolToken(tokenKindModifierMarker),
newSymbolToken(tokenKindActionLeader),
+ newSymbolToken(tokenKindTreeNodeOpen),
+ newSymbolToken(tokenKindTreeNodeClose),
+ newPositionToken(1),
+ newSymbolToken(tokenKindExpantion),
newEOFToken(),
},
},
@@ -68,6 +72,11 @@ bar // This is the fourth comment.
err: synErrIncompletedEscSeq,
},
{
+ caption: "a position must be greater than or equal to 1",
+ src: `$0`,
+ err: synErrZeroPos,
+ },
+ {
caption: "the lexer can recognize valid tokens following an invalid token",
src: `abc!!!def`,
tokens: []*token{
@@ -123,7 +132,7 @@ bar // This is the fourth comment.
func testToken(t *testing.T, tok, expected *token) {
t.Helper()
- if tok.kind != expected.kind || tok.text != expected.text {
+ if tok.kind != expected.kind || tok.text != expected.text || tok.num != expected.num {
t.Fatalf("unexpected token; want: %+v, got: %+v", expected, tok)
}
}