aboutsummaryrefslogtreecommitdiff
path: root/spec/lexer_test.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2022-05-13 22:40:50 +0900
committerRyo Nihei <nihei.dev@gmail.com>2022-05-15 20:42:28 +0900
commit15ea142b25927d6f103ee6ddde4fe8a5e2324831 (patch)
tree8c83fc31ac7d5712374ee82681bea87e071c97fd /spec/lexer_test.go
parentStop handling panic to print a stack trace (diff)
downloadcotia-15ea142b25927d6f103ee6ddde4fe8a5e2324831.tar.gz
cotia-15ea142b25927d6f103ee6ddde4fe8a5e2324831.tar.xz
Prohibit using escape sequences in string literals
Diffstat (limited to 'spec/lexer_test.go')
-rw-r--r--spec/lexer_test.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/spec/lexer_test.go b/spec/lexer_test.go
index 5f555ec..d822de2 100644
--- a/spec/lexer_test.go
+++ b/spec/lexer_test.go
@@ -70,10 +70,10 @@ func TestLexer_Run(t *testing.T) {
},
},
{
- caption: "the lexer can recognize character sequences and escape sequences in a string literal",
- src: `'.*+?|()[\'\\'`,
+ caption: "backslashes are recognized as they are because escape sequences are not allowed in strings",
+ src: `'\\\'`,
tokens: []*token{
- strTok(`.*+?|()['\`),
+ strTok(`\\\`),
newEOFToken(),
},
},
@@ -160,7 +160,7 @@ bar // This is the fourth comment.
err: synErrUnclosedTerminal,
},
{
- caption: "an incompleted terminal in a pattern is not a valid token",
+ caption: "an incompleted escape sequence in a pattern is not a valid token",
src: `"\`,
err: synErrIncompletedEscSeq,
},
@@ -170,11 +170,6 @@ bar // This is the fourth comment.
err: synErrUnclosedString,
},
{
- caption: "an incompleted terminal in a string is not a valid token",
- src: `'\`,
- err: synErrIncompletedEscSeq,
- },
- {
caption: "the lexer can recognize valid tokens following an invalid token",
src: `abc!!!def`,
tokens: []*token{