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

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

[elpa] externals/phps-mode 3d3003f 364/405: Started on test for newline-


From: Stefan Monnier
Subject: [elpa] externals/phps-mode 3d3003f 364/405: Started on test for newline-and-indent before white-space
Date: Sat, 13 Jul 2019 10:00:52 -0400 (EDT)

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

    Started on test for newline-and-indent before white-space
---
 phps-mode-functions.el      |  9 +++++----
 phps-mode-test-functions.el | 15 +++++++++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 41ad779..3385c41 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -96,7 +96,7 @@
   "Process current buffer and generation indentation and Imenu in one 
iteration.  Complexity: O(n)."
   (if (boundp 'phps-mode-lexer-tokens)
       (save-excursion
-        (message "Processing current buffer")
+        ;; (message "Processing current buffer")
         (goto-char (point-min))
         (when phps-mode-functions-verbose
           (message "\nCalculation indentation for all lines in buffer:\n\n%s" 
(buffer-substring-no-properties (point-min) (point-max))))
@@ -823,15 +823,16 @@
 
           (if looking-at-whitespace
               (progn
-                (message "Looking at white-space")
+                ;; (message "Looking at white-space")
                 (setq new-pos (point))
                 (let ((diff (- new-pos old-pos)))
                   (when (> diff 0)
                     (phps-mode-lexer-move-tokens old-pos diff)
                     (phps-mode-lexer-move-states old-pos diff)
-                    (message "Old pos %s, new pos: %s, diff: %s" old-pos 
new-pos diff)
+                    ;; (message "Old pos %s, new pos: %s, diff: %s" old-pos 
new-pos diff)
                     )))
-            (message "Not looking at white-space"))))
+            ;; (message "Not looking at white-space")
+            )))
     (apply old-function arguments)))
 
 (defun phps-mode-functions-indent-line ()
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index ab14cc9..30ce7c7 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -856,6 +856,7 @@
 
 (defun phps-mode-test-functions-whitespace-modifications ()
   "Test white-space modifications functions."
+
   (phps-mode-test-with-buffer
    "<?php\n$var = 'abc';\n\n$var2 = '123';\n"
    "Add newline between two assignments and inspect moved tokens and states"
@@ -869,6 +870,20 @@
                   '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 11) ("=" 12 . 13) 
(T_CONSTANT_ENCAPSED_STRING 14 . 19) (";" 19 . 20) (T_VARIABLE 23 . 28) ("=" 29 
. 30) (T_CONSTANT_ENCAPSED_STRING 31 . 36) (";" 36 . 37))))
    )
 
+  (phps-mode-test-with-buffer
+   "<?php\nif (true):\n    $var = 'abc';\n    $var2 = '123';\nendif;\n"
+   "Add newline inside if body after two assignments and inspect moved tokens 
and states"
+   (message "Tokens %s" (phps-mode-lexer-get-tokens))
+   (should (equal (phps-mode-lexer-get-tokens)
+                  '((T_OPEN_TAG 1 . 7) (T_IF 7 . 9) ("(" 10 . 11) (T_STRING 11 
. 15) (")" 15 . 16) (":" 16 . 17) (T_VARIABLE 22 . 26) ("=" 27 . 28) 
(T_CONSTANT_ENCAPSED_STRING 29 . 34) (";" 34 . 35) (T_VARIABLE 40 . 45) ("=" 46 
. 47) (T_CONSTANT_ENCAPSED_STRING 48 . 53) (";" 53 . 54) (T_ENDIF 55 . 60) (";" 
60 . 61))))
+   (goto-char 54)
+   (newline-and-indent)
+   (message "Tokens %s" (phps-mode-lexer-get-tokens))
+   (should (equal (phps-mode-lexer-get-tokens)
+                  '(should (equal (phps-mode-lexer-get-tokens)
+                  '((T_OPEN_TAG 1 . 7) (T_IF 7 . 9) ("(" 10 . 11) (T_STRING 11 
. 15) (")" 15 . 16) (":" 16 . 17) (T_VARIABLE 22 . 26) ("=" 27 . 28) 
(T_CONSTANT_ENCAPSED_STRING 29 . 34) (";" 34 . 35) (T_VARIABLE 40 . 45) ("=" 46 
. 47) (T_CONSTANT_ENCAPSED_STRING 48 . 53) (";" 53 . 54) (T_ENDIF 55 . 60) (";" 
60 . 61))))))
+   )
+
   )
 
 (defun phps-mode-test-functions ()



reply via email to

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