emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phps-mode a59ef7b 079/405: More unit tests for moving l


From: Stefan Monnier
Subject: [elpa] externals/phps-mode a59ef7b 079/405: More unit tests for moving lexer token positions
Date: Sat, 13 Jul 2019 09:59:47 -0400 (EDT)

branch: externals/phps-mode
commit a59ef7b3eb0b04606100adbb5303b23835b10120
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>

    More unit tests for moving lexer token positions
---
 phps-lexer.el      |  4 ++--
 phps-test-lexer.el | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 3382a00..d96bf2b 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1279,7 +1279,7 @@ ANY_CHAR'
   (setq phps-mode/lexer-tokens (semantic-lex-buffer)))
 
 (defun phps-mode/move-lexer-tokens (old-tokens start diff)
-  "Move lexer OLD-TOKENS positions after START with DIFF points."
+  "Move lexer OLD-TOKENS positions after (or equal to) START with DIFF points."
   (let ((new-tokens '()))
     (when old-tokens
 
@@ -1290,7 +1290,7 @@ ANY_CHAR'
           (let ((token-symbol (car token))
                 (token-start (car (cdr token)))
                 (token-end (cdr (cdr token))))
-            (if (> token-start start)
+            (if (>= token-start start)
                 (let ((new-token-start (+ token-start diff))
                       (new-token-end (+ token-end diff)))
                   (push `(,token-symbol ,new-token-start . ,new-token-end) 
new-tokens))
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 9056461..8ef15d5 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -276,6 +276,22 @@
            '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 7 . 16) (T_ERROR 21 . 60))
            (phps-mode/move-lexer-tokens '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 
7 . 16) (T_ERROR 16 . 55)) 8 5)))
 
+  (should (equal
+           '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 7 . 16) (T_ERROR 11 . 50))
+           (phps-mode/move-lexer-tokens '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 
7 . 16) (T_ERROR 16 . 55)) 8 -5)))
+
+  (should (equal
+           '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 8 . 17) (T_ERROR 17 . 56))
+           (phps-mode/move-lexer-tokens '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 
7 . 16) (T_ERROR 16 . 55)) 7 1)))
+
+  (should (equal
+           '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 7 . 16) (T_ERROR 16 . 55))
+           (phps-mode/move-lexer-tokens '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 
7 . 16) (T_ERROR 16 . 55)) 20 1)))
+
+  (should (equal
+           '((T_OPEN_TAG 2 . 8) (T_START_HEREDOC 8 . 17) (T_ERROR 17 . 56))
+           (phps-mode/move-lexer-tokens '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 
7 . 16) (T_ERROR 16 . 55)) -20 1)))
+
   )
 
 (defun phps-mode/test-lexer ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]