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

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

[elpa] externals/phps-mode c7ad55c 255/405: Passed first integration-tes


From: Stefan Monnier
Subject: [elpa] externals/phps-mode c7ad55c 255/405: Passed first integration-test
Date: Sat, 13 Jul 2019 10:00:27 -0400 (EDT)

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

    Passed first integration-test
---
 phps-mode-lexer.el            | 24 ++++++++++++++----------
 phps-mode-test-integration.el | 29 +++++++++++++++++++++++------
 2 files changed, 37 insertions(+), 16 deletions(-)

diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el
index 4dc8814..1e6b00f 100644
--- a/phps-mode-lexer.el
+++ b/phps-mode-lexer.el
@@ -1269,6 +1269,20 @@ ANY_CHAR'
 (defun phps-mode-lexer-setup (start end)
   "Just prepare other lexers for lexing region START to END."
   ;; (message "phps-mode-lexer-setup %s %s" start end)
+
+  ;; Reset line indents
+  (when (and (boundp 'phps-mode-functions-lines-indent)
+             phps-mode-functions-lines-indent)
+    (setq phps-mode-functions-lines-indent nil))
+
+  ;; Reset imenu index
+  (when (and (boundp 'phps-mode-functions-imenu)
+             phps-mode-functions-imenu)
+    (setq phps-mode-functions-imenu nil))
+
+  ;; TODO Delete all overlays after point of change if it's incremental
+
+  ;; Does lexer start from the beginning of buffer?
   (when (and (eq start 1)
              end)
     (delete-all-overlays)
@@ -1278,16 +1292,6 @@ ANY_CHAR'
                phps-mode-lexer-buffer-changes--start)
       (setq phps-mode-lexer-buffer-changes--start nil))
 
-    ;; Reset line indents
-    (when (and (boundp 'phps-mode-functions-lines-indent)
-               phps-mode-functions-lines-indent)
-      (setq phps-mode-functions-lines-indent nil))
-
-    ;; Reset imenu index
-    (when (and (boundp 'phps-mode-functions-imenu)
-               phps-mode-functions-imenu)
-      (setq phps-mode-functions-imenu nil))
-
     (setq phps-mode-lexer-states nil)
     (phps-mode-lexer-BEGIN phps-mode-lexer-ST_INITIAL)))
 
diff --git a/phps-mode-test-integration.el b/phps-mode-test-integration.el
index 9d865e7..4d37fcb 100644
--- a/phps-mode-test-integration.el
+++ b/phps-mode-test-integration.el
@@ -41,7 +41,7 @@
 
     (phps-mode-test-with-buffer
    "<?php\nnamespace myNamespace\n{\n    class myClass\n    {\n        public 
function myFunction()\n        {\n            echo 'my statement';\n        }\n 
   }\n}\n"
-   "Regular PHP with namespaces, classes and functions"
+   "Integration-test for regular PHP with namespaces, classes and functions"
 
    ;; Tokens
    (when (and (boundp 'phps-mode-lexer-tokens)
@@ -55,12 +55,29 @@
    ;; Imenu
    (should (equal (phps-mode-functions-get-imenu) '(("\\myNamespace" . 17) 
("\\myNamespace\\myClass" . 41) ("\\myNamespace\\myClass->myFunction()" . 79))))
 
-   ;; TODO Make changes
+   ;; Make changes
+   (goto-char 144)
+   (insert "\n\n        public function myFunctionB()\n        {\n            
echo 'my second statement';\n        }\n")
 
-   ;; TODO New test for tokens
-   ;; TODO New test for indentation
-   ;; TODO new test for Imenu
-   )
+   ;; Verify stored point of change
+   (when (boundp 'phps-mode-functions-buffer-changes-start)
+     (should (equal phps-mode-functions-buffer-changes-start 144)))
+
+   ;; Run incremental lexer
+   (phps-mode-lexer-run-incremental)
+
+   ;; Tokens
+   (when (and (boundp 'phps-mode-lexer-tokens)
+              phps-mode-lexer-tokens)
+     ;; (message "Tokens %s" phps-mode-lexer-tokens)
+     (should (equal phps-mode-lexer-tokens '((T_OPEN_TAG 1 . 7) (T_NAMESPACE 7 
. 16) (T_STRING 17 . 28) ("{" 29 . 30) (T_CLASS 35 . 40) (T_STRING 41 . 48) 
("{" 53 . 54) (T_PUBLIC 63 . 69) (T_FUNCTION 70 . 78) (T_STRING 79 . 89) ("(" 
89 . 90) (")" 90 . 91) ("{" 100 . 101) (T_ECHO 114 . 118) 
(T_CONSTANT_ENCAPSED_STRING 119 . 133) (";" 133 . 134) ("}" 143 . 144) 
(T_PUBLIC 154 . 160) (T_FUNCTION 161 . 169) (T_STRING 170 . 181) ("(" 181 . 
182) (")" 182 . 183) ("{" 192 . 193) (T_ECHO 206 . 210 [...]
+
+   ;; Indentation
+   ;; (message "indent: %s" (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)))
+   (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (1 0)) (6 (2 
0)) (7 (2 0)) (8 (3 0)) (9 (2 0)) (10 (2 0)) (11 (2 0)) (12 (2 0)) (13 (3 0)) 
(14 (2 0)) (15 (2 0)) (16 (1 0)) (17 (0 0))) (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent))))
+
+   ;; Imenu
+   (should (equal (phps-mode-functions-get-imenu) '(("\\myNamespace" . 17) 
("\\myNamespace\\myClass" . 41) ("\\myNamespace\\myClass->myFunction()" . 79) 
("\\myNamespace\\myClass->myFunctionB()" . 170)))))
 
 )
 



reply via email to

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