diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2022-05-13 22:40:50 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2022-05-15 20:42:28 +0900 |
commit | 15ea142b25927d6f103ee6ddde4fe8a5e2324831 (patch) | |
tree | 8c83fc31ac7d5712374ee82681bea87e071c97fd /spec/lexer_test.go | |
parent | Stop handling panic to print a stack trace (diff) | |
download | cotia-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.go | 13 |
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{ |