branch: elpa/parseclj
commit 388bb2bde2f1985e246d52c3970c8468e03ca69d
Author: Daniel Barreto <[email protected]>
Commit: Daniel Barreto <[email protected]>
Fix test case for `\u` and `\o` characters
Before this commit, reading something like "\u \v \w", would produce two
char
tokens, one with "\u \v " and another with "\w". Test included exemplifies
solution.
---
parseclj-lex.el | 4 ++--
test/parseclj-lex-test.el | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/parseclj-lex.el b/parseclj-lex.el
index d835457903..1d4f28a5b5 100644
--- a/parseclj-lex.el
+++ b/parseclj-lex.el
@@ -297,11 +297,11 @@ token is returned."
(right-char 7)
(parseclj-lex-token :character (buffer-substring-no-properties pos
(point)) pos))
- ((equal (char-after (point)) ?u)
+ ((string-match-p "^u[0-9a-fA-F]\\{4\\}" (parseclj-lex-lookahead 5))
(right-char 5)
(parseclj-lex-token :character (buffer-substring-no-properties pos
(point)) pos))
- ((equal (char-after (point)) ?o)
+ ((string-match-p "^o[0-8]\\{3\\}" (parseclj-lex-lookahead 4))
(right-char 4)
(parseclj-lex-token :character (buffer-substring-no-properties pos
(point)) pos))
diff --git a/test/parseclj-lex-test.el b/test/parseclj-lex-test.el
index bc72bfb7f8..eae02a07af 100644
--- a/test/parseclj-lex-test.el
+++ b/test/parseclj-lex-test.el
@@ -113,6 +113,15 @@
(should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\b"
28)))
(should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\c"
30))))
+ (with-temp-buffer
+ (insert "\\u \\v \\w")
+ (goto-char 1)
+ (should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\u"
1)))
+ (should (equal (parseclj-lex-next) (parseclj-lex-token :whitespace " " 3)))
+ (should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\v"
4)))
+ (should (equal (parseclj-lex-next) (parseclj-lex-token :whitespace " " 6)))
+ (should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\w"
7))))
+
(with-temp-buffer
(insert "\\u0078\\o170")
(goto-char 1)